-
Notifications
You must be signed in to change notification settings - Fork 540
Support MySql INTERVAL #3074
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
Support MySql INTERVAL #3074
Conversation
@@ -63,6 +63,7 @@ internal class MySqlTypeResolver( | |||
"unix_timestamp" -> IntermediateType(TEXT) | |||
"to_seconds" -> IntermediateType(INTEGER) | |||
"json_arrayagg" -> IntermediateType(TEXT) | |||
"date_add", "date_sub" -> encapsulatingType(exprList, TEXT, MySqlType.TIME, MySqlType.DATE, MySqlType.DATETIME, MySqlType.TIMESTAMP) |
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.
Not fully sure about how this works, i.e. should it just return IntermediateType(TEXT)
?
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.
you give it a list of types where if you have two types in the expression list it will pick the type closer to the front of the list. So I think this is good. I mean if tests pass you probably did it right
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.
Looks like the integration test is failing but I can't see what the failure is, and I can't run it locally (something about docker not being detected)
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.
yea you need docker to run the integration tests, it's pretty easy to set up if you're keane to try it locally.
You can see test reports on CI by downloading the build report at the bottom here
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.
I have docker installed but I didn't want to go down the rabbit hole debugging why it wasn't working 😅
In any case I think I misunderstood how the functions work. It looks like the rules for what gets returned might be a little too complicated for SQLDelight to infer.
The options I can think of are:
- Return
TEXT
- If it's possible to rewrite the arguments, always casting it to a
DATETIME
will ensure that aDATETIME
is always returned
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.
i think just returning text for now is fine
1f801d7
to
a66218b
Compare
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.
really nice
@@ -71,4 +79,26 @@ class MySqlTest { | |||
) | |||
) | |||
} | |||
|
|||
@Test | |||
fun testDates() { |
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.
awesome
@@ -63,6 +63,7 @@ internal class MySqlTypeResolver( | |||
"unix_timestamp" -> IntermediateType(TEXT) | |||
"to_seconds" -> IntermediateType(INTEGER) | |||
"json_arrayagg" -> IntermediateType(TEXT) | |||
"date_add", "date_sub" -> encapsulatingType(exprList, TEXT, MySqlType.TIME, MySqlType.DATE, MySqlType.DATETIME, MySqlType.TIMESTAMP) |
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.
you give it a list of types where if you have two types in the expression list it will pick the type closer to the front of the list. So I think this is good. I mean if tests pass you probably did it right
965ed72
to
7f0b846
Compare
7f0b846
to
6b29318
Compare
Closes #2969