MCPcopy
hub / github.com/jmoiron/sqlx / TestScanError

Function TestScanError

sqlx_test.go:866–898  ·  sqlx_test.go::TestScanError
(t *testing.T)

Source from the content-addressed store, hash-verified

864}
865
866func TestScanError(t *testing.T) {
867 var schema = Schema{
868 create: `
869 CREATE TABLE kv (
870 k text,
871 v integer
872 );`,
873 drop: `drop table kv;`,
874 }
875
876 RunWithSchema(schema, t, func(db *DB, t *testing.T, now string) {
877 type WrongTypes struct {
878 K int
879 V string
880 }
881 _, err := db.Exec(db.Rebind("INSERT INTO kv (k, v) VALUES (?, ?)"), "hi", 1)
882 if err != nil {
883 t.Error(err)
884 }
885
886 rows, err := db.Queryx("SELECT * FROM kv")
887 if err != nil {
888 t.Error(err)
889 }
890 for rows.Next() {
891 var wt WrongTypes
892 err := rows.StructScan(&wt)
893 if err == nil {
894 t.Errorf("%s: Scanning wrong types into keys should have errored.", db.DriverName())
895 }
896 }
897 })
898}
899
900func TestMultiInsert(t *testing.T) {
901 RunWithSchema(defaultSchema, t, func(db *DB, t *testing.T, now string) {

Callers

nothing calls this directly

Calls 9

RunWithSchemaFunction · 0.85
ErrorMethod · 0.80
NextMethod · 0.80
ErrorfMethod · 0.80
ExecMethod · 0.65
RebindMethod · 0.65
QueryxMethod · 0.65
DriverNameMethod · 0.65
StructScanMethod · 0.45

Tested by

no test coverage detected