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 Sep 19, 2023
1 parent 9cc70d9 commit 9fbc84b
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 @@ -2,7 +2,6 @@ package app.cash.sqldelight.dialects.postgresql

import app.cash.sqldelight.dialect.api.DialectType
import app.cash.sqldelight.dialect.api.IntermediateType
import app.cash.sqldelight.dialect.api.PrimitiveType
import app.cash.sqldelight.dialect.api.PrimitiveType.BLOB
import app.cash.sqldelight.dialect.api.PrimitiveType.BOOLEAN
import app.cash.sqldelight.dialect.api.PrimitiveType.INTEGER
Expand Down Expand Up @@ -164,6 +163,7 @@ class PostgreSqlTypeResolver(private val parentResolver: TypeResolver) : TypeRes
-> IntermediateType(TEXT)
"json_array_length", "jsonb_array_length" -> IntermediateType(INTEGER)
"jsonb_path_exists", "jsonb_path_match", "jsonb_path_exists_tz", "jsonb_path_match_tz" -> IntermediateType(BOOLEAN)
"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 @@ -458,5 +458,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 9fbc84b

Please sign in to comment.