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 support and test for gen_random_uuid() #3855

Merged
merged 6 commits into from
Feb 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class PostgreSqlTypeResolver(private val parentResolver: TypeResolver) : TypeRes
"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)
"gen_random_uuid" -> IntermediateType(PostgreSqlType.UUID)
else -> null
}

Expand Down
7 changes: 7 additions & 0 deletions dialects/postgresql/src/test/fixtures_postgresql/uuids/Test.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CREATE TABLE uuid_test (
pk uuid
);

SELECT gen_random_uuid(), pk FROM uuid_test;

INSERT INTO uuid_test(pk) SELECT gen_random_uuid();
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CREATE TABLE uuids(
key uuid NOT NULL
);

insertUuid:
INSERT INTO uuids (key) VALUES (:key);

randomUuid:
SELECT gen_random_uuid();
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,9 @@ class PostgreSqlTest {
insertRef(RefTable(RefTable.Id(10), id))
}
}

@Test fun genRandomUuid() {
val uuid = database.datesQueries.randomUuid().executeAsOne()
davidwheeler123 marked this conversation as resolved.
Show resolved Hide resolved
assertThat(uuid).isNotNull()
}
}