Browse Source

fcl-db: odbc: map UNSIGNED SMALLINT to ftWord fields. TestSupportWordFields

git-svn-id: trunk@25032 -
lacak 12 năm trước cách đây
mục cha
commit
7a46ebd7f1

+ 21 - 1
packages/fcl-db/src/sqldb/odbc/odbcconn.pas

@@ -1088,7 +1088,7 @@ var
   ColName,TypeName:string;
   FieldType:TFieldType;
   FieldSize:word;
-  AutoIncAttr, Updatable, FixedPrecScale: SQLLEN;
+  AutoIncAttr, Updatable, FixedPrecScale, Unsigned: SQLLEN;
 begin
   ODBCCursor:=cursor as TODBCCursor;
 
@@ -1224,6 +1224,7 @@ begin
 
     if FieldType in [ftFloat] then
     begin
+      FixedPrecScale:=0;
       ODBCCheckResult(
         SQLColAttribute(ODBCCursor.FSTMTHandle,
                         i,
@@ -1238,6 +1239,25 @@ begin
         FieldType:=ftCurrency;
     end;
 
+    if FieldType in [ftSmallint] then
+    begin
+      Unsigned:=0;
+      ODBCCheckResult(
+        SQLColAttribute(ODBCCursor.FSTMTHandle,
+                        i,
+                        SQL_DESC_UNSIGNED,
+                        nil,
+                        0,
+                        nil,
+                        @Unsigned),
+      SQL_HANDLE_STMT, ODBCCursor.FSTMTHandle, 'Could not get unsigned attribute for column %d.',[i]
+    );
+    if Unsigned=SQL_TRUE then
+      case FieldType of
+        ftSmallint: FieldType:=ftWord;
+      end;
+    end;
+
     if FieldType=ftUnknown then // if unknown field type encountered, try finding more specific information about the ODBC SQL DataType
     begin
       SetLength(TypeName,TypeNameDefaultLength); // also garantuees uniqueness

+ 1 - 0
packages/fcl-db/tests/sqldbtoolsunit.pas

@@ -225,6 +225,7 @@ begin
       end;
     ssMySQL:
       begin
+      FieldtypeDefinitions[ftWord] := 'SMALLINT UNSIGNED';
       //MySQL recognizes BOOLEAN, but as synonym for TINYINT, not true sql boolean datatype
       FieldtypeDefinitions[ftBoolean]  := '';
       // Use 'DATETIME' for datetime-fields instead of timestamp, because