Open chushik opened 8 years ago
codegen.go only checks for strings.ToUpper(f.DefaultValue) == "CURRENT_TIMESTAMP" or strings.ToUpper(f.DefaultValue) == "NOW()" when deciding whether a time column has some default value. See https://github.com/mijia/modelq/blob/master/main.go#L28
strings.ToUpper(f.DefaultValue) == "CURRENT_TIMESTAMP"
strings.ToUpper(f.DefaultValue) == "NOW()"
However, MySql also allows default values like CURRENT_TIMESTAMP(X) and NOW(X) where X is a number. See http://dev.mysql.com/doc/refman/5.7/en/timestamp-initialization.html
CURRENT_TIMESTAMP(X)
NOW(X)
I think code generator should check for matches against ^NOW(?:\\(\\d\\))?$" and "^CURRENT_TIMESTAMP(?:\\(\\d\\))?$"
^NOW(?:\\(\\d\\))?$"
"^CURRENT_TIMESTAMP(?:\\(\\d\\))?$"
En, yeah, that is not considered before. I will verify and fix this later. Or would you like to provide a PR, :P Thank you very much.
yup, I'll try to prepare a PR!
codegen.go only checks for
strings.ToUpper(f.DefaultValue) == "CURRENT_TIMESTAMP"
orstrings.ToUpper(f.DefaultValue) == "NOW()"
when deciding whether a time column has some default value. See https://github.com/mijia/modelq/blob/master/main.go#L28However, MySql also allows default values like
CURRENT_TIMESTAMP(X)
andNOW(X)
where X is a number. See http://dev.mysql.com/doc/refman/5.7/en/timestamp-initialization.htmlI think code generator should check for matches against
^NOW(?:\\(\\d\\))?$"
and"^CURRENT_TIMESTAMP(?:\\(\\d\\))?$"