diff --git a/packages/fcl-db/src/sqldb/odbc/odbcconn.pas b/packages/fcl-db/src/sqldb/odbc/odbcconn.pas index 3d4ec584fb..9420379b2f 100644 --- a/packages/fcl-db/src/sqldb/odbc/odbcconn.pas +++ b/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 diff --git a/packages/fcl-db/tests/sqldbtoolsunit.pas b/packages/fcl-db/tests/sqldbtoolsunit.pas index a78ea2ff7c..687c8b6b36 100644 --- a/packages/fcl-db/tests/sqldbtoolsunit.pas +++ b/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