Skip to content

Commit 566b962

Browse files
committed
Fixed insert not being able to return a single column
1 parent c71961f commit 566b962

4 files changed

Lines changed: 12 additions & 3 deletions

File tree

Sources/Compiler/Gen/SwiftLanguage.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ public struct SwiftLanguage: Language {
591591
writer.blankLine()
592592
writer.write(line: "func execute(")
593593
writeInput()
594-
writer.write(", tx: borrowing Transaction) async throws -> Output ")
594+
writer.write(", tx: borrowing Transaction) throws -> Output ")
595595

596596
writer.braces {
597597
writer.write(line: "try execute(with: ", query.inputName, "(")

Sources/Compiler/Sema/StmtTypeChecker.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ extension StmtTypeChecker {
543543
return .empty
544544
}
545545

546-
usedTableNames.insert(table.name.name)
546+
importTable(table)
547547

548548
// If there is an error upstream that will cause unification to fail for sure
549549
// we can just skip it so the real error does not get hidden by all the other errors

Tests/CompilerTests/Compiler/CompileInsert.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,12 @@ INSERT INTO user (id, name) VALUES (?, ?)
158158
ON CONFLICT (id) DO UPDATE
159159
SET name = excluded.name
160160
WHERE excluded.name = 'bob';
161+
162+
-- CHECK: SIGNATURE
163+
-- CHECK: OUTPUT_CHUNKS
164+
-- CHECK: CHUNK
165+
-- CHECK: OUTPUT
166+
-- CHECK: id INTEGER
167+
-- CHECK: TABLES
168+
-- CHECK: user
169+
INSERT INTO user (name) VALUES ('joe') RETURNING id;

Tests/CompilerTests/CompilerTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class CompilerTests: XCTestCase {
1919
}
2020

2121
func testInsert() throws {
22-
try checkQueries(compile: "CompileInsert")
22+
try checkQueries(compile: "CompileInsert", dump: true)
2323
}
2424

2525
func testUpdate() throws {

0 commit comments

Comments
 (0)