Page 1 of 1

MetaDataKind IndexColumns not working for SQLite

Posted: Tue 14 Jun 2011 14:39
by Elias Zurschmiede
Hi

Just updated to version "UniDac 3.70.0.17 28-Apr-2011" now the MetaDataKind "IndexColumns" is not working anymore for SQLite. UniMetaData shows only one index (autoindex0) even if there are other indexes defined.

Tracked down the problem to LiteClassesUni.pas > TSQLiteMetaData.ParseIndexSQL: The variable lexem contains ident quotes and is compared to a string without ident quotes.

On this line here:

Code: Select all

if _LowerCase(Lexem) = _LowerCase(Members.Columns[c].Name) then 

My workaround is to remove the ident quotes ("") 1st:

Code: Select all

      repeat
        Code := Parser.GetNext(Lexem);
        if (Code = lcEnd) or (Lexem = ')') then
          break;
        
        // EZ: workaround for IndexColumns not working in SQLite.
        if (Code = lcIdent) and (Length(Lexem) > 0) and (Lexem[1] in ['"', '`']) then 
          Lexem := Copy(Lexem, 2, Length(Lexem)-2);

        if (Lexem  ',') then begin
          for c := 0 to Length(Members.Columns) - 1 do
            if _LowerCase(Lexem) = _LowerCase(Members.Columns[c].Name) then begin
              j := Length(Members.Indexes[0].ColumnInfo);
              SetLength(Members.Indexes[0].ColumnInfo, j + 1);
              Members.Indexes[0].ColumnInfo[j].ColumnIndex := c;

              Code := Parser.GetNext(Lexem); // asc, desc
              if Code  lcEnd then
                Members.Indexes[0].ColumnInfo[j].IsDesc := _LowerCase(Lexem) = 'desc';
              break;
            end;
        end;
      until False;

BTW: This is a sample query SQLite returns for parsing. As you can see the fieldname are in ident quotes.
CREATE INDEX "0A75FF397290434A9830DDC97045DAD9" ON "adrpro_classificationfunctions" ("classificationtypeid")
BTW 2nd: Tested with current SQLite Version 3.7.6.3

Thanks for fixing this in next release.

regards
Elias Zurschmiede

Posted: Wed 15 Jun 2011 07:08
by AlexP
Hello,

Thank you for the information.
We have fixed the problem.
This fix will be included in the next build.