diff --git a/backends/clickhouse/column.go b/backends/clickhouse/column.go index 14ad089..6628be6 100644 --- a/backends/clickhouse/column.go +++ b/backends/clickhouse/column.go @@ -403,7 +403,10 @@ type SDecimalColumn struct { // ColType implementation of SDecimalColumn for IColumnSpec func (c *SDecimalColumn) ColType() string { str := c.SClickhouseBaseColumn.ColType() - return fmt.Sprintf("%s(%d, %d)", str, c.width, c.Precision) + if str == "Decimal" { + return fmt.Sprintf("%s(%d, %d)", str, c.width, c.Precision) + } + return fmt.Sprintf("%s(%d)", str, c.Precision) } // IsNumeric implementation of SDecimalColumn for IColumnSpec diff --git a/backends/clickhouse/columninfo.go b/backends/clickhouse/columninfo.go index 42475cd..75ed274 100644 --- a/backends/clickhouse/columninfo.go +++ b/backends/clickhouse/columninfo.go @@ -83,6 +83,14 @@ func (info *sSqlColumnInfo) getTagmap() map[string]string { } tagmap[sqlchemy.TAG_DEFAULT] = defVal } + sqlType := info.getType() + if strings.HasPrefix(sqlType, "Decimal") { + re := regexp.MustCompile(`Decimal\((\d+),\s*(\d+)\)`) + match := re.FindStringSubmatch(sqlType) + if len(match) == 3 { + tagmap[sqlchemy.TAG_WIDTH], tagmap[sqlchemy.TAG_PRECISION] = match[1], match[2] + } + } return tagmap }