go-gorm / postgres

GORM PostgreSQL driver
MIT License
234 stars 123 forks source link

varchar类型的默认值处理问题 #136

Closed yuxinyin closed 1 year ago

yuxinyin commented 2 years ago

GORM Playground Link

https://github.com/go-gorm/playground/pull/1

Description

问题代码: gorm.io/driver/postgres@v1.4.4/migrator.go:418

原因:

字段: "country" varchar(4) DEFAULT 'CN'

读取到的值: column.DefaultValueValue = "'CN'::character varying"

修复建议:

修改正则匹配空格

'(.*)'::[\w]+$ => '(.*)'::[\w\s]+$

yuxinyin commented 1 year ago

148