Browse Source

--- Merging r16853 into '.':
U packages/fcl-db/tests/testfieldtypes.pas
U packages/fcl-db/src/sqldb/sqlite/sqlite3conn.pp
--- Merging r16855 into '.':
G packages/fcl-db/src/sqldb/sqlite/sqlite3conn.pp
--- Merging r16945 into '.':
U compiler/globals.pas

# revisions: 16775,16776,16853,16855,16945
------------------------------------------------------------------------
r16775 | michael | 2011-01-18 09:36:09 +0100 (Tue, 18 Jan 2011) | 1 line
Changed paths:
M /trunk/packages/fcl-db/src/sqldb/sqlite/sqlite3conn.pp

* Applied patch from bug #16493
------------------------------------------------------------------------
------------------------------------------------------------------------
r16776 | michael | 2011-01-18 10:31:49 +0100 (Tue, 18 Jan 2011) | 1 line
Changed paths:
M /trunk/packages/fcl-db/src/sqldb/sqlite/sqlite3conn.pp

* Minor code cleanup suggested by LacaK <[email protected]>
------------------------------------------------------------------------
------------------------------------------------------------------------
r16853 | joost | 2011-01-30 18:50:18 +0100 (Sun, 30 Jan 2011) | 1 line
Changed paths:
M /trunk/packages/fcl-db/src/sqldb/sqlite/sqlite3conn.pp
M /trunk/packages/fcl-db/tests/testfieldtypes.pas

* Added recognition of CLOB fields to TSqlite3Conn + test, bug #17004
------------------------------------------------------------------------
------------------------------------------------------------------------
r16855 | joost | 2011-01-30 20:24:08 +0100 (Sun, 30 Jan 2011) | 1 line
Changed paths:
M /trunk/packages/fcl-db/src/sqldb/sqlite/sqlite3conn.pp

* Added support for ftMemo-params in TSQLite3Conn
------------------------------------------------------------------------
------------------------------------------------------------------------
r16945 | joost | 2011-02-20 01:04:20 +0100 (Sun, 20 Feb 2011) | 2 lines
Changed paths:
M /trunk/compiler/globals.pas

* Replace environment variables placed between dollar signs in fpc.cfg
with the value of the environment variable.
------------------------------------------------------------------------

git-svn-id: branches/fixes_2_4@16968 -

marco 14 years ago
parent
commit
be82819387

+ 27 - 0
compiler/globals.pas

@@ -712,6 +712,10 @@ implementation
 ****************************************************************************}
 ****************************************************************************}
 
 
      procedure DefaultReplacements(var s:ansistring);
      procedure DefaultReplacements(var s:ansistring);
+       var
+         envstr: string;
+         envvalue: pchar;
+         i: integer;
        begin
        begin
          { Replace some macros }
          { Replace some macros }
          Replace(s,'$FPCVERSION',version_string);
          Replace(s,'$FPCVERSION',version_string);
@@ -723,6 +727,29 @@ implementation
            Replace(s,'$FPCTARGET',target_os_string)
            Replace(s,'$FPCTARGET',target_os_string)
          else
          else
            Replace(s,'$FPCTARGET',target_full_string);
            Replace(s,'$FPCTARGET',target_full_string);
+         { Replace environment variables between dollar signs }
+         i := pos('$',s);
+         while i>0 do
+          begin
+            envstr:=copy(s,i+1,length(s)-i);
+            i:=pos('$',envstr);
+            if i>0 then
+             begin
+               envstr := copy(envstr,1,i-1);
+               envvalue := GetEnvPChar(envstr);
+               if assigned(envvalue) then
+                 begin
+                 Replace(s,'$'+envstr+'$',envvalue);
+                 // Look if there is another env.var in the string
+                 i:=pos('$',s);
+                 end
+               else
+                 // if the env.var is not set, do not replace the env.variable
+                 // and stop looking for more env.var within the string
+                 i := 0;
+              FreeEnvPChar(envvalue);
+             end;
+          end;
        end;
        end;
 
 
 
 

+ 7 - 5
packages/fcl-db/src/sqldb/sqlite/sqlite3conn.pp

@@ -181,10 +181,11 @@ begin
                 do1:= P.asfloat;
                 do1:= P.asfloat;
                 checkerror(sqlite3_bind_double(fstatement,I,do1));
                 checkerror(sqlite3_bind_double(fstatement,I,do1));
                 end;
                 end;
-        ftstring: begin
-                  str1:= p.asstring;
-                  checkerror(sqlite3_bind_text(fstatement,I,pcharstr(str1), length(str1),@freebindstring));
-                  end;
+        ftstring,
+        ftmemo: begin // According to SQLite documentation, CLOB's (ftMemo) have the Text affinity
+                str1:= p.asstring;
+                checkerror(sqlite3_bind_text(fstatement,I,pcharstr(str1), length(str1),@freebindstring));
+                end;
         ftblob: begin
         ftblob: begin
                 str1:= P.asstring;
                 str1:= P.asstring;
                 checkerror(sqlite3_bind_blob(fstatement,I,pcharstr(str1), length(str1),@freebindstring));
                 checkerror(sqlite3_bind_blob(fstatement,I,pcharstr(str1), length(str1),@freebindstring));
@@ -312,7 +313,7 @@ Type
   end;
   end;
   
   
 Const
 Const
-  FieldMapCount = 19;
+  FieldMapCount = 20;
   FieldMap : Array [1..FieldMapCount] of TFieldMap = (
   FieldMap : Array [1..FieldMapCount] of TFieldMap = (
    (n:'INT'; t: ftInteger),
    (n:'INT'; t: ftInteger),
    (n:'LARGEINT'; t:ftlargeInt),
    (n:'LARGEINT'; t:ftlargeInt),
@@ -332,6 +333,7 @@ Const
    (n:'NUMERIC'; t: ftBCD),
    (n:'NUMERIC'; t: ftBCD),
    (n:'DECIMAL'; t: ftBCD),
    (n:'DECIMAL'; t: ftBCD),
    (n:'TEXT'; t: ftmemo),
    (n:'TEXT'; t: ftmemo),
+   (n:'CLOB'; t: ftmemo),
    (n:'BLOB'; t: ftBlob)
    (n:'BLOB'; t: ftBlob)
 { Template:
 { Template:
   (n:''; t: ft)
   (n:''; t: ft)

+ 25 - 0
packages/fcl-db/tests/testfieldtypes.pas

@@ -96,6 +96,9 @@ type
     procedure TestClearUpdateableStatus;
     procedure TestClearUpdateableStatus;
     procedure TestReadOnlyParseSQL; // bug 9254
     procedure TestReadOnlyParseSQL; // bug 9254
     procedure TestGetTables;
     procedure TestGetTables;
+
+    // Test SQL-field type recognition
+    procedure TestSQLClob;
   end;
   end;
 
 
 implementation
 implementation
@@ -1580,6 +1583,28 @@ begin
     end;
     end;
 end;
 end;
 
 
+procedure TTestFieldTypes.TestSQLClob;
+var
+  i          : byte;
+begin
+  CreateTableWithFieldType(ftMemo,'CLOB');
+  TestFieldDeclaration(ftMemo,0);
+
+  for i := 0 to testValuesCount-1 do
+    TSQLDBConnector(DBConnector).Connection.ExecuteDirect('insert into FPDEV2 (FT) values (' + QuotedStr(testStringValues[i]) + ')');
+
+  with TSQLDBConnector(DBConnector).Query do
+    begin
+    Open;
+    for i := 0 to testValuesCount-1 do
+      begin
+      AssertEquals(testStringValues[i],fields[0].AsString);
+      Next;
+      end;
+    close;
+    end;
+end;
+
 procedure TTestFieldTypes.TestUpdateIndexDefs;
 procedure TTestFieldTypes.TestUpdateIndexDefs;
 var ds : TSQLQuery;
 var ds : TSQLQuery;
 begin
 begin