Skip to content

Commit

Permalink
Extract the value in async transactions only
Browse files Browse the repository at this point in the history
  • Loading branch information
hfhbd committed Jul 15, 2023
1 parent d9d8329 commit 2b25be5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,11 @@ abstract class QueryGenerator(
}
}

// Extract value from the result of a grouped statement
if (isNamedQuery && query.statement is SqlDelightStmtClojureStmtList) {
// Extract value from the result of a grouped statement in async,
// because the transaction is put in an QueryResult.AsyncValue block.
if (generateAsync && isNamedQuery && query.statement is SqlDelightStmtClojureStmtList) {
binder += "%L"
if (generateAsync) {
arguments.add(".await()")
} else {
arguments.add(".value")
}
arguments.add(".await()")
}

val statementId = if (needsFreshStatement) CodeBlock.of("null") else CodeBlock.of("%L", id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1784,7 +1784,7 @@ class SelectQueryTypeTest {
| |SELECT value
| | FROM data
| | WHERE id = last_insert_rowid()
| ""${'"'}.trimMargin(), mapper, 0).value
| ""${'"'}.trimMargin(), mapper, 0)
| }
|
| override fun toString(): kotlin.String = "Test.sq:insertAndReturn"
Expand Down

0 comments on commit 2b25be5

Please sign in to comment.