Skip to content

Commit

Permalink
Merge pull request #914 from soyayaos/master
Browse files Browse the repository at this point in the history
fix: postgresql search_path can be empty (#696)
  • Loading branch information
dhui committed Apr 7, 2023
2 parents e968557 + ddaf669 commit 84009cf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions database/postgres/postgres.go
Expand Up @@ -90,16 +90,16 @@ func WithConnection(ctx context.Context, conn *sql.Conn, config *Config) (*Postg

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

if len(schemaName) == 0 {
if !schemaName.Valid {
return nil, ErrNoSchema
}

config.SchemaName = schemaName
config.SchemaName = schemaName.String
}

if len(config.MigrationsTable) == 0 {
Expand Down

0 comments on commit 84009cf

Please sign in to comment.