Hello All,

I'd like to create a Table, (to use with the mapper()) that will
always include a check to filter returned results.

e.g. I have a table Foo with a status field in it. I never want to
return rows where status = DELETED aka 2.
This code:
query(Foo).get(1)
should produce:
SELECT * FROM foo WHERE id=1 AND status != 2

I've searched for this and I've found a couple different ways to do
it, but none that were optimal. The closest solution is to:

mapper(Foo, select([foo_table], foo_table.c.status != 2))

but that creates SQL:
SELECT * FROM (SELECT * FROM foo WHERE status != 2) tmp WHERE tmp.id =
1

which works but is not optimal for large collections.

Hopefully I'm not re-asking a similar question.

Thanks!

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