Skip to content

Commit

Permalink
add function setval
Browse files Browse the repository at this point in the history
add test
  • Loading branch information
griffio committed Aug 15, 2023
1 parent a65ae4e commit 7d8fc9c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class PostgreSqlTypeResolver(private val parentResolver: TypeResolver) : TypeRes
"regr_count" -> IntermediateType(BIG_INT).asNullable()
"gen_random_uuid" -> IntermediateType(PostgreSqlType.UUID)
"length", "character_length", "char_length" -> IntermediateType(PostgreSqlType.INTEGER).nullableIf(resolvedType(exprList[0]).javaType.isNullable)
"currval", "lastval", "nextval" -> IntermediateType(BIG_INT)
"currval", "lastval", "nextval", "setval" -> IntermediateType(BIG_INT)
else -> null
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ SELECT currval('serial');

selectLastVal:
SELECT lastval();

selectSetVal:
SELECT setval('serial', 200, TRUE);
Original file line number Diff line number Diff line change
Expand Up @@ -336,5 +336,8 @@ class PostgreSqlTest {
val selectNextVal = database.sequencesQueries.selectNextVal().executeAsOne()
val lastVal = database.sequencesQueries.selectLastVal().executeAsOne()
assertThat(selectNextVal).isEqualTo(lastVal)

val selectSetVal = database.sequencesQueries.selectSetVal().executeAsOne()
assertThat(selectSetVal).isEqualTo(nextVal)
}
}

0 comments on commit 7d8fc9c

Please sign in to comment.