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

Add NOW() to PostgreSQL #3403

Merged
merged 1 commit into from Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -86,6 +86,7 @@ class PostgreSqlTypeResolver(private val parentResolver: TypeResolver) : TypeRes
"max" -> encapsulatingType(exprList, SMALL_INT, PostgreSqlType.INTEGER, INTEGER, BIG_INT, REAL, TEXT, BLOB).asNullable()
"min" -> encapsulatingType(exprList, BLOB, TEXT, SMALL_INT, INTEGER, PostgreSqlType.INTEGER, BIG_INT, REAL).asNullable()
"date_trunc" -> encapsulatingType(exprList, TIMESTAMP_TIMEZONE, TIMESTAMP)
"now" -> IntermediateType(TIMESTAMP_TIMEZONE)
else -> null
}

Expand Down
@@ -0,0 +1,5 @@
CREATE TABLE foo (
bar TIMESTAMPTZ NOT NULL
);

SELECT NOW() AS now, date_trunc('hour', bar) AS d FROM foo;
Expand Up @@ -12,3 +12,6 @@ RETURNING *;

selectDateTrunc:
SELECT date_trunc('hour', timestamp), date_trunc('hour', timestamp_with_timezone) FROM dates;

selectNow:
SELECT NOW();
Expand Up @@ -126,6 +126,12 @@ class PostgreSqlTest {
}
}

@Test fun now() {
val now = database.datesQueries.selectNow().executeAsOne()
assertThat(now).isNotNull()
assertThat(now).isGreaterThan(OffsetDateTime.MIN)
}

@Test fun successfulOptimisticLock() {
with(database.withLockQueries) {
val row = insertText("sup").executeAsOne()
Expand Down