Skip to content

feat: handle unsigned types#80

Merged
Mandukhai-Alimaa merged 2 commits intoadbc-drivers:mainfrom
tokoko:extension-types
Mar 17, 2026
Merged

feat: handle unsigned types#80
Mandukhai-Alimaa merged 2 commits intoadbc-drivers:mainfrom
tokoko:extension-types

Conversation

@tokoko
Copy link
Copy Markdown
Contributor

@tokoko tokoko commented Mar 15, 2026

adds handling for unsigned types:

  • for data queries, the issue was that go sql driver flips type names, it uses UNSIGNED INT instead of INT UNSIGNED and we have to flip it back.
  • for metadata queries, DataType column from information schema doesn't contain information about signed/unsigned. we have to get that additional information from ColumnType field.

@tokoko tokoko requested a review from lidavidm as a code owner March 15, 2026 10:19
// Build the full type name including UNSIGNED if applicable
xdbcTypeName := tc.DataType
if strings.Contains(strings.ToUpper(tc.ColumnType), "UNSIGNED") {
xdbcTypeName = tc.DataType + " unsigned"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
xdbcTypeName = tc.DataType + " unsigned"
xdbcTypeName = tc.DataType + " UNSIGNED"

go/connection.go Outdated
Comment on lines +85 to +174
@@ -95,6 +96,7 @@ func (c *mysqlConnectionImpl) GetTableSchema(ctx context.Context, catalog *strin
ORDINAL_POSITION,
COLUMN_NAME,
DATA_TYPE,
COLUMN_TYPE,
IS_NULLABLE,
CHARACTER_MAXIMUM_LENGTH,
NUMERIC_PRECISION,
@@ -132,6 +134,7 @@ func (c *mysqlConnectionImpl) GetTableSchema(ctx context.Context, catalog *strin
&col.OrdinalPosition,
&col.ColumnName,
&col.DataType,
&col.ColumnType,
&col.IsNullable,
&col.CharacterMaximumLength,
&col.NumericPrecision,
@@ -166,9 +169,15 @@ func (c *mysqlConnectionImpl) GetTableSchema(ctx context.Context, catalog *strin
scale = &col.NumericScale.Int64
}

// Use DATA_TYPE but append UNSIGNED if COLUMN_TYPE indicates it
dbTypeName := col.DataType
if strings.Contains(strings.ToUpper(col.ColumnType), "UNSIGNED") {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check may be too broad in the INFORMATION_SCHEMA paths (in both GetTableSchema and getTablesWithColumns). MySQL's COLUMN_TYPE includes enum/set value lists, so enum('unsigned','signed','pending') will match and incorrectly become "ENUM UNSIGNED". We should probably gate the logic to integer DATA_TYPEs only (TINYINT, SMALLINT, MEDIUMINT, INT, INTEGER, BIGINT) to prevent false positives.

Copy link
Copy Markdown
Contributor

@Mandukhai-Alimaa Mandukhai-Alimaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks

@Mandukhai-Alimaa Mandukhai-Alimaa merged commit 7588372 into adbc-drivers:main Mar 17, 2026
12 checks passed
@tokoko
Copy link
Copy Markdown
Contributor Author

tokoko commented Mar 18, 2026

thanks for the review. that was a good catch.

@tokoko tokoko deleted the extension-types branch March 21, 2026 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants