[sqlalchemy] Re: Determining types of joined attributes

2007-12-09 Thread Brendan Arnold
Ah I see, sorry, what I meant to ask was if there was a way to tell the difference with _instances_ of orm objects brendan On Dec 8, 2007 7:32 PM, Michael Bayer [EMAIL PROTECTED] wrote: On Dec 8, 2007, at 2:09 PM, Brendan Arnold wrote: hmm strange, i tried this out with sqlalchemy

[sqlalchemy] Re: SA and MySQL replication.

2007-12-09 Thread Anton V. Belyaev
On Dec 6, 11:51 pm, Andrew Stromnov [EMAIL PROTECTED] wrote: I have DB with onemasterserver and several replicated slaves (MySQL). How to implement this functionality: read-only request can be passed to any DB (masterorslave), but any write request with following read requests must be sended

[sqlalchemy] Re: Determining types of joined attributes

2007-12-09 Thread Michael Bayer
On Dec 9, 2007, at 10:10 AM, Brendan Arnold wrote: Ah I see, sorry, what I meant to ask was if there was a way to tell the difference with _instances_ of orm objects youd call object_mapper(instance) and then do the same thing using mapper.get_property().

[sqlalchemy] Re: SA and MySQL replication.

2007-12-09 Thread Michael Bayer
On Dec 9, 2007, at 11:50 AM, Anton V. Belyaev wrote: On Dec 6, 11:51 pm, Andrew Stromnov [EMAIL PROTECTED] wrote: I have DB with onemasterserver and several replicated slaves (MySQL). How to implement this functionality: read-only request can be passed to any DB (masterorslave), but any

[sqlalchemy] Re: Undeferring attributes off joined entities

2007-12-09 Thread Chris M
Is this how you want to do it? Unfortunately, just your fix alone doesn't do the trick BUT if you change line 901 of query.py to context.exec_with_path(m, value.key, value.setup, context, parentclauses=clauses) it works, and all ORM tests run fine. On Dec 8, 10:59 pm, Michael Bayer [EMAIL

[sqlalchemy] Re: From arbitrary SELECT to Query

2007-12-09 Thread Artur Siekielski
But is Query object constructed by from_statement fully functional? Using filter doesn't work for me - it returns the same query. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this

[sqlalchemy] Re: From arbitrary SELECT to Query

2007-12-09 Thread Michael Bayer
On Dec 9, 2007, at 1:03 PM, Artur Siekielski wrote: But is Query object constructed by from_statement fully functional? Using filter doesn't work for me - it returns the same query. no, from_statement replaces all filtering. so, what is it youre trying to do exactly ?

[sqlalchemy] Re: Undeferring attributes off joined entities

2007-12-09 Thread Michael Bayer
On Dec 9, 2007, at 1:21 PM, Chris M wrote: Is this how you want to do it? Unfortunately, just your fix alone doesn't do the trick BUT if you change line 901 of query.py to context.exec_with_path(m, value.key, value.setup, context, parentclauses=clauses) it works, and all ORM tests run

[sqlalchemy] Re: From arbitrary SELECT to Query

2007-12-09 Thread Artur Siekielski
no, from_statement replaces all filtering. Shouldn't it throw some exception then? so, what is it youre trying to do exactly ? I'm writing DAO module for db access which must be independent of rest of the system. I'm looking for a class which can be used as a proxy for SQL results. Query

[sqlalchemy] save_or_update and composit Primary Keys...

2007-12-09 Thread Smoke
Hi, These days i'm playing with sqlalchemy to know if it can fit my needs... I'm having some troubles with this ( maybe it's a real dumb question.. or maybe a non supported feature.. :) ): I have a database (mssql) with some tables with composite primary keys... something like this: t_jobs =

[sqlalchemy] Re: From arbitrary SELECT to Query

2007-12-09 Thread Michael Bayer
On Dec 9, 2007, at 2:31 PM, Artur Siekielski wrote: no, from_statement replaces all filtering. Shouldn't it throw some exception then? funny you should say that, this week we've been adding warnings for query methods that are called when they would ignore some part of the existing

[sqlalchemy] Re: save_or_update and composit Primary Keys...

2007-12-09 Thread Michael Bayer
On Dec 9, 2007, at 2:54 PM, Smoke wrote: When i create and save a j = Job(identifier, start), I have no problems and it saves the new record on the table, but when i want to update ( update or save_or_update ) the record with the stop time i just don't update the record... It does not throw

[sqlalchemy] Re: Undeferring attributes off joined entities

2007-12-09 Thread Chris M
Nope, eagerloads are a no-go. I tried changing 901 of query.py again to: context.exec_with_path(m, value.key, value.setup, context, parentclauses=clauses, parentmapper=m) but that did not work either. The code around exec_with_path and setup_query confuses me, I'm not sure I can fix eagerloads

[sqlalchemy] Re: Undeferring attributes off joined entities

2007-12-09 Thread Chris M
I'll commit what I have and some tests sometime soon so you can see what's going on (unless you're by chance magical and already know what's going on!) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy

[sqlalchemy] Re: From arbitrary SELECT to Query

2007-12-09 Thread Michael Bayer
heres the output of: sel = users.select(users.c.id.in_([7, 8])).alias() sess.query(User).options(eagerload('addresses')).select_from(sel)[1] SELECT anon_1.anon_2_id AS anon_1_anon_2_id, anon_1.anon_2_name AS anon_1_anon_2_name, addresses_1.id AS addresses_1_id, addresses_1.user_id AS

[sqlalchemy] Lazy ID Fetching/generation

2007-12-09 Thread Adam Batkin
If I create an object, then save() it, potentially the object won't be actually persisted until sqlalchemy decides that it needs to (for example on flush/commit, or when some query involving Thing's table gets executed) which is good. But (in my opinion) the lazyness is a bit too lazy when it

[sqlalchemy] Re: Lazy ID Fetching/generation

2007-12-09 Thread Michael Bayer
On Dec 9, 2007, at 4:10 PM, Adam Batkin wrote: If I create an object, then save() it, potentially the object won't be actually persisted until sqlalchemy decides that it needs to (for example on flush/commit, or when some query involving Thing's table gets executed) which is good. But

[sqlalchemy] Re: Lazy ID Fetching/generation

2007-12-09 Thread Adam Batkin
My thought is that sqlalchemy should force the object to be flushed (or whatever must be done to determine the ID, possibly just selecting the next value from a sequence) when the id property is retrieved. can't be done for mysql, sqlite, MSSQL, others, without issuing an INSERT.

[sqlalchemy] Re: Undeferring attributes off joined entities

2007-12-09 Thread Michael Bayer
On Dec 9, 2007, at 3:59 PM, Chris M wrote: I'll commit what I have and some tests sometime soon so you can see what's going on (unless you're by chance magical and already know what's going on!) im doing some surgery on Query at the momentmight be better if you wait for the next

[sqlalchemy] Re: save_or_update and composit Primary Keys...

2007-12-09 Thread Smoke
On 9 Dic, 21:37, Michael Bayer [EMAIL PROTECTED] wrote: theyre entirely supported. try to provide a fully working example illustrating the problem youre having. Here's a small example just to simulate the problem.. The last part of this code is there just to simulate the problem... normally

[sqlalchemy] Re: Lazy ID Fetching/generation

2007-12-09 Thread Michael Bayer
On Dec 9, 2007, at 4:57 PM, Adam Batkin wrote: Ahh, but session.save() was already called, so trying to fetch a database-generated attribute (such as the primary key in my case) should trigger a flush of the row itself. That can be done with any database. It wouldn't be done on __init__,

[sqlalchemy] Re: From arbitrary SELECT to Query

2007-12-09 Thread Michael Bayer
On Dec 9, 2007, at 2:31 PM, Artur Siekielski wrote: I'm writing DAO module for db access which must be independent of rest of the system. I'm looking for a class which can be used as a proxy for SQL results. Query would be good, if it would be possible to have fully functional Query

[sqlalchemy] Re: Lazy ID Fetching/generation

2007-12-09 Thread Adam Batkin
I hate to disagree here, and I can see what you're getting at, but honestly, the INSERT on save() approach is exactly the naive active- record-like pattern that SQLAlchemy's ORM was designed to get away from. The way the unit of work functions, we dont generate ids until a flush

[sqlalchemy] Re: Matching a DateTime-field

2007-12-09 Thread Rick Morrison
Any query using sql expressions is going to want to use correctly typed data -- you're trying to query a date column with a string value. The LIKE operator is for string data. I'm not up on my mssql date expressions, but the answer is going to resemble something like this:

[sqlalchemy] Re: save_or_update and composit Primary Keys... MSSQL / pyodbc issue ?

2007-12-09 Thread Michael Bayer
I cant reproduce your problem, although i dont have access to MSSQL here and there may be some issue on that end. Attached is your script using an in-memory sqlite database, with the update inside of a while loop, and it updates regularly.A few things to try on the MSSQL side, if the

[sqlalchemy] Possible to build a query object from a relation property?

2007-12-09 Thread Allen Bierbaum
I am using SA 0.3.11 and I would like to know if there is a way to get a query object from a relation property. I have several one-to-many relationships in my application. These are all setup and work very well, but I find that I often want to perform further filtering of the objects in the

[sqlalchemy] Re: Possible to build a query object from a relation property?

2007-12-09 Thread Michael Bayer
On Dec 9, 2007, at 10:55 PM, Allen Bierbaum wrote: I am using SA 0.3.11 and I would like to know if there is a way to get a query object from a relation property. I have several one-to-many relationships in my application. These are all setup and work very well, but I find that I often