MCPcopy
hub / github.com/gocraft/dbr / TestPostgresReturning

Function TestPostgresReturning

insert_test.go:27–43  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

25}
26
27func TestPostgresReturning(t *testing.T) {
28 sess := postgresSession
29 reset(t, sess)
30
31 var person dbrPerson
32 err := sess.InsertInto("dbr_people").Columns("name").Record(&person).
33 Returning("id").Load(&person.Id)
34 require.NoError(t, err)
35 require.True(t, person.Id > 0)
36 require.Len(t, sess.EventReceiver.(*testTraceReceiver).started, 1)
37 require.Contains(t, sess.EventReceiver.(*testTraceReceiver).started[0].eventName, "dbr.select")
38 require.Contains(t, sess.EventReceiver.(*testTraceReceiver).started[0].query, "INSERT")
39 require.Contains(t, sess.EventReceiver.(*testTraceReceiver).started[0].query, "dbr_people")
40 require.Contains(t, sess.EventReceiver.(*testTraceReceiver).started[0].query, "name")
41 require.Equal(t, 1, sess.EventReceiver.(*testTraceReceiver).finished)
42 require.Equal(t, 0, sess.EventReceiver.(*testTraceReceiver).errored)
43}
44
45func BenchmarkInsertValuesSQL(b *testing.B) {
46 buf := NewBuffer()

Callers

nothing calls this directly

Calls 6

resetFunction · 0.85
RecordMethod · 0.80
ColumnsMethod · 0.80
InsertIntoMethod · 0.65
LoadMethod · 0.45
ReturningMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…