Skip to content

Commit

Permalink
fix inclusion and excusion lists parsing in per db configs
Browse files Browse the repository at this point in the history
  • Loading branch information
orgrim committed Dec 26, 2023
1 parent be759c4 commit 4421dd6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
16 changes: 3 additions & 13 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -696,9 +696,9 @@ func loadConfigurationFile(path string) (options, error) {
}
o.Format = []rune(dbFormat)[0]

o.Schemas = parseIdentifierList(s.Key("schemas").String())
o.ExcludedSchemas = parseIdentifierList(s.Key("exclude_schemas").String())
o.Tables = parseIdentifierList(s.Key("tables").String())
o.Schemas = s.Key("schemas").Strings(",")
o.ExcludedSchemas = s.Key("exclude_schemas").Strings(",")
o.Tables = s.Key("tables").Strings(",")
o.ExcludedTables = s.Key("exclude_tables").Strings(",")

if s.HasKey("pg_dump_options") {
Expand Down Expand Up @@ -727,16 +727,6 @@ func loadConfigurationFile(path string) (options, error) {
return opts, nil
}

func parseIdentifierList(rawList string) []string {
ids := make([]string, 0)
if len(strings.TrimSpace(rawList)) > 0 {
for _, t := range strings.Split(rawList, ";") {
ids = append(ids, strings.TrimSpace(t))
}
}
return ids
}

func mergeCliAndConfigOptions(cliOpts options, configOpts options, onCli []string) options {
opts := configOpts

Expand Down
4 changes: 4 additions & 0 deletions testdata/fixture.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ GRANT CONNECT ON DATABASE b2 TO u2;
SET ROLE u1;
CREATE TABLE t1 AS SELECT generate_series(0, 9) i;
CREATE TABLE t2 AS SELECT generate_series(10, 19) j;
CREATE TABLE t3 AS SELECT generate_series(0, 9) i;
CREATE TABLE t4 AS SELECT generate_series(10, 19) j;

\c b2

SET ROLE u2;
CREATE TABLE t1 AS SELECT generate_series(0, 9) i;
CREATE TABLE t2 AS SELECT generate_series(10, 19) j;
CREATE TABLE t3 AS SELECT generate_series(0, 9) i;
CREATE TABLE t4 AS SELECT generate_series(10, 19) j;

0 comments on commit 4421dd6

Please sign in to comment.