Michael, I simplified my code just for test purposes. I'm now working with only two columns, without order_by clause, commented a few other lines with order by. I'm sure there is no order_by left in my code. I run the script with echo set to debug. The result:
INFO:sqlalchemy.engine.base.Engine.0x...a7d0:{} DEBUG:sqlalchemy.engine.base.Engine.0x...a7d0:Col ('contributie_alle_leden_id', 'contributie_alle_leden_achternaam') 2011-12-27 16:23:05,839 INFO sqlalchemy.engine.base.Engine.0x...a7d0 SELECT contributie_alle_leden.id AS contributie_alle_leden_id, contributie_alle_leden.achternaam AS contributie_alle_leden_achternaam FROM (SELECT "Leden".id AS id, "Leden".achternaam AS achternaam FROM "Leden") AS contributie_alle_leden ORDER BY contributie_alle_leden.id The order by is still added. As sqlalchemy doesn't add things, the only suspect now is elixir. This is part of the Camelot framework and act as a layer upon SQLAlchemy. Regards, Peter On Dec 25, 11:33 pm, Michael Bayer <mike...@zzzcomputing.com> wrote: > On Dec 25, 2011, at 3:19 PM, VDK wrote: > > > > > > > > > > > With echo=True, the following sql statements are reported: > > > INFO:sqlalchemy.engine.base.Engine.0x...9890:select version() > > INFO:sqlalchemy.engine.base.Engine.0x...9890:{} > > 2011-12-25 21:08:58,796 INFO sqlalchemy.engine.base.Engine.0x...9890 > > select version() > > 2011-12-25 21:08:58,797 INFO sqlalchemy.engine.base.Engine.0x...9890 > > {} > > INFO:sqlalchemy.engine.base.Engine.0x...9890:select current_schema() > > INFO:sqlalchemy.engine.base.Engine.0x...9890:{} > > 2011-12-25 21:08:58,819 INFO sqlalchemy.engine.base.Engine.0x...9890 > > select current_schema() > > 2011-12-25 21:08:58,819 INFO sqlalchemy.engine.base.Engine.0x...9890 > > {} > > 2011-12-25 21:08:58,822 INFO sqlalchemy.engine.base.Engine.0x...9890 > > SELECT count(1) AS count_1 > > INFO:sqlalchemy.engine.base.Engine.0x...9890:SELECT count(1) AS > > count_1 > > FROM (SELECT "Leden".id AS id, "Leden".achternaam AS achternaam, > > "Leden".tussenvoegsel AS tussenvoegsel, "Leden".voorletters AS > > voorletters, "Leden".adres AS adres, "Leden".postcode AS postcode, > > "Leden".woonplaats AS woonplaats, "Tarieven".omschrijving AS > > omschrijving, "Tarieven".tariefbedrag AS tariefbedrag, > > "Leden".adresenpc AS adresenpc > > FROM "Leden", "Tarieven" > > FROM (SELECT "Leden".id AS id, "Leden".achternaam AS achternaam, > > "Leden".tussenvoegsel AS tussenvoegsel, "Leden".voorletters AS > > voorletters, "Leden".adres AS adres, "Leden".postcode AS postcode, > > "Leden".woonplaats AS woonplaats, "Tarieven".omschrijving AS > > omschrijving, "Tarieven".tariefbedrag AS tariefbedrag, > > "Leden".adresenpc AS adresenpc > > WHERE "Leden".lidsoort_id IN (%(lidsoort_id_1)s, %(lidsoort_id_2)s) > > AND "Tarieven".id = "Leden".lidsoort_id ORDER BY "Leden".achternaam) > > AS contributie_alle_leden > > FROM "Leden", "Tarieven" > > 2011-12-25 21:08:58,822 INFO sqlalchemy.engine.base.Engine.0x...9890 > > {'lidsoort_id_2': 2, 'lidsoort_id_1': 1} > > WHERE "Leden".lidsoort_id IN (%(lidsoort_id_1)s, %(lidsoort_id_2)s) > > AND "Tarieven".id = "Leden".lidsoort_id ORDER BY "Leden".achternaam) > > AS contributie_alle_leden > > INFO:sqlalchemy.engine.base.Engine.0x...9890:{'lidsoort_id_2': 2, > > 'lidsoort_id_1': 1} > > INFO:sqlalchemy.engine.base.Engine.0x...9890:SELECT > > contributie_alle_leden.id AS contributie_alle_leden_id, > > contributie_alle_leden.achternaam AS > > contributie_alle_leden_achternaam, > > contributie_alle_leden.tussenvoegsel AS > > contributie_alle_leden_tussenvoegsel, > > contributie_alle_leden.voorletters AS > > contributie_alle_leden_voorletters, contributie_alle_leden.adres AS > > contributie_alle_leden_adres, contributie_alle_leden.postcode AS > > contributie_alle_leden_postcode, contributie_alle_leden.woonplaats AS > > contributie_alle_leden_woonplaats, contributie_alle_leden.omschrijving > > AS contributie_alle_leden_omschrijving, > > contributie_alle_leden.tariefbedrag AS > > contributie_alle_leden_tariefbedrag, contributie_alle_leden.adresenpc > > AS contributie_alle_leden_adresenpc > > 2011-12-25 21:08:58,925 INFO sqlalchemy.engine.base.Engine.0x...9890 > > SELECT contributie_alle_leden.id AS contributie_alle_leden_id, > > contributie_alle_leden.achternaam AS > > contributie_alle_leden_achternaam, > > contributie_alle_leden.tussenvoegsel AS > > contributie_alle_leden_tussenvoegsel, > > contributie_alle_leden.voorletters AS > > contributie_alle_leden_voorletters, contributie_alle_leden.adres AS > > contributie_alle_leden_adres, contributie_alle_leden.postcode AS > > contributie_alle_leden_postcode, contributie_alle_leden.woonplaats AS > > contributie_alle_leden_woonplaats, contributie_alle_leden.omschrijving > > AS contributie_alle_leden_omschrijving, > > contributie_alle_leden.tariefbedrag AS > > contributie_alle_leden_tariefbedrag, contributie_alle_leden.adresenpc > > AS contributie_alle_leden_adresenpc > > FROM (SELECT "Leden".id AS id, "Leden".achternaam AS achternaam, > > "Leden".tussenvoegsel AS tussenvoegsel, "Leden".voorletters AS > > voorletters, "Leden".adres AS adres, "Leden".postcode AS postcode, > > "Leden".woonplaats AS woonplaats, "Tarieven".omschrijving AS > > omschrijving, "Tarieven".tariefbedrag AS tariefbedrag, > > "Leden".adresenpc AS adresenpc > > FROM "Leden", "Tarieven" > > WHERE "Leden".lidsoort_id IN (%(lidsoort_id_1)s, %(lidsoort_id_2)s) > > AND "Tarieven".id = "Leden".lidsoort_id ORDER BY "Leden".achternaam) > > AS contributie_alle_leden ORDER BY contributie_alle_leden.id > > LIMIT 24 OFFSET 0 > > 2011-12-25 21:08:58,925 INFO sqlalchemy.engine.base.Engine.0x...9890 > > {'lidsoort_id_2': 2, 'lidsoort_id_1': 1} > > FROM (SELECT "Leden".id AS id, "Leden".achternaam AS achternaam, > > "Leden".tussenvoegsel AS tussenvoegsel, "Leden".voorletters AS > > voorletters, "Leden".adres AS adres, "Leden".postcode AS postcode, > > "Leden".woonplaats AS woonplaats, "Tarieven".omschrijving AS > > omschrijving, "Tarieven".tariefbedrag AS tariefbedrag, > > "Leden".adresenpc AS adresenpc > > FROM "Leden", "Tarieven" > > WHERE "Leden".lidsoort_id IN (%(lidsoort_id_1)s, %(lidsoort_id_2)s) > > AND "Tarieven".id = "Leden".lidsoort_id ORDER BY "Leden".achternaam) > > AS contributie_alle_leden ORDER BY contributie_alle_leden.id > > LIMIT 24 OFFSET 0 > > INFO:sqlalchemy.engine.base.Engine.0x...9890:{'lidsoort_id_2': 2, > > 'lidsoort_id_1': 1} > > > The problem is in the last few sentences where you can see '.... ORDER > > BY "Leden".achternaam) AS .... ORDER BY contributie_alle_leden.id'. So > > the last ORDER BY is consistent with what is visible in the GUI: > > ordered by primary key. So the question should be now: how to > > construct a select that omits the last (and unwanted) ORDER BY clause? > > This output appears somewhat truncated as the line "FROM (SELECT..." seems to > be a new log line that begins with FROM (I have a mac which does this > sometimes when pasting from terminal), but in any case, assuming you're on at > least version 0.5, SQLAlchemy does not in any case ever add an ORDER BY > clause to the statement that wasn't implemented by the programmer. You'd > need to locate where this ORDER BY is specified in your application, either > in mapper(), relationship(), or query.order_by(), and remove it. -- 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 sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.