Skip to content

Commit

Permalink
🔧 Add support for --table flag
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Jul 14, 2021
1 parent 18907e1 commit 26e9071
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cmd/dump/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var (
ifExists bool
clean bool
noOwner bool
tables []string
excludeTable []string
excludeTableData []string
)
Expand All @@ -50,6 +51,7 @@ func init() {
Command.Flags().BoolVar(&ifExists, "if-exists", true, "use IF EXISTS when dropping objects")
Command.Flags().BoolVarP(&clean, "clean", "c", true, "clean (drop) database objects before recreating")
Command.Flags().BoolVarP(&noOwner, "no-owner", "O", true, "skip restoration of object ownership in plain-text format")
Command.Flags().StringSliceVarP(&tables, "table", "t", []string{}, "dump the specified table(s) only")
Command.Flags().StringSliceVarP(&excludeTable, "exclude-table", "T", []string{}, "do NOT dump the specified table(s)")
Command.Flags().StringSliceVar(&excludeTableData, "exclude-table-data", []string{}, "do NOT dump data for the specified table(s)")
}
Expand Down Expand Up @@ -178,11 +180,14 @@ func buildCommand() []string {
if ifExists {
cmd = append(cmd, "--if-exists")
}
for _, table := range tables {
cmd = append(cmd, "--table="+table)
}
for _, table := range excludeTable {
cmd = append(cmd, "--exclude-table=" + table)
cmd = append(cmd, "--exclude-table="+table)
}
for _, table := range excludeTableData {
cmd = append(cmd, "--exclude-table-data=" + table)
cmd = append(cmd, "--exclude-table-data="+table)
}
if outputFormat == sqlformat.Custom {
cmd = append(cmd, "--format=c")
Expand Down

0 comments on commit 26e9071

Please sign in to comment.