I use my assign_mapper'd classes with a lot of joy so far. But now I
feel trapped. My table:

records_table = Table(
    'records', meta,
    Column('id', Integer, primary_key=True),
    Column('name', Unicode(80)),
    Column('type', Unicode(10)),
    Column('content', Unicode(200)),
    Column('ttl', Integer),
    Column('prio', Integer))

My mapping:

    class DnsRecord(object): pass
    assign_mapper(session_context, DnsRecord, records_table)

Now I'd like to select all objects from that table with unique values in
the "name" column. In old-school SQL that would be:

    SELECT DISTINCT name,* FROM records;

When I start with...

    DnsRecord.select(...)

...I can just change the WHERE clause but not the actually selected
data. Do I really have to use

    select([DnsRecord.c.name], distinct=True)

? It's simple and working. But I'd rather like to get the result as a
mapped class so that I can work with other columns, too. This way I just
received a list of strings when I .execute() it.

On #sqlalchemy I was proposed to:
- use a subselect with .filter()
- map a select instead of a Table()
- use result-set mapping

But these solutions sounded like dirty workarounds and I couldn't even
figure out the proper syntax to try it.

I have seen similar requests on the list that went unanswered. Is it an
obviously lacking feature in SA or is my idea just plain stupid? What is
the one truly right way (tm) to handle this?

Thanks,
 Christoph


--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to