mirror of
https://github.com/jackc/pgx.git
synced 2025-05-31 11:42:24 +00:00
ParseConfig: default_query_exec_mode: Return arg in error
If the default_query_exec_mode is unknown, the returned error previously was: invalid default_query_exec_mode: <nil> This changes it to return the argument. Add a test that unknown modes fail to parse and include this string.
This commit is contained in:
parent
11d892dfcf
commit
9de41fac75
2
conn.go
2
conn.go
@ -178,7 +178,7 @@ func ParseConfigWithOptions(connString string, options ParseConfigOptions) (*Con
|
|||||||
case "simple_protocol":
|
case "simple_protocol":
|
||||||
defaultQueryExecMode = QueryExecModeSimpleProtocol
|
defaultQueryExecMode = QueryExecModeSimpleProtocol
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("invalid default_query_exec_mode: %v", err)
|
return nil, fmt.Errorf("invalid default_query_exec_mode: %s", s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
15
conn_test.go
15
conn_test.go
@ -197,6 +197,21 @@ func TestParseConfigExtractsDefaultQueryExecMode(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestParseConfigErrors(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
for _, tt := range []struct {
|
||||||
|
connString string
|
||||||
|
expectedErrSubstring string
|
||||||
|
}{
|
||||||
|
{"default_query_exec_mode=does_not_exist", "does_not_exist"},
|
||||||
|
} {
|
||||||
|
config, err := pgx.ParseConfig(tt.connString)
|
||||||
|
require.Nil(t, config)
|
||||||
|
require.ErrorContains(t, err, tt.expectedErrSubstring)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestExec(t *testing.T) {
|
func TestExec(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user