-
Notifications
You must be signed in to change notification settings - Fork 515
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
Add PostgreSql temporal types to SqlBinaryExpr #4657
Conversation
f79f1b6
to
6b77da1
Compare
0736643
to
ba80c52
Compare
ba80c52
to
71dff65
Compare
71dff65
to
150e143
Compare
For encapsulatingType allow expressions to return temporal types PostgreSqlType.INTERVAL, PostgreSqlType.TIMESTAMP_TIMEZONE PostgreSqlType.TIMESTAMP e.g 31 * INTERVAL '1 minute' + INTERVAL '2 days' Timestamp should be ordered last When binary expression contains TIMESTAMP and INTERVAL, TIMESTAMP must be selected
Extend the existing tests with binary expressions
150e143
to
764338d
Compare
@@ -252,12 +252,31 @@ class PostgreSqlTest { | |||
assertThat(now).isGreaterThan(OffsetDateTime.MIN) | |||
} | |||
|
|||
@Test fun nowPlusInterval() { |
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.
Minor, you could also use SELECT NOW(), NOW() + INTERVAL '1 day'
and compare the two values in Java/Kotlin.
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.
Ok - have compared now plus 1 > now
@Test fun interval() { | ||
val interval = database.datesQueries.selectInterval().executeAsOne() | ||
assertThat(interval).isNotNull() | ||
assertThat(interval.getDays()).isEqualTo(1) | ||
} | ||
|
||
@Test fun intervalBinaryMultiplyExpression() { |
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.
Nice!
Check that now + 1 is greater than now
* Update PostgreSqlTypeResolver temporal type For encapsulatingType allow expressions to return temporal types PostgreSqlType.INTERVAL, PostgreSqlType.TIMESTAMP_TIMEZONE PostgreSqlType.TIMESTAMP e.g 31 * INTERVAL '1 minute' + INTERVAL '2 days' Timestamp should be ordered last When binary expression contains TIMESTAMP and INTERVAL, TIMESTAMP must be selected * Add PostgreSql integration tests Extend the existing tests with binary expressions * Change test to compare two intervals Check that now + 1 is greater than now
Add some missing support for binary expressions with temporal types:
TIMESTAMP is added last to the type-order as it needs to be the result of a binary expression containing a TIMESTAMP and INTERVAL
Examples