[sqlalchemy] Inconsistent results in session.flush()

2007-03-16 Thread King Simon-NFHD78
Hi, I'm having a problem where the results of session.flush() vary from one run to another of my test suite. The unit of work transaction dump is significantly different from one run to the next, similar to the issue in ticket 461. I haven't managed to make a test case small enough to post to

[sqlalchemy] Re: Inconsistent results in session.flush()

2007-03-16 Thread King Simon-NFHD78
what pairs of classes the UOW perceives as dependent on each other. On Mar 16, 2007, at 6:59 AM, King Simon-NFHD78 wrote: Hi, I'm having a problem where the results of session.flush() vary from one run to another of my test suite. The unit of work transaction dump

[sqlalchemy] Re: table name bind param

2007-03-15 Thread King Simon-NFHD78
tml wrote: also to clarify, the text actually has :table_name used in many other places: t = metadata.engine.text(LOCK TABLE :table_name WRITE; UPDATE :table_name SET rgt=rgt + 2 WHERE rgt :insert_node_val and parent_id = :parent_id;

[sqlalchemy] Re: Polymorphic collections / ticket #500

2007-03-06 Thread King Simon-NFHD78
I wanted to do something like this in the past, and in the end, rather than using polymorphic mappers it made more sense to create a MapperExtension which overrides create_instance. In create_instance you can examine your 'typ' column to decide what class to create, selecting one of your

[sqlalchemy] Table being removed from nested query

2007-03-06 Thread King Simon-NFHD78
Hi, I have a problem in which a table is being removed from the FROM clause of a nested query. The attached file should show the problem, which I've tested on 0.3.5 and rev 2383. In the example, there are two tables, department and employee, such that one department has many employees. The inner

[sqlalchemy] Re: Associations in a cleaner way

2007-03-05 Thread King Simon-NFHD78
Knut Aksel Røysland wrote: [snip] However, an instance of D also needs a reference to an instance of C. If the appropriate instance of C exists in the database (or is pending to go into it), I want to pick this one, or otherwise create a new instance of C. What I am looking for is

[sqlalchemy] Re: SQA failing on table creation

2007-03-02 Thread King Simon-NFHD78
percious wrote: Here is the dump: ...snip... sqlalchemy.exceptions.SQLError: (OperationalError) (1071, 'Specified key was too long; max key length is 999 bytes') '\nCREATE TABLE `Album` (\n\tid INTEGER NOT NULL AUTO_INCREMENT, \n\tname VARCHAR(128), \n\tdirectory VARCHAR(512),

[sqlalchemy] Re: How do I tell if an object has been INSERTed or UPDATEd?

2007-02-26 Thread King Simon-NFHD78
Marco Mariani wrote: Simon Willison wrote: I've got a bit of code that looks like this: session = get_session() session.save(obj) session.flush() You can see what's going to be inserted/updated/deleted by accessing session.new, session.dirty, session.deleted

[sqlalchemy] Re: Lazy loading advantages and disadvantages

2007-02-22 Thread King Simon-NFHD78
Adam M Peacock wrote: Is there a difference in the SQL executed when using lazy vs eager loading? Specifically, if I use eager loading will everything be queried at once with a more efficient join, or will it still use the lazy style (as far as I understand it) of generating a ton

[sqlalchemy] Re: new setuptools vs local SA copy

2007-02-06 Thread King Simon-NFHD78
Rick Morrison wrote: I keep two versions of SA installed here, one is a stable version installed in the Python site-packages folder, and one is current trunk with some local patches for testing. I used to be able to run tests and programs using the local version by just inserting the

[sqlalchemy] Re: SelectResults, counts and one-to-many relationships

2007-02-06 Thread King Simon-NFHD78
Michael Bayer wrote: I added distinct() to selectresults as a method and made the unit test a little clearer (since i dont like relying on the selectresults mod)... q = sess.query(Department) d = SelectResults(q) d =

[sqlalchemy] Re: iteration over mapper

2007-01-31 Thread King Simon-NFHD78
Jose Soares wrote: Hi all, Probably this is a stupid question, :-[ but I don't understand how to iterate an object mapper to get fields value. --- user = session.query(User).select(id=1) for j in user.c: print j.name logname id password for j in user.c: print

[sqlalchemy] Using .label() on boolean expressions

2007-01-19 Thread King Simon-NFHD78
Hi, I don't know if this is valid SQL, but MySQL seems to accept it... I'd like to write a query that looks like: SELECT s.result LIKE 'Pass%' AS pass ... Which would return 1 or 0 for each row depending on whether the result column begins with Pass. In SQLAlchemy this would become:

[sqlalchemy] Re: Using .label() on boolean expressions

2007-01-19 Thread King Simon-NFHD78
Simon King wrote: I don't know if this is valid SQL, but MySQL seems to accept it... I'd like to write a query that looks like: SELECT s.result LIKE 'Pass%' AS pass ... Which would return 1 or 0 for each row depending on whether the result column begins with Pass. Another way I

[sqlalchemy] Re: Questions about polymorphic mappers

2007-01-18 Thread King Simon-NFHD78
Michael Bayer wrote: Simon King wrote: [requirements for instances returned from MapperExtension.create_instance] at this point the entity_name should get set after your custom create_instance is called (at least thats in the trunk). init_attr is not required, it pre-sets attributes on

[sqlalchemy] Re: Questions about polymorphic mappers

2007-01-15 Thread King Simon-NFHD78
Micheal Bayer wrote: id rather just add another plugin point on MapperExtension for this, which takes place before the polymorphic decision stage at the top of the _instance method, like get_polymorphic_identity(). that way you could do all of this stuff cleanly in an extension (and id do

[sqlalchemy] Re: Questions about polymorphic mappers

2007-01-12 Thread King Simon-NFHD78
Michael Bayer wrote: i think using the polymorphic_map is OK. i downplayed its existence since I felt it was confusing to people, which is also the reason i made the _polymorphic_map argument to mapper private; it was originally public. but it seemed like it was producing two ways of

<    1   2   3