On Nov 5, 2010, at 2:51 AM, Lenza McElrath wrote:

> Well, turns out that it doesn't take much of a pool at all to get the test to 
> fail: http://pastebin.com/trHhiG47

sorry, again this works fine, and theres still nothing in the test as given 
that can cause StaleDataError.

output when I add echo=True:

010-11-05 03:24:49,463 INFO sqlalchemy.engine.base.Engine.0x...e610 SELECT 
DATABASE()
2010-11-05 03:24:49,463 INFO sqlalchemy.engine.base.Engine.0x...e610 ()
2010-11-05 03:24:49,465 INFO sqlalchemy.engine.base.Engine.0x...e610 SHOW 
VARIABLES LIKE 'character_set%%'
2010-11-05 03:24:49,465 INFO sqlalchemy.engine.base.Engine.0x...e610 ()
2010-11-05 03:24:49,465 INFO sqlalchemy.engine.base.Engine.0x...e610 SHOW 
VARIABLES LIKE 'lower_case_table_names'
2010-11-05 03:24:49,466 INFO sqlalchemy.engine.base.Engine.0x...e610 ()
2010-11-05 03:24:49,466 INFO sqlalchemy.engine.base.Engine.0x...e610 SHOW 
COLLATION
2010-11-05 03:24:49,466 INFO sqlalchemy.engine.base.Engine.0x...e610 ()
2010-11-05 03:24:49,469 INFO sqlalchemy.engine.base.Engine.0x...e610 SHOW 
VARIABLES LIKE 'sql_mode'
2010-11-05 03:24:49,469 INFO sqlalchemy.engine.base.Engine.0x...e610 ()
2010-11-05 03:24:49,470 INFO sqlalchemy.engine.base.Engine.0x...e610 
CREATE TABLE sqlalchemy_test_my_model (
        id INTEGER NOT NULL AUTO_INCREMENT, 
        float_value FLOAT, 
        PRIMARY KEY (id)
)ENGINE=InnoDB


2010-11-05 03:24:49,470 INFO sqlalchemy.engine.base.Engine.0x...e610 ()
2010-11-05 03:24:49,473 INFO sqlalchemy.engine.base.Engine.0x...e610 COMMIT
2010-11-05 03:24:49,474 INFO sqlalchemy.engine.base.Engine.0x...e610 BEGIN 
(implicit)
2010-11-05 03:24:49,475 INFO sqlalchemy.engine.base.Engine.0x...e610 INSERT 
INTO sqlalchemy_test_my_model (float_value) VALUES (%s)
2010-11-05 03:24:49,475 INFO sqlalchemy.engine.base.Engine.0x...e610 
(0.4444444444444444,)
2010-11-05 03:24:49,476 INFO sqlalchemy.engine.base.Engine.0x...e610 COMMIT
2010-11-05 03:24:49,477 INFO sqlalchemy.engine.base.Engine.0x...e610 BEGIN 
(implicit)
2010-11-05 03:24:49,477 INFO sqlalchemy.engine.base.Engine.0x...e610 SELECT 
sqlalchemy_test_my_model.id AS sqlalchemy_test_my_model_id, 
sqlalchemy_test_my_model.float_value AS sqlalchemy_test_my_model_float_value 
FROM sqlalchemy_test_my_model 
WHERE sqlalchemy_test_my_model.id = %s
2010-11-05 03:24:49,477 INFO sqlalchemy.engine.base.Engine.0x...e610 (1L,)
2010-11-05 03:24:49,479 INFO sqlalchemy.engine.base.Engine.0x...e610 UPDATE 
sqlalchemy_test_my_model SET float_value=%s WHERE sqlalchemy_test_my_model.id = 
%s
2010-11-05 03:24:49,479 INFO sqlalchemy.engine.base.Engine.0x...e610 
(0.4444444444444444, 1L)
2010-11-05 03:24:49,479 INFO sqlalchemy.engine.base.Engine.0x...e610 COMMIT
2010-11-05 03:24:49,480 INFO sqlalchemy.engine.base.Engine.0x...e610 
DROP TABLE sqlalchemy_test_my_model
2010-11-05 03:24:49,480 INFO sqlalchemy.engine.base.Engine.0x...e610 ()
2010-11-05 03:24:49,482 INFO sqlalchemy.engine.base.Engine.0x...e610 COMMIT




> 
> On Thu, Nov 4, 2010 at 10:33 PM, Lenza McElrath <[email protected]> wrote:
> Interesting.  When I use your simple engine I do not get the error either, 
> but I definitely get it when using my real configuration.  We are using a 
> connection pool.  So the construction of the session maker for the test looks 
> like this:
> 
> e = sqlalchemy.create_engine('mysql://', pool=connections.get_pool())
> sessionmaker = sqlalchemy.orm.sessionmaker(e)
> 
> The connection pool is somewhat complex, so I will try to find the simplest 
> possible pool that reproduces the problem.  But, do you have ideas based on 
> this?  The script only fails when I use a Float type with a test_value that 
> 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 <[email protected]> 
> wrote:
> 
> On Nov 4, 2010, at 8:17 PM, Lenza McElrath wrote:
> 
>> 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
> 
> the test fails to note what "sessionmaker" is, if I run it like this:
> 
>     e = create_engine('mysql://scott:ti...@localhost/test')
>     test_class = UpdateFunctionTest(sessionmaker(e))
> 
> the script runs as expected with no errors.   StaleDataError only occurs if 
> you execute() an update() or delete() construct that affects the primary key 
> or version number of a row in the same transaction as one that also calls 
> flush() and also targets that row.  This test doesn't emit any raw SQL 
> constructs nor does it modify any primary key attributes or use version ids 
> so no error occurs.   Float columns that aren't primary keys have nothing to 
> do with StaleDataError.
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/sqlalchemy?hl=en.
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/sqlalchemy?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to