Dialect::MySQL::GetColumns() raise "Unknown colType" as of MySQL 8.0.17 #1604

Open
opened 2020-03-13 13:34:07 +00:00 by joelBai · 3 comments
Contributor

As of MySQL 8.0.17, the display width attribute is deprecated for integer data types.

See MySQL 8.0 Reference Manual - 11.1.1 Numeric Data Type Syntax.

So the code below in dialect_mysql.go parse COLUMN_TYPE wrong(expect tinyint(4) unsigned but got tinyint unsigned):

cts := strings.Split(colType, "(")
colName := cts[0]

Looks like need more code like this:

if colType == "FLOAT UNSIGNED" {
colType = "FLOAT"
}
if colType == "DOUBLE UNSIGNED" {
colType = "DOUBLE"
}
As of MySQL 8.0.17, the display width attribute is deprecated for integer data types. See [MySQL 8.0 Reference Manual - 11.1.1 Numeric Data Type Syntax](https://dev.mysql.com/doc/refman/8.0/en/numeric-type-syntax.html). So the code below in `dialect_mysql.go` parse `COLUMN_TYPE` wrong(expect `tinyint(4) unsigned` but got `tinyint unsigned`): ``` cts := strings.Split(colType, "(") colName := cts[0] ``` Looks like need more code like this: ``` if colType == "FLOAT UNSIGNED" { colType = "FLOAT" } if colType == "DOUBLE UNSIGNED" { colType = "DOUBLE" } ```
joelBai changed title from Dialect:MySQL::GetColumns() raise "Unknown colType" as of MySQL 8.0.17 to Dialect::MySQL::GetColumns() raise "Unknown colType" as of MySQL 8.0.17 2020-03-13 13:34:25 +00:00
lunny added the
kind
enhancement
label 2020-03-13 15:53:02 +00:00
Contributor

xorm v1.2.5 golang 1.17

Unknown colType UNSIGNED FLOAT/DOUBLE/DECIMAL in mysql

xorm v1.2.5 golang 1.17 > Unknown colType UNSIGNED FLOAT/DOUBLE/DECIMAL in mysql
Contributor

FILE dialects/mysql.go LINE 486

		if isUnsigned {
			colType = "UNSIGNED " + colType
		}

Change to:

		if isUnsigned && (colType == "BIT" || strings.HasSuffix(colType, "INT")) {
			colType = "UNSIGNED " + colType
		}
FILE dialects/mysql.go LINE 486 ```go if isUnsigned { colType = "UNSIGNED " + colType } ``` Change to: ```go if isUnsigned && (colType == "BIT" || strings.HasSuffix(colType, "INT")) { colType = "UNSIGNED " + colType } ```
Owner

FILE dialects/mysql.go LINE 486

		if isUnsigned {
			colType = "UNSIGNED " + colType
		}

Change to:

		if isUnsigned && (colType == "BIT" || strings.HasSuffix(colType, "INT")) {
			colType = "UNSIGNED " + colType
		}

Could you send a PR with some tests?

> FILE dialects/mysql.go LINE 486 > ```go > if isUnsigned { > colType = "UNSIGNED " + colType > } > ``` > Change to: > ```go > if isUnsigned && (colType == "BIT" || strings.HasSuffix(colType, "INT")) { > colType = "UNSIGNED " + colType > } > ``` > Could you send a PR with some tests?
Sign in to join this conversation.
No Milestone
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: xorm/xorm#1604
No description provided.