Re: [sqlalchemy] Deadlock in iterating over a session

2011-03-06 Thread Lenza McElrath
On Sun, Mar 6, 2011 at 5:21 PM, Michael Bayer wrote: > > On Mar 6, 2011, at 8:16 PM, Lenza McElrath wrote: > > Ok cool. I actually could write my code to produce exactly that effect > fairly quickly since I was already accessing the mutable object through a > comparable_pro

Re: [sqlalchemy] Deadlock in iterating over a session

2011-03-06 Thread Lenza McElrath
explaining that attribute values are loaded individually once they are expired? Could the resurrecting of state not be happening properly when only loading a single attribute? On Fri, Mar 4, 2011 at 2:16 PM, Michael Bayer wrote: > > On Mar 4, 2011, at 5:09 PM, Lenza McElrath wrote: > > &g

Re: [sqlalchemy] Deadlock in iterating over a session

2011-03-04 Thread Lenza McElrath
Thanks for the quick response to this as usual. See me responses below. On Fri, Mar 4, 2011 at 7:32 AM, Michael Bayer wrote: > > On Mar 4, 2011, at 2:58 AM, Lenza McElrath wrote: > > Hello! I'm iterating over a session to look at all the objects: > > for obj in session

[sqlalchemy] Deadlock in iterating over a session

2011-03-03 Thread Lenza McElrath
Hello! I'm iterating over a session to look at all the objects: for obj in session: do_something_cool(obj) Yesterday this caused what looks like a deadlock in SQLAlchemy code. Here is the stack I grabbed using gdb: 1. /python2.5/sqlalchemy/orm/session.py:1353 (Session.__iter__) 2. /pyt

Re: [sqlalchemy] Can you declaratively concatenate two columns

2011-01-24 Thread Lenza McElrath
Hey Royce, This sounds like a job for composite columns: http://www.sqlalchemy.org/docs/orm/mapper_config.html#composite-column-types One gotcha that I ran into here is that you cannot have both the component columns and the composite column mapped at the same time, like you do in your example.

[sqlalchemy] Specifying a type for primary key results in strange behaviors

2010-12-18 Thread Lenza McElrath
I am writing a system where I want my DB primary keys to be represented in the system by a type other than an integer. I have run into several issues with this: 1) I tried using a TypeDecorator, but SQLAlchemy does not like this. Seems like the main problem is the auto_increment is not set on th

[sqlalchemy] Row insert does not update relations in identity map

2010-12-02 Thread Lenza McElrath
I ran into an issue where a query was returning a object where the relations were stale. It turned out that this is because inserting a row does not update relations in identity map. The basic issue looks like this: my_model = MyModel() session.add(my_model) session.flush

Re: [sqlalchemy] Avoiding StaleDataError when updating Float values

2010-11-05 Thread Lenza McElrath
such - see if cursor.rowcount > is zero when it should be one. If I think of something else I'll let you > know. > > On Nov 5, 2010, at 9:41 AM, Lenza McElrath wrote: > > Here is my output. Note that my updates are for "0.2" not > "0.44

Re: [sqlalchemy] Avoiding StaleDataError when updating Float values

2010-11-05 Thread Lenza McElrath
y/orm/unitofwork.py", line 448, in execute uow File "/var/lib/python-support/python2.5/sqlalchemy/orm/mapper.py", line 1852, in _save_obj (table.description, len(update), rows)) sqlalchemy.orm.exc.StaleDataError: UPDATE statement on table 'sqlalchemy_test_my_model' exp

Re: [sqlalchemy] Avoiding StaleDataError when updating Float values

2010-11-04 Thread Lenza McElrath
Well, turns out that it doesn't take much of a pool at all to get the test to fail: http://pastebin.com/trHhiG47 On Thu, Nov 4, 2010 at 10:33 PM, Lenza McElrath wrote: > Interesting. When I use your simple engine I do not get the error either, > but I definitely get it when us

Re: [sqlalchemy] Avoiding StaleDataError when updating Float values

2010-11-04 Thread Lenza McElrath
is higher percision than the DB can represent. It works when I use an Integer type, or when test_value is 44 or 0.44. Thanks for your help! On Thu, Nov 4, 2010 at 6:18 PM, Michael Bayer wrote: > > On Nov 4, 2010, at 8:17 PM, Lenza McElrath wrote: > > I am getting a StaleDataError when u

[sqlalchemy] Avoiding StaleDataError when updating Float values

2010-11-04 Thread Lenza McElrath
I am getting a StaleDataError when updating a Float column to the same value twice in a row. This happens because SQLAlchemy thinks that I am changing the value, but then the DB reports that no value was changed. Test case can be seen here: http://pastebin.com/vxFBAMxm Is there an easy way aroun

Re: [sqlalchemy] Re: SQLAlchemy not updating all expected columns after mutable attribute modification

2010-10-26 Thread Lenza McElrath
passes. -Lenza On Mon, Oct 25, 2010 at 10:33 AM, Michael Bayer wrote: > > On Oct 25, 2010, at 1:07 PM, Lenza McElrath wrote: > > I am running into a issue where it looks like SQLAlchemy is not performing > the proper DB update when committing a session after modifying an object.

[sqlalchemy] Re: SQLAlchemy not updating all expected columns after mutable attribute modification

2010-10-25 Thread Lenza McElrath
I am running into a issue where it looks like SQLAlchemy is not performing the proper DB update when committing a session after modifying an object. This happens only when all references to the updated object are lost, and I update a mutable attribute BEFORE updating another attribute. It seems as