Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

time fields with default value CURRENT_TIMESTAMP(X) in sql are still written to with dont-touch-timestamp=True flag #27

Open
chushik opened this issue Oct 19, 2016 · 2 comments

Comments

@chushik
Copy link

chushik commented Oct 19, 2016

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

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

I think code generator should check for matches against ^NOW(?:\\(\\d\\))?$" and "^CURRENT_TIMESTAMP(?:\\(\\d\\))?$"

@mijia
Copy link
Owner

mijia commented Oct 20, 2016

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.

@chushik
Copy link
Author

chushik commented Oct 20, 2016

yup, I'll try to prepare a PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants