From 4bdc528744e1ca915ebf428269d67ffe11f200b9 Mon Sep 17 00:00:00 2001 From: Azareal Date: Mon, 13 Jul 2020 16:53:04 +1000 Subject: [PATCH] remove arbitrary restrictions on text fields in MysqlAdapter.SetDefaultColumn save allocs in mysql query adapter --- query_gen/mysql.go | 56 +++++++++++++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 16 deletions(-) diff --git a/query_gen/mysql.go b/query_gen/mysql.go index 41ccb996..80fab7ab 100644 --- a/query_gen/mysql.go +++ b/query_gen/mysql.go @@ -123,10 +123,14 @@ func (a *MysqlAdapter) CreateTable(name, table, charset, collation string, colum q += "," } else { q += "(" - for _, column := range strings.Split(key.Columns, ",") { - q += "`" + column + "`," + for i, column := range strings.Split(key.Columns, ",") { + if i != 0 { + q += ",`" + column + "`" + } else { + q += "`" + column + "`" + } } - q = q[0:len(q)-1] + ")," + q += ")," } } } @@ -167,9 +171,6 @@ func (a *MysqlAdapter) ChangeColumn(name, table, colName string, col DBTableColu } func (a *MysqlAdapter) SetDefaultColumn(name, table, colName, colType, defaultStr string) (string, error) { - if colType == "text" { - return "", errors.New("text fields cannot have default values") - } if defaultStr == "" { defaultStr = "''" } @@ -799,10 +800,10 @@ func (a *MysqlAdapter) buildFlexiWhereSb(sb *strings.Builder, where string, date sb.WriteString(dateCutoff.Unit) sb.WriteString(") AND UTC_TIMESTAMP()") case 11: - sb.WriteString(" < UTC_TIMESTAMP()-interval ? ") + sb.WriteString("