Breaking changes on select count (*)

Discussion of open issues, suggestions and bugs regarding LiteDAC (SQLite Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
pwatel
Posts: 39
Joined: Wed 11 Feb 2009 09:42

Breaking changes on select count (*)

Post by pwatel » Sun 10 Nov 2013 06:59

Hi
I upgraded to the latest version and to my surprise I got some crashes on this
ssql := 'SELECT COUNT(*) FROM ACTIONS';
PrepareDataset(aDataset, ssql);
Number := aDataset.Fields[0].asInteger;
Now the SQLite cannot retrieve this field as integer
a) it is a breaking change that should be mentioned somewhere
b) it is not very smart because guess what it is always an integer and if empty should return 0
now I have to do
ssql := 'SELECT COUNT(*) FROM ACTIONS';
PrepareDataset(aDataset, ssql);
Variant:= aDataset.Fields[0].Value;
Number := Variant

Now I have a hard time to call this upgrade an improvement at least for this feature
I have the same problem with the FTS tables but there I can understand it is all text not regular databases
Any thoughs? thanks
PW

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Breaking changes on select count (*)

Post by AlexP » Mon 11 Nov 2013 07:40

Hello,

We cannot reproduce the problem on the latest LiteDAC version 2.1.4. Please run the following code, and let us know the result.

Code: Select all

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils, LiteAccess;

var
  LiteConnection: TLiteConnection;
  LiteQuery: TLiteQuery;
begin
  LiteConnection := TLiteConnection.Create(nil);
  try
    LiteConnection.Database := ':memory:';
    LiteConnection.Connect;
    LiteConnection.ExecSQL('create table test (id integer)');
    LiteConnection.ExecSQL('insert into test values(1),(2),(3),(4),(5),(6),(7)');
    LiteQuery := TLiteQuery.Create(nil);
    try
      LiteQuery.Connection := LiteConnection;
      LiteQuery.SQL.Text := 'select count(*) from test';
      LiteQuery.Open;
      Writeln(IntToStr(LiteQuery.Fields[0].AsInteger));
    finally
      LiteQuery.Free;
    end;
  finally
    LiteConnection.Free;
    readln;
  end;
end.

Post Reply