[sqlalchemy] Re: Determine what joins are in select statement

2009-11-01 Thread Steve Zatz
Still not there because I am not sure how to compare two join objects.

For example let's say I have a join object:

obj1
sqlalchemy.orm.util._ORMJoin at 0xac0d30c; Join object on task(172432076)
and context(172432940)

And I then create a second object:
 obj2 = sqlalchemy.orm.util.join(Task, Context)
obj2
sqlalchemy.orm.util._ORMJoin at 0xae517ac; Join object on task(172432076)
and context(172432940)

I can't quite figure out how to compare the objects since:

obj1.compare(obj2) is False

What is the best way to compare those two join objects and conclude they
represent the same join?

Steve

--~--~-~--~~~---~--~~
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, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Determine what joins are in select statement

2009-11-01 Thread Michael Bayer


On Nov 1, 2009, at 6:27 PM, Steve Zatz wrote:

 Still not there because I am not sure how to compare two join objects.

 For example let's say I have a join object:

 obj1
 sqlalchemy.orm.util._ORMJoin at 0xac0d30c; Join object on task 
 (172432076) and context(172432940)

 And I then create a second object:
  obj2 = sqlalchemy.orm.util.join(Task, Context)
 obj2
 sqlalchemy.orm.util._ORMJoin at 0xae517ac; Join object on task 
 (172432076) and context(172432940)

 I can't quite figure out how to compare the objects since:

 obj1.compare(obj2) is False

 What is the best way to compare those two join objects and conclude  
 they represent the same join?

join() isn't providing a depth-based version of compare() at the  
moment so compare join.left, join.right, join.onclause.







--~--~-~--~~~---~--~~
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, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Determine what joins are in select statement

2009-10-28 Thread Steve Zatz
And what is the approach to the simpler question of determining what joins
are in a query.

For example,

query = session.query(Task).join(Context)...

If you're just passed the query, what's the best way to determine that it
contains a join (for example, so you don't perform the same join again)?

Steve

--~--~-~--~~~---~--~~
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, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Determine what joins are in select statement

2009-10-28 Thread Michael Bayer

Steve Zatz wrote:
 And what is the approach to the simpler question of determining what joins
 are in a query.

 For example,

 query = session.query(Task).join(Context)...

 If you're just passed the query, what's the best way to determine that it
 contains a join (for example, so you don't perform the same join again)?

well I showed the visitor example towards the goal of illustrating a
generalized solution to finding things.  just change table to join.

myjoins = set()
visitors.traverse(mystmt, {'join':myjoins.add})



 Steve

 



--~--~-~--~~~---~--~~
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, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Determine what joins are in select statement

2009-10-28 Thread Steve Zatz
  just change table to join.
I tried that but got an Attribute Error that Query' object has no attribute
'__visit_name__'

Asume I am doing something wrong by using the query object as the first
argument but not sure what to use.

Also, what is the second argument in visitors.traverse().  [It was missing
in the most recent example but apparently an empty dictionary is fine.]

Steve




--~--~-~--~~~---~--~~
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, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Determine what joins are in select statement

2009-10-28 Thread Michael Bayer

Steve Zatz wrote:
  just change table to join.
 I tried that but got an Attribute Error that Query' object has no
 attribute
 '__visit_name__'

 Asume I am doing something wrong by using the query object as the first
 argument but not sure what to use.

use query.statement to get at the SQL expression


 Also, what is the second argument in visitors.traverse().  [It was missing
 in the most recent example but apparently an empty dictionary is fine.]

just an empty dict.  it's contents have meaning in some cases but is not
generally necessary.  it would be preferable if the API didn't stick that
boilerplate right in the middle of the function like that but that's sort
of how it is for now.



 Steve




 



--~--~-~--~~~---~--~~
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, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Determine what joins are in select statement

2009-10-28 Thread Steve Zatz
 use query.statement to get at the SQL expression
Thanks. That worked.

--~--~-~--~~~---~--~~
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, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---