[sqlalchemy] Re: relationship trouble

2011-10-27 Thread Jakob L.
I found the problem. I executed a query where I check against the parents 
name instad of the parent. Silly mistake, sorry for wasting your time. 
Since I write the query in a different place I didn't know it was actually 
the framework that executed it. 

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/taMVwznSt8MJ.
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] relationship trouble

2011-10-26 Thread Jakob L.
Hi!

I added a new self-referential relationship to one of my tables but since I 
couldn't find how to create the new column through SA I added it to the db 
manually after checking how it's been done before. 

The code looks like this (using elixir):
class User(Entity):
username = Field(String(80),  primary_key=True)

# New fields
parent = ManyToOne('User')
children = OneToMany('User')

So I added a field in the db with the name parent_name since I noticed 
thats how SA names foreign keys and I also indexed it with the name 
ix_user_parent_name

Do I need to do anything else to get this to work or have I done anything 
wrong? 

What I get is:  'str' object has no attribute '_state'  for that object 
in _get_committed_attr_by_column. 

I read that this means that I add a string to a relationship object, but I 
could access the parents fields when testing. 





-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/RJ-iAdcQWDoJ.
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: relationship trouble

2011-10-26 Thread Jakob L.
Sorry, I named the new field parent_username and the index 
 ix_user_parent_username

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/pPpCbKKCWnAJ.
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] max() with SQLAlchemy 0.4.7

2011-10-11 Thread Jakob L.
Sorry if this has already been posted but couldn't find any docs for 0.4 nor 
any examples where columns aren't used in the query. 

As I understand, you can't use columns in queries in 0.4. 

So how should I write: 
session.query(Media.id, func.max(Media.sort_order)).first()


-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/Tlll3oOFkDgJ.
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.



Re: [sqlalchemy] max() with SQLAlchemy 0.4.7

2011-10-11 Thread Jakob L.
select([func.max(Media.c.sort_order)])   works great! 

Thanx!

//J

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/CtRlzNOa1DUJ.
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.