I'm using Postgres 8.3 and sqlalchemy 0.5.0rc2 - when I'm doing a
select, it seems I can't concatenate a function with another column -
rather that use the || operator, it tries to use the || operator.
Code to reproduce example:
import sqlalchemy as sa
from sqlalchemy import *
from sqlalchemy.sql import *
meta = MetaData()
def get_pg_statement(s):
return s.compile(bind=create_engine('postgres://'))
pt = Table('people', meta,
Column('id', Integer, primary_key=True),
Column('first_name', String(100)),
Column('last_name', String(100))
)
statements = (
select([func.lower(pt.c.first_name)]),
select([pt.c.first_name + pt.c.last_name]),
select([func.lower(pt.c.first_name) + pt.c.first_name +
pt.c.last_name]),
)
print sa.__version__
for s in statements:
print get_pg_statement(s)
--------------------------------------------------------------------------------
Output of sample (line breaks removed):
0.5.0rc2
SELECT lower(people.first_name) AS lower_1 FROM people
SELECT people.first_name || people.last_name AS anon_1 FROM people
SELECT (lower(people.first_name) + people.first_name) ||
people.last_name AS anon_1 FROM people
Note on the third select, the + operator is used rather than ||.
The following error is thrown from PostGres:
ERROR: operator does not exist: text + character varying
LINE 1: SELECT (lower(people.first_name) + people.first_name) ||
peo...
^
HINT: No operator matches the given name and argument type(s). You
might need to add explicit type casts.
When running "SELECT (lower(people.first_name) || people.first_name)
|| people.last_name AS anon_1 FROM people" the querey executes
properly.
Is there a workaround for this?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---