Here is a test case that fails with 0.1.6 as well as trunk (http://
svn.sqlalchemy.org/sqlalchemy/trunk, not the .2 branch):
import mx.DateTime as mxDateTime
from sqlalchemy import *
e = create_engine("postgres://database=test", echo=True)
test = Table("test", e,
Column("id", String, primary_key=True),
Column("date", DateTime, primary_key=True),
Column("something", String),
)
class Test(object):
pass
Test.mapper = mapper(Test, test)
try:
test.drop()
except:
pass
test.create()
date = mxDateTime.now()
t = Test()
t.id = '1'
t.date = date
t.something = 'hello'
objectstore.flush()
del t
t = Test.mapper.get_by(id='1', date=date)
t.something = 'hi'
objectstore.flush() # fails
The last line fails. The last line of the traceback is as follows:
[2006-05-04 11:13:50,428] [engine]: UPDATE test SET something=%
(something)s WHERE test.id = %(test_id)s AND test.date = %(test_date)s
[2006-05-04 11:13:50,429] [engine]: [{'test_id': '1', 'something':
'hi', 'test_date': datetime.datetime(2006, 5, 4, 11, 13, 50)}]
Traceback (most recent call last):
..........
sqlalchemy.exceptions.SQLError: (ProgrammingError) ERROR: syntax
error at or near "11" at character 79
UPDATE test SET something='hi' WHERE test.id = '1' AND test.date =
2006-05-04 11:13:50 'UPDATE test SET something=%(something)s WHERE
test.id = %(test_id)s AND test.date = %(test_date)s' {'test_id': '1',
'something': 'hi', 'test_date': datetime.datetime(2006, 5, 4, 11, 13,
50)}
So it is treating the date incorrectly, without quotes. Notice that
in the get_by call, before the update, there is a different WHERE
clause:
[2006-05-04 11:13:50,422] [engine]: SELECT test.date AS test_date,
test.id AS test_id, test.something AS test_something
FROM test
WHERE test.date = %(test_date)s AND test.id = %(test_id)s
LIMIT 1
[2006-05-04 11:13:50,423] [engine]: {'test_id': '1', 'test_date':
<datetime object at 0xb7e1c140>}
The datetime parameter differs in the two calls. I couldn't find
anything in the list archives or docs about this.
--
Dimi Shahbaz, Software Engineer Specialist
California PASS Program
www.cyberhigh.fcoe.k12.ca.us
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users