Hi there,
I am in the process of upgrading from VA Smalltalk 9.2.2 to 10.0.2. The old one contains a port of Glorp based on Glorp 8.1-7, the new one has a port of Glorp 9.0-11, nross
We just found out that the new version produces more complex joins for the same SimpleQuery (which is not actually simple).
Here is the code that creates the Query and is unchanged between VAST 9.2.2 and VAST 10.0.2 (the same method edition is present in the old and new image):
q :=
SimpleQuery
read: Umsatz
where: [:ums |
ums konto = self & (ums buchungssatz buchungsDatum between: strt and: ende)].
q alsoFetch: [:u | u buchungssatz].
q alsoFetch: [:u| u buchungssatz buchungsbeleg asOuterJoin].
q alsoFetch: [:u| u buchungssatz buchungsbeleg externesDokument asOuterJoin].
q alsoFetch: [:u | u buchungssatz umsaetze asOuterJoin].
q alsoFetch: [:u | u buchungssatz umsaetze konto asOuterJoin].
q orderBy: [:u | u buchungssatz buchungsDatum ].
As you can see, there are outer joins to related tables and even going one table further.
The old Glorp version creates this Statement:
SELECT *
FROM (
(
(
(
(DB2INST1.UMSATZ t1 INNER JOIN DB2INST1.BUCHUNGSSATZ t2 ON (t1.buchsatz_id = t2.id)
)
LEFT OUTER JOIN DB2INST1.BUCHUNGSBELEG t3 ON (t2.beleg_id = t3.id)
)
LEFT OUTER JOIN DB2INST1.EXTERNESDOKUMENT t4 ON (t3.ext_beleg_id = t4.id)
)
LEFT OUTER JOIN DB2INST1.UMSATZ t5 ON (t2.id = t5.buchsatz_id)
)
LEFT OUTER JOIN DB2INST1.KPELEMENT t6 ON (t5.konto_id = t6.id)
)
WHERE ((t1.konto_id = 2555494) AND t2.datum BETWEEN '2021-01-01' AND '2021-05-31')
ORDER BY t2.datum, t2.id
As you can see, it joins 6 tables and finds the expected result. The newer version, however, joins 8 tables and finds nothing:
SELECT *
FROM (
(
(
(
(
(
(DB2INST1.UMSATZ t1 INNER JOIN DB2INST1.BUCHUNGSSATZ t2 ON (t1.buchsatz_id = t2.id)
)
INNER JOIN DB2INST1.BUCHUNGSBELEG t3 ON (t2.beleg_id = t3.id)
)
LEFT OUTER JOIN DB2INST1.EXTERNESDOKUMENT t4 ON (t3.ext_beleg_id = t4.id)
)
INNER JOIN DB2INST1.UMSATZ t5 ON (t2.id = t5.buchsatz_id)
)
LEFT OUTER JOIN DB2INST1.KPELEMENT t6 ON (t5.konto_id = t6.id)
)
LEFT OUTER JOIN DB2INST1.BUCHUNGSBELEG t7 ON (t2.beleg_id = t7.id)
)
LEFT OUTER JOIN DB2INST1.UMSATZ t8 ON (t2.id = t8.buchsatz_id)
)
WHERE ((t1.konto_id = 2555494) AND t2.datum BETWEEN '2021-01-01' AND '2021-05-31')
ORDER BY t2.datum, t2.id;
I guess this has to do with the way #asOuterJoin worked then vs. how it works in this later version.
Does anybody have some insight into what is wrong here? Is this a bug or a feature and my query creation code in the old version was "wrong" from a Glorp standpoint?
Joachim