Can you please try this patch :
Code: Select all
Index: ZDbcSqLiteResultSet.pas
===================================================================
--- ZDbcSqLiteResultSet.pas (revision 374)
+++ ZDbcSqLiteResultSet.pas (working copy)
@@ -80,6 +80,8 @@
FColumnNames: PPChar;
FColumnValues: PPChar;
FPlainDriver: IZSQLitePlainDriver;
+ FBooleanTrue : String;
+ FBooleanFalse : String;
protected
procedure Open; override;
procedure FreeHandle;
@@ -180,6 +182,9 @@
Statement: IZStatement; SQL: string; Handle: Psqlite;
StmtHandle: Psqlite_vm; ColumnCount: Integer; ColumnNames: PPChar;
ColumnValues: PPChar);
+var
+ Tempstr : String;
+ CommaPos : integer;
begin
inherited Create(Statement, SQL, TZSQLiteResultSetMetadata.Create(
Statement.GetConnection.GetMetadata, SQL, Self));
@@ -192,6 +197,30 @@
FColumnNames := ColumnNames;
FColumnValues := ColumnValues;
+ If Statement.GetConnection.GetParameters.Values['true_false_values']<>'' then
+ begin
+ Tempstr := Statement.GetConnection.GetParameters.Values['true_false_values'];
+ CommaPos := Pos(Tempstr,',');
+ If CommaPos > 0 then
+ begin
+ FBooleanTrue := Copy(TempStr,1,CommaPos);
+ FBooleanFalse := Copy(TempStr,CommaPos+1,Length(TempStr)-CommaPos-1);
+ end
+ else
+ begin
+ FBooleanTrue := TempStr;
+ FBooleanFalse := '';
+ end;
+ If (FBooleanTrue[1]='''') and (FBooleanTrue[Length(FBooleanTrue)]='''') then FBooleanTrue := Copy(FBooleanTrue,2,Length(FBooleanTrue)-2);
+ If (FBooleanFalse[1]='''') and (FBooleanFalse[Length(FBooleanFalse)]='''') then FBooleanFalse := Copy(FBooleanFalse,2,Length(FBooleanFalse)-2);
+ end
+ else
+ begin
+ FBooleanTrue := '';
+ FBooleanFalse := '';
+ end;
+
+
Open;
end;
@@ -389,8 +418,13 @@
CheckColumnConvertion(ColumnIndex, stBoolean);
{$ENDIF}
Temp := UpperCase(GetPChar(ColumnIndex));
- Result := (Temp = 'Y') or (Temp = 'YES') or (Temp = 'T') or
- (Temp = 'TRUE') or (StrToIntDef(Temp, 0) <> 0);
+
+ If (FBooleanTrue = '') and (FBooleanFalse = '') then
+ // Connection parameter 'true_false_values' is not used
+ Result := (Temp = 'Y') or (Temp = 'YES') or (Temp = 'T') or
+ (Temp = 'TRUE') or (StrToIntDef(Temp, 0) <> 0)
+ else
+ Result := (Temp = FBooleanTrue);
end;
{**
Index: ZDbcSqLiteStatement.pas
===================================================================
--- ZDbcSqLiteStatement.pas (revision 374)
+++ ZDbcSqLiteStatement.pas (working copy)
@@ -86,6 +86,8 @@
private
FHandle: Psqlite;
FPlainDriver: IZSQLitePlainDriver;
+ FBooleanTrue : String;
+ FBooleanFalse : String;
protected
function CreateExecStatement: IZStatement; override;
function GetEscapeString(const Value: string): string;
@@ -289,11 +291,34 @@
}
constructor TZSQLitePreparedStatement.Create(PlainDriver: IZSQLitePlainDriver;
Connection: IZConnection; const SQL: string; Info: TStrings; Handle: Psqlite);
+var
+ Tempstr : String;
+ CommaPos : integer;
begin
inherited Create(Connection, SQL, Info);
FHandle := Handle;
FPlainDriver := PlainDriver;
ResultSetType := rtForwardOnly;
+ If Connection.GetParameters.Values['true_false_values']<>'' then
+ begin
+ Tempstr := Connection.GetParameters.Values['true_false_values'];
+ CommaPos := Pos(Tempstr,',');
+ If CommaPos > 0 then
+ begin
+ FBooleanTrue := Copy(TempStr,1,CommaPos);
+ FBooleanFalse := Copy(TempStr,CommaPos+1,Length(TempStr)-CommaPos-1);
+ end
+ else
+ begin
+ FBooleanTrue := TempStr;
+ FBooleanFalse := ''''''; //quoted empty string
+ end;
+ end
+ Else
+ begin
+ FBooleanTrue :='''Y''';
+ FBooleanFalse := '''N''';
+ end;
end;
{**
@@ -337,8 +362,8 @@
else begin
case InParamTypes[ParamIndex] of
stBoolean:
- if SoftVarManager.GetAsBoolean(Value) then Result := '''Y'''
- else Result := '''N''';
+ if SoftVarManager.GetAsBoolean(Value) then Result := FBooleanTrue
+ else Result := FBooleanFalse;
stByte, stShort, stInteger, stLong, stBigDecimal, stFloat, stDouble:
Result := SoftVarManager.GetAsString(Value);
stString, stBytes:
This should allow to add a connection parameter like 'true_false_values=1,0' , indicating that all boolean values read/written using this connection should use 1 as true value and 0 as false value. Attention : when using string values you should quote them like true_false_values='A','B'
I must admit, it's completely untested code... So I won't commit until somebody confirms the new feature works and it still works the old way.
Mark