MCPcopy Create free account
hub / github.com/PostHog/duckgres / TestDMLUpdateReturning

Function TestDMLUpdateReturning

tests/integration/dml_test.go:244–272  ·  view source on GitHub ↗

TestDMLUpdateReturning tests UPDATE ... RETURNING

(t *testing.T)

Source from the content-addressed store, hash-verified

242
243// TestDMLUpdateReturning tests UPDATE ... RETURNING
244func TestDMLUpdateReturning(t *testing.T) {
245 mustExec(t, testHarness.DuckgresDB, "CREATE TABLE dml_update_returning (id INTEGER, name TEXT, version INTEGER)")
246 mustExec(t, testHarness.DuckgresDB, "INSERT INTO dml_update_returning VALUES (1, 'Test', 1)")
247
248 t.Run("update_returning_star", func(t *testing.T) {
249 skipIfKnown(t)
250 rows, err := testHarness.DuckgresDB.Query("UPDATE dml_update_returning SET version = version + 1 WHERE id = 1 RETURNING *")
251 if err != nil {
252 t.Fatalf("Update RETURNING failed: %v", err)
253 }
254 defer func() { _ = rows.Close() }()
255
256 if !rows.Next() {
257 t.Error("Expected 1 row returned")
258 }
259 var id int
260 var name string
261 var version int
262 if err := rows.Scan(&id, &name, &version); err != nil {
263 t.Fatalf("Scan failed: %v", err)
264 }
265 if version != 2 {
266 t.Errorf("Expected version=2, got %d", version)
267 }
268 })
269
270 // Cleanup
271 mustExec(t, testHarness.DuckgresDB, "DROP TABLE IF EXISTS dml_update_returning")
272}
273
274// TestDMLUpdateFromJoin tests UPDATE with FROM clause (join)
275func TestDMLUpdateFromJoin(t *testing.T) {

Callers

nothing calls this directly

Calls 8

mustExecFunction · 0.85
skipIfKnownFunction · 0.85
RunMethod · 0.65
QueryMethod · 0.65
CloseMethod · 0.65
NextMethod · 0.65
ScanMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected