-
Notifications
You must be signed in to change notification settings - Fork 228
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
Fix coerce to date #308
Fix coerce to date #308
Conversation
CLA is valid! |
This should fix #292 |
LGTM. Should we add an integration test to make sure this doesn't get mangled somewhere else? |
👍 |
@DeathByTape As I was adding the integration tests, more problem reveals. Turns out I can construct a date from long, but when it is serialized through hibernate, the value stored in db will carry an implicit timezone. For example, for timestamp |
@@ -70,6 +74,9 @@ public Converter lookup(Class<?> sourceType, Class<?> targetType) { | |||
return TO_ENUM_CONVERTER; | |||
} else if (Map.class.isAssignableFrom(sourceType)) { | |||
return FROM_MAP_CONVERTER; | |||
} else if ((String.class.isAssignableFrom(sourceType) || Long.class.isAssignableFrom(sourceType)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xiaoyao1991 @DeathByTape I've found a bug here. If you try to create entity with date field and set value to 1970-01-01 (timestamp is -14400000 in my time zone) it will be automactically converted into Integer
object, not Long
inside elide because the value is too small and it seems like the smallest allowed number type is selected on conversion. Then it will miss this if branch and wrong date converter will be chosen.
No description provided.