Opened 8 years ago

Last modified 8 years ago

#26680 closed Bug

more than one row returned by a subquery used as an expression — at Initial Version

Reported by: Maarten Owned by: nobody
Component: Database layer (models, ORM) Version: 1.9
Severity: Normal Keywords: ORM subquery multiple rows
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Summary:
In 1.8 the subquery has a compare to "in", in 1.9 to "=". In my view 1.8 is correct.

The query:

leverancier_medew = Adresboek.objects.filter(
         klant_id=klant_id, 
         soort='leverancier', 
         leverancier=Leverancier.objects.filter(
                      klant_id=klant_id, 
                      locatie=melding.apparaat.locatie))

gives in 1.8.6

SELECT "meldman_adresboek"."id",  etc.etc.
FROM "meldman_adresboek" 
WHERE ("meldman_adresboek"."soort" = 'leverancier' 
AND "meldman_adresboek"."klant_id" = 24 
AND "meldman_adresboek"."leverancier_id" IN 
  (SELECT U0."id" 
   FROM "meldman_leverancier" U0 
   INNER JOIN "meldman_locatie_leverancier" U2 ON (U0."id" = U2."leverancier_id") 
     WHERE (U0."klant_id" = 24 AND U2."locatie_id" = 75))) 
  ORDER BY "meldman_adresboek"."achternaam" ASC, "meldman_adresboek"."voornaam" ASC

The line:

   AND "meldman_adresboek"."leverancier_id" IN

changes in 1.9 to

   AND "meldman_adresboek"."leverancier_id" = 

which then returns the error: "more than one row returned by a subquery used as an expression".

My sincere thanks for your time and attention.
Greetings,
Maarten

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top