Bug with SQL parsing

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
pincopallino
Posts: 16
Joined: Wed 03 Oct 2012 19:52

Bug with SQL parsing

Post by pincopallino » Wed 03 Oct 2012 20:17

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.

ZEuS
Devart Team
Posts: 240
Joined: Thu 05 Apr 2012 07:32

Re: Bug with SQL parsing

Post by ZEuS » Thu 04 Oct 2012 08:23

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).

Post Reply