[sqlalchemy] SqlAlchemy 0.7.4 Make a hybrid_property a declared_attr

2011-12-11 Thread Hector Blanco
Hello everyone! I'm trying to migrate from SqlAlchemy 0.6.8 to 0.7.4. I have a class that is the base for all the bases in my system. In that class is where I define the id (numeric primary key) for the rest of my classes. That class is not mapped to any table. I want to have getter/setter for

[sqlalchemy] Re: Set expire_on_commit to False to improve commit performance

2011-12-11 Thread Amir Sasson
After setting expire_on_commit to False, I hit inconsistency after commits in DB relations. For example, I've two tables Host and HostPort, where Host have a relation to Ports: class HostPort(Base): __tablename__ = 'hostport' db_id = Column('id', Integer, primary_key=True) # the port's id

Re: [sqlalchemy] MySQL significant order in set list of update command

2011-12-11 Thread bogun . dmitriy
2011/12/11 Michael Bayer mike...@zzzcomputing.com My impression was Postgresql handles this much more nicely which is confirmed by this post: http://beerpla.net/2009/02/17/swapping-column-values-in-mysql/ the usual way this kind of thing is done is via declaring local variables in the SQL

Re: [sqlalchemy] SqlAlchemy 0.7.4 Make a hybrid_property a declared_attr

2011-12-11 Thread Michael Bayer
On Dec 11, 2011, at 5:56 AM, Hector Blanco wrote: but if then i try to use the id in filters (such as Product.manufacturer.any(id=parameterId), where Product is a really mapped class, with a relationship towards Manufacturer, another really mapped class, ) I get a key error id, so it looks

Re: [sqlalchemy] Re: Set expire_on_commit to False to improve commit performance

2011-12-11 Thread Michael Bayer
On Dec 11, 2011, at 8:35 AM, Amir Sasson wrote: After setting expire_on_commit to False, I hit inconsistency after commits in DB relations. For example, I've two tables Host and HostPort, where Host have a relation to Ports: class HostPort(Base): __tablename__ = 'hostport' db_id =

[sqlalchemy] empty query

2011-12-11 Thread lestat
/sqlalchemy/sql/expression.py:1869: SAWarning: The IN-predicate on comment.reply_id was invoked with an empty sequence. This results in a contradiction, which nonetheless can be expensive to evaluate. Consider alternative strategies for improved performance. return self._in_impl(operators.in_op,

Re: [sqlalchemy] empty query

2011-12-11 Thread Michael Bayer
On Dec 11, 2011, at 11:55 AM, lestat wrote: /sqlalchemy/sql/expression.py:1869: SAWarning: The IN-predicate on comment.reply_id was invoked with an empty sequence. This results in a contradiction, which nonetheless can be expensive to evaluate. Consider alternative strategies for improved

Re: [sqlalchemy] empty query

2011-12-11 Thread Michael Bayer
On Dec 11, 2011, at 1:06 PM, Michael Bayer wrote: In the above case, you'd just say comments_replies = []. correction, as you're attempting to return a Query; you'd factor the calling code to expect that an empty list of user_ids as input should result in an empty result that can't be

Re: [sqlalchemy] empty query

2011-12-11 Thread Alex K
I need EmptyQuery because query that returns from my function used for different cases, and if I return [], it will raise error, because [] not has query methods like order_by. e.g. query1 = getComments(user_id).order_by('comment.time_create desc') query2 = getComments(user_id).order_by('id')

Re: [sqlalchemy] SqlAlchemy 0.7.4 Make a hybrid_property a declared_attr

2011-12-11 Thread Hector Blanco
The workaround is very simple, just say A.id==5 instead of id=5. The bug itself is fixed in r99564ce1414c. Ah, yeah! That works! I find using the double == for comparison clearer (just a personal opinion) -- You received this message because you are subscribed to the Google Groups

Re: [sqlalchemy] SqlAclhemy 0.6.8 Delete orphan with objects that contain new objects (momentarily orphan)?

2011-12-11 Thread Hector Blanco
Oh, it wasn't exactly an error with the Synonyms itself. They are working fine for what I've been doing with them (just using them for getters/setters... nothing fancy) It was more that when I migrated the Synonyms I have in the 0.6.8 to hybrid_properties in 0.7.4, I was getting trouble (which I'm

[sqlalchemy] SqlAlchemy 0.7.4 Hibrid-properties not showing in NamedTuples when values are queried (they are resolved)

2011-12-11 Thread Hector Blanco
Hello everyone! I am continuing with the migration from SqlAlchemy 0.6.8 to 0.7.4, and I've seen a little difference in behavior. I have a class Product (more or less) like: class Product(declarativeBase): _id = Column(id, Integer, primary_key=True) _model = Column(model,

Re: [sqlalchemy] SqlAlchemy 0.7.4 Hibrid-properties not showing in NamedTuples when values are queried (they are resolved)

2011-12-11 Thread Michael Bayer
On Dec 11, 2011, at 3:54 PM, Hector Blanco wrote: Hello everyone! I am continuing with the migration from SqlAlchemy 0.6.8 to 0.7.4, and I've seen a little difference in behavior. I have a class Product (more or less) like: class Product(declarativeBase): _id = Column(id,

[sqlalchemy] quasi-run time ForeignKey definition

2011-12-11 Thread Viktor Nagy
hi, I would like to build a reusabe forum application. For the sake of simplicity we need two tables Owner and Thread. There is a ForeignKey from Thread to Owner. As reusability goes, the Owner table is given in a configuration argument, thus it's unknown when the code is written. Using pyramid,

Re: [sqlalchemy] Querying number column as if it is a unicode column

2011-12-11 Thread Martijn Moeling
Kinda lame I could not find that I should have known Thanks! On Dec 9, 2011, at 16:01 , Michael Bayer wrote: On Dec 9, 2011, at 5:28 AM, Martijn Moeling wrote: Hi, I'm puzzled on how to get this working: class User(base): Id = Column (Integer,