Skip to content
This repository has been archived by the owner on Aug 12, 2022. It is now read-only.

Commit

Permalink
fix: Issues when PG username is 'cloudquery' (#371)
Browse files Browse the repository at this point in the history
Before this fix, cloudquery misbehaved when the PG username was named 'cloudquery'.
It created tables in the 'cloudquery' schema instead of the 'public' schema.
This happened because the search path was  '"$user", public', which means it depended on the username.

This fix, upon connection to PG, will change serach_path to 'public' only, i.e. not dependent on username (which is way more predictable).

This won't impact us explicitly accessing the 'cloudquery' schema via 'cloudquery.<table-name>', which is what we do when we actually need the 'cloudquery' schema.
  • Loading branch information
shimonp21 authored Jun 24, 2022
1 parent 6f51f6c commit 3317cae
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions database/postgres/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ func Connect(ctx context.Context, dsnURI string) (*pgxpool.Pool, error) {
return nil, dsn.RedactParseError(err)
}
poolCfg.AfterConnect = func(ctx context.Context, conn *pgx.Conn) error {
_, err := conn.Exec(ctx, "SET search_path=public")
if err != nil {
return err
}

UUIDType := pgtype.DataType{
Value: &UUID{},
Name: "uuid",
Expand Down

0 comments on commit 3317cae

Please sign in to comment.