Skip to content
Permalink
Browse files

Issue #12: Proper implementation of TSQLiteQuery.ColIsPrimaryKeyPart()

  • Loading branch information
ansgarbecker committed Jan 1, 2020
1 parent 7fc55c5 commit c9d3d3c38db271e4ac2b9f86e2f82a2cb2d3d282
Showing with 23 additions and 0 deletions.
  1. +18 −0 source/dbconnection.pas
  2. +5 −0 source/dbstructures.pas
@@ -7137,8 +7137,26 @@ function TPGQuery.ColIsPrimaryKeyPart(Column: Integer): Boolean;


function TSQLiteQuery.ColIsPrimaryKeyPart(Column: Integer): Boolean;
var
MetaResult: Integer;
TableNm, ColumnNm: String;
DataType, CollSeq: PAnsiChar;
NotNull, PrimaryKey, Autoinc: Integer;
begin
Result := False;
TableNm := TableName(Column);
ColumnNm := FColumnOrgNames[Column];
if not TableNm.IsEmpty then begin
MetaResult := FConnection.Lib.sqlite3_table_column_metadata(FConnection.FHandle,
PAnsiChar(Utf8Encode(FConnection.Database)),
PAnsiChar(Utf8Encode(TableNm)),
PAnsiChar(Utf8Encode(ColumnNm)),
DataType, CollSeq, NotNull, PrimaryKey, Autoinc
);
if MetaResult <> SQLITE_ERROR then begin
Result := PrimaryKey.ToBoolean;
end;
end;
end;


@@ -536,6 +536,10 @@ TSQLiteLib = class(TDbLib)
sqlite3_column_table_name: function(pStmt: Psqlite3_stmt; N: Integer): PAnsiChar; cdecl;
sqlite3_column_origin_name: function(pStmt: Psqlite3_stmt; N: Integer): PAnsiChar; cdecl;
sqlite3_next_stmt: function(ppDb: Psqlite3; pStmt: Psqlite3_stmt): Psqlite3_stmt; cdecl;
sqlite3_table_column_metadata: function(ppDb: Psqlite3;
zDbName, zTableName, zColumnName: PAnsiChar;
var pzDataType, pzCollSeq: PAnsiChar; var pNotNull, pPrimaryKey, pAutoinc: Integer
): Integer; cdecl;
private
procedure AssignProcedures; override;
end;
@@ -7949,6 +7953,7 @@ procedure TSQLiteLib.AssignProcedures;
AssignProc(@sqlite3_column_table_name, 'sqlite3_column_table_name');
AssignProc(@sqlite3_column_origin_name, 'sqlite3_column_origin_name');
AssignProc(@sqlite3_next_stmt, 'sqlite3_next_stmt');
AssignProc(@sqlite3_table_column_metadata, 'sqlite3_table_column_metadata');
end;


0 comments on commit c9d3d3c

Please sign in to comment.
You can’t perform that action at this time.