Grimsqueaker wrote:
> It looks as though SQLAlchemy doesn't use the startswith() operator
> properly in Oracle (using SA 0.6).
>
> " col1.startswth(col2) " gives me " col1 LIKE col2 + '%%' " which
> should be " col1 LIKE col2 || '%%' ".
>
> Am I doing something wrong or should this be reported?

that looks more like col1 or col2 is not of a string type, so it doesn't
know to use the concatenation operator and not the addition operator.

Here's a demo:

from sqlalchemy import *
from sqlalchemy.sql import column
from sqlalchemy.dialects import oracle

dialect = oracle.dialect()

print (column('col1',
String).startswith("somevalue")).compile(dialect=dialect)
print (column('col1', String).startswith(5)).compile(dialect=dialect)
print (column('col1', String).startswith(column('col2',
String))).compile(dialect=dialect)
print (column('col1', Integer).startswith(column('col2',
Integer))).compile(dialect=dialect)
print (column('col1', String).startswith(column('col2',
Integer))).compile(dialect=dialect)


col1 LIKE :col1_1 || '%%'
col1 LIKE :col1_1 + '%%'
col1 LIKE col2 || '%%'
col1 LIKE col2 + '%%'
col1 LIKE col2 + '%%'

-- 
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