Michael Bayer wrote:
> first thing, "wlt" is a view?  thats very surprising that "autoload"
> would work with that...but then im not so famliar with the specifics
It's working :) Views are transparent to the DB engine and should be
visible as tables.

> of postgres views.
Views are one of most important thing in DB programming.
I'm surprised that this topic isn't tested in SA :(

> mapped table, you can use the "primary_key" argument to mapper()
I've tried to do this but some errors occur on session.query
(wlt.select pass):
Wlt.mapper = mapper(Wlt, wlt, primary_key=wlt.c.id)
items = wlt.select(w, order_by=order, limit=5).execute() # OK, 5 items
items = session.query(Wlt).select(w, order_by=order, limit=5)
-> TypeError: iteration over non-sequence
-> in
-> File "build\bdist.win32\egg\sqlalchemy\orm\mapper.py", line 398, in
_compile_tables

I suppose that the problem is in limit statement but without success,
the second
query returns only 10 records instead of about 30 records:
session.query(Wlt).select(w) # Fail

> itself and force the columns that should be used for the pk.
There is a primary key defined - Column('id', String(),
primary_key=True)
It isn't enough ?

It's another strange behavior:
With "metadata.engine.echo = True" I have different queries for the
same situation:
"wlt.select" creates following SQL:
SELECT wlt.id, /*blabla*/ FROM wlt ORDER BY wlt.pat_name ASC LIMIT 5
but "session.query(Wlt).select" creates:
SELECT wlt.id AS wlt_id, /*blabla*/ FROM wlt ORDER BY wlt.pat_name ASC
LIMIT 5
In the second example, there are no primary key (id) defined but
according to definition:
wlt = Table('wlt', metadata, Column('id', String(), primary_key=True),
autoload=True)
there should be a primary key (id).

When I change definition to:
wlt = Table('wlt', metadata, Column('wlt_id', String(),
primary_key=True), autoload=True)
an error occurs:
(ProgrammingError) column wlt.wlt_id does not exist

If you want I can sent to you full DB structure to test :)

Cheers,
Artur


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sqlalchemy
-~----------~----~----~----~------~----~------~--~---

Reply via email to