FinnTew commented on code in PR #930:
URL: 
https://github.com/apache/incubator-seata-go/pull/930#discussion_r2462680459


##########
pkg/datasource/sql/types/sql_data_type.go:
##########
@@ -61,6 +61,46 @@ var SqlDataTypes = map[string]int32{
        "TIMESTAMP_WITH_TIMEZONE": 2014,
 }
 
+// JdbcTypeToMySQLType maps JDBC type codes to MySQL type bytes
+var JdbcTypeToMySQLType = map[int32]byte{
+       -7:   1,   // BIT -> mysql.TypeTiny
+       -6:   1,   // TINYINT -> mysql.TypeTiny
+       5:    2,   // SMALLINT -> mysql.TypeShort
+       4:    3,   // INTEGER -> mysql.TypeLong
+       -5:   8,   // BIGINT -> mysql.TypeLonglong
+       6:    4,   // FLOAT -> mysql.TypeFloat
+       7:    4,   // REAL -> mysql.TypeFloat
+       8:    5,   // DOUBLE -> mysql.TypeDouble
+       2:    246, // NUMERIC -> mysql.TypeNewDecimal
+       3:    246, // DECIMAL -> mysql.TypeNewDecimal
+       1:    254, // CHAR -> mysql.TypeString
+       12:   15,  // VARCHAR -> mysql.TypeVarchar
+       -1:   252, // LONGVARCHAR -> mysql.TypeBlob
+       91:   10,  // DATE -> mysql.TypeDate
+       92:   11,  // TIME -> mysql.TypeDuration
+       93:   7,   // TIMESTAMP -> mysql.TypeTimestamp
+       -2:   254, // BINARY -> mysql.TypeString
+       -3:   15,  // VARBINARY -> mysql.TypeVarchar
+       -4:   252, // LONGVARBINARY -> mysql.TypeBlob
+       2004: 252, // BLOB -> mysql.TypeBlob
+       2005: 252, // CLOB -> mysql.TypeBlob
+       16:   1,   // BOOLEAN -> mysql.TypeTiny
+       -15:  254, // NCHAR -> mysql.TypeString
+       -9:   15,  // NVARCHAR -> mysql.TypeVarchar
+       -16:  252, // LONGNVARCHAR -> mysql.TypeBlob
+       2011: 252, // NCLOB -> mysql.TypeBlob
+       2009: 245, // SQLXML -> mysql.TypeJSON
+}
+
 func GetSqlDataType(dataType string) int32 {
        return SqlDataTypes[strings.ToUpper(dataType)]
 }
+
+// ConvertJdbcTypeToMySQLType converts JDBC type code to MySQL type byte
+func ConvertJdbcTypeToMySQLType(jdbcType int32) byte {
+       if mysqlType, ok := JdbcTypeToMySQLType[jdbcType]; ok {
+               return mysqlType
+       }
+       // Default to VARCHAR for unknown types
+       return 15 // mysql.TypeVarchar

Review Comment:
   There are indeed some issues here, and I will fix them.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to