Skip to content

Commit ddaf669

Browse files
committed
fix: postgresql search_path can be empty (#696)
1 parent e968557 commit ddaf669

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

database/postgres/postgres.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,16 @@ func WithConnection(ctx context.Context, conn *sql.Conn, config *Config) (*Postg
9090

9191
if config.SchemaName == "" {
9292
query := `SELECT CURRENT_SCHEMA()`
93-
var schemaName string
93+
var schemaName sql.NullString
9494
if err := conn.QueryRowContext(ctx, query).Scan(&schemaName); err != nil {
9595
return nil, &database.Error{OrigErr: err, Query: []byte(query)}
9696
}
9797

98-
if len(schemaName) == 0 {
98+
if !schemaName.Valid {
9999
return nil, ErrNoSchema
100100
}
101101

102-
config.SchemaName = schemaName
102+
config.SchemaName = schemaName.String
103103
}
104104

105105
if len(config.MigrationsTable) == 0 {

0 commit comments

Comments
 (0)