/srv/irclogs.ubuntu.com/2013/07/15/#launchpad-dev.txt

StevenKwgrant: http://pastebin.ubuntu.com/5876192/03:18
wgrantStevenK: You generate different code depending on the backend?03:28
StevenKwgrant: Sadly, I have to.03:49
StevenK        # DISTINCT ON is not supported in sqlite3, and GROUP BY with all fields03:49
StevenK        # is not supported in psql.03:49
wgrantpsql is a command-line client; I think you mean PostgreSQL or postgres :)03:53
wgrantBut sounds reasonable03:53
wgrantDoes it work?03:53
StevenKwgrant: Doesn't that pastebin prove it does?03:54
wgrantStevenK: No, the tests are inadequate, I suspect03:55
wgranteg. the SQLite implementation doesn't have an ORDER BY03:56
StevenKwgrant: That's on purpose.03:56
wgrantOh03:57
StevenKIf I add a ORDER BY, Django adds every field to the GROUP BY and sqlite returns everything03:57
wgrantHow does it work, then?03:57
StevenKwgrant: TBH, I was happy enough to find a query that sqlite3 actually liked and returned the right data.03:57
wgrantSure03:58
wgrantAnd we shouldn't write queries based on what Django's ORM supports -- we should write queries that work.03:58
wgrantThen work out how to make Django like them03:58
wgrantThe sqlite query at present only works by accident03:58
StevenKGROUP BY is a terrible hack, because Django wants everyone to use their aggregation stuff03:59
wgrantSure03:59
wgrantIDGAF about Django atm03:59
wgrantWork out SQL that does what you want03:59
wgrantThen Djangofy it03:59
wgrantPossibly using lots of quotes...03:59
wgrantWorking > Djangoy03:59
StevenKwgrant: I hit IDGAF about Django on about Tuesday of last week03:59
StevenKSeriously considered Pylons04:00
wgrants/Pylons/Pyramid/04:00
StevenKThat04:00
wgrantWould have been a much more sensible choice, but our deployment story for that is, I believe weaker.04:00
wgrant(I argued for it at the time :P)04:00
StevenKI remember.04:00
StevenKWe got lifeless'd.04:01
lifelessare you passive-aggressive trolling ? :)04:02
StevenKwgrant: http://pastebin.ubuntu.com/5876270/04:02
wgrantStevenK: Hm?04:03
StevenKlifeless: A little, this exercise has moved my opinion of Django's ORM from hate to outright loathing04:03
wgrantI'm not sure why you're not just bypassing most of it here04:03
wgrantYou're not doing any complex object-related queries04:03
wgrantSQL would probably work just as well, as we do sometimes in Storm04:03
StevenKThe filtering stuff I'm doing for object operation and actor works well enough04:04
StevenKIt's just distinct that makes me want to stab things04:04
* StevenK ponders being evil, grabbing the query string, appending ORDER BY and then executing it04:08
StevenKOh, blah.04:32
StevenKIf you ask for a raw query from a QuerySet, it quotes EVERYTHING *except* string data that you're asking the database for.04:32
=== tasdomas_afk is now known as tasdomas
StevenKwgrant: I have convinced sqlite and Django to add ORDER BY06:29
StevenKSELECT "auditor_auditor"."id", "auditor_auditor"."date", "auditor_auditor"."operation", "auditor_auditor"."object", "auditor_auditor"."actor", "auditor_auditor"."comment", "auditor_auditor"."details" FROM "auditor_auditor" WHERE ("auditor_auditor"."object" IN (lp-development:PackageUpload:16) AND "auditor_auditor"."operation" IN (packageupload-accepted, packageupload-rejected)) GROUP BY (object), (operation) ORDER BY object, operation, -date06:31
wgrantStevenK: Does that work?06:35
wgranteg. are the operations performed in the right order?06:35
* wgrant gone for a while06:35
=== mthaddon` is now known as mthaddon
=== rvba` is now known as rvba
=== jam1 is now known as jam
=== Guest46086 is now known as jpds
=== tasdomas is now known as tasdomas_afk
=== matsubara is now known as matsubara-lunch
=== matsubara-lunch is now known as matsubara
=== BradCrittenden is now known as bac
StevenKwgrant: So I'm not certain why the sqlite test works without the ORDER BY, but it also works with it.23:45
StevenK(And the code that actually injects ORDER BY so that Django doesn't just go ahead and add every field to the GROUP BY is truly hideous.)23:46
wgrantStevenK: There could be a flaw in the test, or perhaps it works by accident due to SQLite implicitly sorting the right way23:51
wgrantDoes the behaviour become obviously incorrect if you invert the sort?23:51
wgrantAnd does the auditor test suite run across both backends?23:51
StevenKNo23:51
StevenKwgrant: Hm, if I switch from -date to date in the ORDER BY it doesn't fail23:53
wgrantRight, so it's probably executing in the wrong order23:53
wgrantAn explain will confir23:53
StevenKwgrant: EXPLAIN in sqlite is ... odd23:55
wgrantIt's different from PostgreSQL's, yes23:55
StevenKwgrant: http://pastebin.ubuntu.com/5879198/23:56
wgrantStevenK: Oh, you probably want EXPLAIN QUERY PLAN23:57
wgrantRather than the underlying VM instructions23:58
StevenKOh23:58
wgrantBut you can tell from that EXPLAIN that it's doing the sort at the end23:58
wgrantYou may need to use a subselect for sqlite23:58
StevenKEXPLAIN QUERY PLAN is pretty useless too23:58
wgrantWhat does it say?23:59
StevenKwgrant: http://pastebin.ubuntu.com/5879202/23:59

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!