From 21881d8b84ba38e22f26dc82a60360d444df29da Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Thu, 8 Apr 2021 14:12:40 +0800 Subject: [PATCH] MariaDB 10.5 adds a suffix on old datatypes (#1885) MariaDB when encountering an old datetime type will add a suffix of /* mariadb-5.3 */ on its schema information page. Xorm does not understand this and then its mappings fail. The simplest solution is just to remove any fixed suffix and that is what this PR does - a clever solution would look for and remove any comments or match them. See https://mariadb.com/kb/en/time/ for more details about the comment. Related: https://github.com/go-gitea/gitea/issues/15277 Signed-off-by: Andrew Thornton Reviewed-on: https://gitea.com/xorm/xorm/pulls/1885 Reviewed-by: Lunny Xiao Co-authored-by: Andrew Thornton Co-committed-by: Andrew Thornton --- dialects/mysql.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dialects/mysql.go b/dialects/mysql.go index 32e18a17..769e30b1 100644 --- a/dialects/mysql.go +++ b/dialects/mysql.go @@ -353,6 +353,8 @@ func (db *mysql) GetColumns(queryer core.Queryer, ctx context.Context, tableName cts := strings.Split(colType, "(") colName := cts[0] + // Remove the /* mariadb-5.3 */ suffix from coltypes + colName = strings.TrimSuffix(colName, "/* mariadb-5.3 */") colType = strings.ToUpper(colName) var len1, len2 int if len(cts) == 2 {