Using literal_column does not give any error, but the condition
actually does not work and produces wrong results for me. For example,
in the below program I inserted a record with value of date column 'd'
as '20110210'. And a view with a condition d > '20110310' still
outputs this record.

Let me know if I am missing something.


Program:
===================================================================
from sqlalchemy import *
from sqlalchemy.sql import *
from dateutil import parser

    conn = create_engine("sqlite:////u/my.db").connect()

    t = Table("x", MetaData(conn), Column("z", String), Column("d",
Date))
    t.create(checkfirst=True)
    ins = t.insert().values(z='a', d=parser.parse('20110210'))
    conn.execute(ins)
    s = select([t])
    print s
    result = conn.execute(s)
    for row in result:
        print row

    s = select([t], t.c.d > literal_column("'20110310'"))
    print s
    conn.execute("CREATE TEMP VIEW myview AS %s" % s.compile(conn));

    v = Table("myview", MetaData(conn), autoload=True)

    result_view = conn.execute(select([v]))
    for row in result_view:
        print row
===============================================================
Output:
=====

SELECT x.z, x.d
FROM x
(u'a', datetime.date(2011, 2, 10))

SELECT x.z, x.d
FROM x
WHERE x.d > '20110310'
(u'a', datetime.date(2011, 2, 10))

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
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.

Reply via email to