-----Original Message-----
From: [email protected] <[email protected]>
To: sqlalchemy <[email protected]>
Sent: Mon Feb 04 16:09:49 2008
Subject: [sqlalchemy] Oracle, limit, and polymorphism
Hey all,
I'm rather new to sqlalchemy, I've been playing with it for about a
week. I'm using version 4.2p3 on python 2.4
Anyways, I've run into a problem when I use oracle with joined
inheritance with a limit clause, specifically, it can't seem to find
the polymorphic_on column.
If I switch the database to sqlite, it works fine.
Here's the psuedo-code description:
tickets = Table('hpd_helpdesk', metadata,
Column('case_id_', String(100), primary_key=True),
Column('requester_login_name_', String(100)),
Column('ticket_type', String(100))
schema="aradmin")
class Ticket(object): pass
tickets_mapper = mapper(Ticket, tickets,
polymorphic_on=tickets.c.ticket_type,
polymorphic_identity="Default")
broken_query =
session.query(Ticket).filter(tickets.ticket_type=="Default").limit(10)
working_query =
session.query(Ticket).filter(tickets.ticket_type=="Default")
On oracle, if I comment out the polymorphic_* args it works with a
limit() specified.
Here's the last line of the traceback
sqlalchemy/engine.base.py, line 1479, in lookup_key
raise exceptions.NoSuchColumnError("Could not locate column in row
for column '%s'" % str(key))
exceptions.NoSuchColumnError: Could not locate column in row for
column 'tickets.ticket_type'
The sql its generating is (note i've sanitized the actual name of the
ticket_type column, it had a company's name in it)
SELECT hpd_helpdesk_case_id_, hpd_helpdesk_requester_l_1,
hpd_helpdesk_ticket_type__2
FROM (SELECT hpd_helpdesk.case_id_ AS hpd_helpdesk_case_id_,
hpd_helpdesk.requester_login_name_ AS hpd_helpdesk_requester_l_1,
hpd_helpdesk.ticket_type AS hpd_helpdesk_ticket_type__2, ROW_NUMBER()
OVER (ORDER BY hpd_helpdesk.rowid) AS ora_rn
FROM aradmin.hpd_helpdesk
hpd_helpdesk.ticket_type = :hpd_helpdesk_ticket_type__2)
WHERE ora_rn<=10
How can I fix this? I'm about to start hacking into the source to see
whats going on, but I figured I'd ask here first.
-Richard
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---