hi all,
i don't know if any of you got into this, but running sqlalchemy against
mssql produces an akward error for me:
<exception>
sqlalchemy.exc.ProgrammingError: (ProgrammingError) ('42000', "[42000]
[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the
keyword 'EXISTS'. (156) (SQLExecDirectW); [42000] [Microsoft][ODBC SQL
Server Driver][SQL Server]Incorrect syntax near the keyword 'AS'. (156);
[42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could
not be prepared. (8180)") u'SELECT EXISTS (SELECT 1 \nFROM fields_assoc
\nWHERE fields.field_id = fields_assoc.field_group) AS _part_of_array,
fields.field_id AS fields_field_id, fields.struct_id AS fields_struct_id,
fields.[key] AS fields_key, fields.item_type AS fields_item_type \nFROM
fields \nWHERE fields.struct_id = ? AND fields.item_type != ?' (1, 9)
</exception>
running that query inside sql server management studio, it produces the same
error:
<query>
SELECT EXISTS (SELECT 1
FROM fields_assoc
WHERE fields.field_id = fields_assoc.field_group) AS _part_of_array,
fields.field_id AS fields_field_id, fields.struct_id AS fields_struct_id,
fields.[key] AS fields_key, fields.item_type AS fields_item_type
FROM fields
WHERE fields.struct_id = 1 AND fields.item_type != 9
</query>
<error>
Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'EXISTS'.
Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'AS'.
</error>
but if a change the query slightly to:
<query>
SELECT (SELECT 1
FROM fields_assoc
WHERE fields.field_id = fields_assoc.field_group) AS _part_of_array,
fields.field_id AS fields_field_id, fields.struct_id AS fields_struct_id,
fields.[key] AS fields_key, fields.item_type AS fields_item_type
FROM fields
WHERE fields.struct_id = 1 AND fields.item_type != 9
</query>
it works (of course, without the EXISTS clause). the exists clause in mssql
is found usualy in where clauses. my code works fine under other dbms (such
as postgresql / mysql / sqlite).
the code that generates exists is a property mapping:
<code>
self.map_fields = mapper(
MainFields,
T.tbl_fields,
properties = {
[...],
'_part_of_array': column_property(
exists([1], T.tbl_fields.c.field_id==\
T.tbl_fields_assoc.c.field_group
).correlate(T.tbl_fields).label('_part_of_array')
)
}
)
</code>
using: windows 7 x64; sql server 2008; python 2.7 x64; sqlalchemy 0.6.3;
pyodbc adapter;
any ideas?
thanks in advance,
richard.
--
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.