Page 1 of 1

Bug with SQL parsing

Posted: Wed 03 Oct 2012 20:17
by pincopallino
With Unidac 4.5.9
I've a TUniQuery using InterbaseUniProvider with this SQL

Code: Select all

SELECT 
  LIBRI.*,
  EDITORI.NOME AS cEDITORE,
  COLLANE.NOME AS cCOLLANA,
  CATEGORIE.NOME AS cCATEGORIA,
  LINGUE.NOME AS cLINGUA,
  COMBINA_AUTORI.CAUTORI
FROM
  LIBRI
  LEFT OUTER JOIN EDITORI ON (LIBRI.EDITORE = EDITORI.ID)
  LEFT OUTER JOIN CATEGORIE ON (LIBRI.CATEGORIA = CATEGORIE.ID)
  LEFT OUTER JOIN COLLANE ON (LIBRI.COLLANA = COLLANE.ID)
  LEFT OUTER JOIN LINGUE ON (LIBRI.LINGUA = LINGUE.ID)
  LEFT OUTER JOIN COMBINA_AUTORI(LIBRI.ID) ON (1=1)
ORDER BY cEditore, cCOLLANA, LIBRI.NUMCOLL
if Options.QueryRecCount is True then I get an error because the query used to count the record will be this:

Code: Select all

'SELECT COUNT(*) FROM ('#$D'SELECT 1 AS C '#$A'FROM'#$D#$A'  LIBRI'#$D#$A'  LEFT OUTER JOIN EDITORI ON (LIBRI.EDITORE = EDITORI.ID)'#$D#$A'  LEFT OUTER JOIN CATEGORIE ON (LIBRI.CATEGORIA = CATEGORIE.ID)'#$D#$A'  LEFT OUTER JOIN COLLANE ON (LIBRI.COLLANA = COLLANE.ID)'#$D#$A'  LEFT OUTER JOIN LINGUE ON (LIBRI.LINGUA = LINGUE.ID)'#$D#$A'  LEFT OUTER JOIN COMBINA_AUTORI(LIBRI.ID) ON (1=1)'#$D#$A'ORDER BY cEditore, cCOLLANA, LIBRI.NUMCOLL'#$D') q'
The problem is that your query continue to use the "ORDER BY" (clause that here is not necessary) and I used not the original field name but an alias.
Changing the field names solved it.
In Unidac 4.1.5 it worked well.

Re: Bug with SQL parsing

Posted: Thu 04 Oct 2012 08:23
by ZEuS
Thank you for the information. We know about the error and have already fixed it.
The fix will be included in the nearest UniDAC build (we plan to release the next build in this month).