Hi
I've been using SQLAlchemy for some queries based on the SQL views
(Postgres).
The problem is in results returned from session.query.
Depending on the method (session or not) for a table with a lot of
items results are not the same:
metadata = BoundMetaData('postgres://blabla')
wlt = Table('wlt', metadata, Column('id', String(), primary_key =
True), autoload=True)
class Wlt(object): pass
Wlt.mapper = mapper(Wlt, wlt)
order = [asc(wlt.c.somecolumn)]
items = wlt.select(w, order_by=order, limit=5).execute()
print 'Old method: %d' % len(list(items)) # 5 items
session = create_session()
items = session.query(Wlt).select(w, order_by=order, limit=5)
session.flush()
print 'New method: %d' % len(list(items)) # 2 items !
I supose that problem can be in primary key definition. SQL view does't
have a primary key, the primary key is taken from 'FROM' table key.
SQL statements created by the engine are different:
SELECT wlt.id, /**/ FROM wlt ORDER BY wlt.somecolumn ASC LIMIT 5 in the
first case
and SELECT wlt.id AS wlt_id, /**/ FROM wlt ORDER BY wlt.somecolumn ASC
LIMIT 5 in the second
Any ideas ?
Cheers,
Artur
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---