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:
committed by
Jack Christensen
parent
11d892dfcf
commit
9de41fac75
@@ -178,7 +178,7 @@ func ParseConfigWithOptions(connString string, options ParseConfigOptions) (*Con
|
||||
case "simple_protocol":
|
||||
defaultQueryExecMode = QueryExecModeSimpleProtocol
|
||||
default:
|
||||
return nil, fmt.Errorf("invalid default_query_exec_mode: %v", err)
|
||||
return nil, fmt.Errorf("invalid default_query_exec_mode: %s", s)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user