Re: [sqlalchemy] [Q] Why the following emits SQL for slot access?

2012-09-27 Thread Ladislav Lenart
, session will keep them all until explicitly removed from it to eliminate successive SQL queries. Ladislav Lenart On 27.9.2012 20:31, Ladislav Lenart wrote: Hello. not sure, is each.bar a typo and you meant _each_bar ? No, I mean each.bar. or are you trying to fetch a relationship

Re: [sqlalchemy] [Q] Why the following emits SQL for slot access?

2012-09-27 Thread Ladislav Lenart
of those tricky bits one has to be caution about :-) Ladislav Lenart On 27.9.2012 22:20, Michael Bayer wrote: On Sep 27, 2012, at 3:17 PM, Ladislav Lenart wrote: Update. Te unwrap version works only if the original result of q.all() is kept around: def test_access(self): q

Re: [sqlalchemy] [Q] How to detect / intercept when a slot access emits SQL?

2012-09-26 Thread Ladislav Lenart
what could be wrong? Thank you, Ladislav Lenart On 26.9.2012 01:37, Michael Bayer wrote: pretty much what I use for that is an event listener for SQL, which logs/doesn't log based on external state.We have kind of a crufty one in the test suite (see assertsql.py and testing.py

Re: [sqlalchemy] [Q] How to detect / intercept when a slot access emits SQL?

2012-09-26 Thread Ladislav Lenart
' for target... self.engine and type(self.engine) are the only two objects that event.listen is happy with. Unfortunately NONE of them works for queries that use self.session. I have no idea how to proceed so any help or hint is much appreciated. Thank you in advance, Ladislav Lenart On 26.9.2012 16:41

Re: [sqlalchemy] [Q] How to detect / intercept when a slot access emits SQL?

2012-09-26 Thread Ladislav Lenart
raise exc.InvalidRequestError(No such event '%s' for target '%s' % As I have written, the only two objects in the setUp method that the function event.listen accepts are self.engine and type(self.engine). Any other idea what am I doing wrong? Ladislav Lenart On 26.9.2012 19:07, Michael Bayer

Re: [sqlalchemy] [Q] Option joinedload_all with joined table inheritance

2012-09-25 Thread Ladislav Lenart
On 24.9.2012 19:38, Michael Bayer wrote: On Sep 24, 2012, at 1:14 PM, Ladislav Lenart wrote: Hello. I have tried the variant for SA 0.7. The query I tried is this: q = self.session.query(self.ClientProduct) q = q.options(joinedload_all(A.b, B.c)) #q = q.options(joinedload_all

Re: [sqlalchemy] [Q] Option joinedload_all with joined table inheritance

2012-09-25 Thread Ladislav Lenart
= q.options(joinedload_all( ClientProduct.client.of_type(PersonalClient), PersonalClient.person )) Thank you again for your assistance, Ladislav Lenart On 25.9.2012 16:20, Michael Bayer wrote: On Sep 25, 2012, at 7:50 AM, Ladislav Lenart wrote: On 24.9.2012 19:38, Michael

[sqlalchemy] [Q] How to detect / intercept when a slot access emits SQL?

2012-09-25 Thread Ladislav Lenart
). Thank you, Ladislav Lenart -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options

[sqlalchemy] [Q] Option joinedload_all with joined table inheritance

2012-09-24 Thread Ladislav Lenart
in advance, Ladislav Lenart -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options

Re: [sqlalchemy] [Q] Option joinedload_all with joined table inheritance

2012-09-24 Thread Ladislav Lenart
Hello. On 24.9.2012 18:31, Michael Bayer wrote: On Sep 24, 2012, at 12:06 PM, Ladislav Lenart wrote: Hello. Suppose the following example query q = session.query(A) q = q.options(joinedload_all(A.b, B.c, C.d) q = q.otions(joinedload_all(A.client, PersonalClient.person

Re: [sqlalchemy] [Q] Option joinedload_all with joined table inheritance

2012-09-24 Thread Ladislav Lenart
in mind (I still have to study the option contains_eager). Ladislav Lenart On 24.9.2012 18:31, Michael Bayer wrote: On Sep 24, 2012, at 12:06 PM, Ladislav Lenart wrote: Hello. Suppose the following example query q = session.query(A) q = q.options(joinedload_all(A.b, B.c, C.d

Re: [sqlalchemy] joinedload option changes outcome of recursive query

2012-09-19 Thread Ladislav Lenart
= q.order_by(q_cte_union.c.iteration) q = q.options(joinedload_all(cls.foo, Foo.bar)) return q Thank you again for your patient guidance, Ladislav Lenart On 18.9.2012 15:28, Ladislav Lenart wrote: Ok, thank you. I know about SELECT a, b FROM x ORDER BY c I just don't know how

Re: [sqlalchemy] [Q] Lack of isolation in unit tests

2012-09-19 Thread Ladislav Lenart
with a single test case to play with, hence I define ORM classes locally in each test and test my assumptions about how SQLAlchemy works :-) Ladislav Lenart On 18.9.2012 17:40, Michael Bayer wrote: On Sep 18, 2012, at 11:36 AM, Ladislav Lenart wrote: Hello. Adding call to clear_mappers

Re: [sqlalchemy] joinedload option changes outcome of recursive query

2012-09-18 Thread Ladislav Lenart
again for your time, Ladislav Lenart On 17.9.2012 16:05, Michael Bayer wrote: On Sep 17, 2012, at 9:23 AM, Ladislav Lenart wrote: Hm, I see. My train of thought: This particular query returns the path from a selected node to the root. Each iteration adds one row to the result set (one new

[sqlalchemy] [Q] Lack of isolation in unit tests

2012-09-18 Thread Ladislav Lenart
separate declarative bases, each with its own metadata, is enough to ensure isolation among tests. Was my assumption wrong? Can I achieve proper isolation of unit tests somehow? Thank you, Ladislav Lenart -- You received this message because you are subscribed to the Google Groups sqlalchemy

Re: [sqlalchemy] [Q] Lack of isolation in unit tests

2012-09-18 Thread Ladislav Lenart
Hello again. The problem is in sqlalchemy.orm.mapper. There are globals _mapper_registry and a boolean _new_mappers that triggers recompilation of the mappers. Is there a safe way to clear them in each test's case tearDown? Thank you in advance, Ladislav Lenart On 18.9.2012 16:07, Ladislav

Re: [sqlalchemy] [Q] Lack of isolation in unit tests

2012-09-18 Thread Ladislav Lenart
the following tests fail because of this. I tried to delete all ORM classes defined in the test but this did not help. Perhaps there are lingering references to them somewhere. I am not sure how Python's GC works. Anyway, thank you again for your quick help, Ladislav Lenart On 18.9.2012 16:39

[sqlalchemy] joinedload option changes outcome of recursive query

2012-09-17 Thread Ladislav Lenart
option should not have observable side-effects. Was I wrong? Can I preload dependent data by some other means without semantic change in the query? Thank you in advance, Ladislav Lenart -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post

Re: [sqlalchemy] joinedload option changes outcome of recursive query

2012-09-17 Thread Ladislav Lenart
Hello again. I have replaced joinedload_all option with subqueryload_all and the query works as expected: order of the results is correct. Ladislav Lenart On 17.9.2012 13:19, Ladislav Lenart wrote: Hello. Imagine the following ORM definition in PostgreSQL: class Node(Base

Re: [sqlalchemy] joinedload option changes outcome of recursive query

2012-09-17 Thread Ladislav Lenart
On 17.9.2012 14:54, Michael Bayer wrote: On Sep 17, 2012, at 7:19 AM, Ladislav Lenart wrote: Hello. Imagine the following ORM definition in PostgreSQL: class Node(Base): __tablename__ = 'node' id = Column(Integer(), primary_key=True) parent_id = Column(Integer

[sqlalchemy] [Q] Any difference betwen two style of core inserts?

2012-09-10 Thread Ladislav Lenart
.insert().values({ 'foo': i, 'bar': i }) session.execute(ins) I guess there is. If so, can the second example be written more efficiently (but still using session)? Thank you, Ladislav Lenart -- You received this message because you are subscribed

Re: [sqlalchemy] [Q] How to return mapped instances from a recursive cte

2012-09-06 Thread Ladislav Lenart
documentation now and still don't see any mention of this functionality there. Is it somewhere? What should I have been googling for to find it quickly in the first place? Thank you again, Ladislav Lenart On 5.9.2012 18:22, Michael Bayer wrote: On Sep 5, 2012, at 9:05 AM, Ladislav Lenart wrote

Re: [sqlalchemy] [Q] How to return mapped instances from a recursive cte

2012-09-06 Thread Ladislav Lenart
Hello. On 6.9.2012 13:04, Michael Bayer wrote: On Sep 6, 2012, at 5:07 AM, Ladislav Lenart wrote: It works! Thank you very much for such a quick response! It is a pity I was unable to find it on my own though. I spent several hours searching and reading various parts of SA documentation

Re: [sqlalchemy] [Q] How to return mapped instances from a recursive cte

2012-09-06 Thread Ladislav Lenart
Thank you for the explanation / brief history overview. Now it makes perfect sense why things are the way they are. Keep up the excellent work! Hopefully one day my knowledge of SQL Alchemy will catch up too :-) Ladislav Lenart On 6.9.2012 16:23, Michael Bayer wrote: On Sep 6, 2012, at 7:25

[sqlalchemy] [Q] How to return mapped instances from a recursive cte

2012-09-05 Thread Ladislav Lenart
) q = session.query(q_cte_union) return q The above query seems to do what I intend but it returns named tuples and not Node instances. I spent all day searching SA docs but with no luck so far. Is this possible? If so, how? Thank you very much in advance, Ladislav Lenart -- You

[sqlalchemy] [0.7.X] - Minor omission in documentation of Dialect-specific compilation rules

2012-07-13 Thread Ladislav Lenart
Hello all. My name is Ladislav Lenart and I am new to SQLAlchemy and this group. I've been reading SQLAlchemy documenation at: http://docs.sqlalchemy.org/en/rel_0_7/core/compiler.html#synopsis I think the section Dialect-specific compilation rules contains an error: * Both decorated

<    1   2