Skip to content

Commit 4ae90e6

Browse files
committed
Ensure \copy commands in export.sql are single line
1 parent a5d69d9 commit 4ae90e6

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

src/tasks/dump_db/dump-export.sql.hbs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
BEGIN ISOLATION LEVEL REPEATABLE READ, READ ONLY;
22
{{~#each tables}}
33
{{~#if this.filter}}
4-
\copy (
5-
SELECT {{this.columns}}
6-
FROM "{{this.name}}"
7-
WHERE {{this.filter}}
8-
) TO 'data/{{this.name}}.csv' WITH CSV HEADER
4+
\copy (SELECT {{this.columns}} FROM "{{this.name}}" WHERE {{this.filter}}) TO 'data/{{this.name}}.csv' WITH CSV HEADER
95
{{~else}}
106
\copy "{{this.name}}" ({{this.columns}}) TO 'data/{{this.name}}.csv' WITH CSV HEADER
117
{{~/if}}

src/tasks/dump_db/gen_scripts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ struct TableConfig {
4242
#[derive(Debug, Serialize)]
4343
struct HandlebarsTableContext<'a> {
4444
name: &'a str,
45-
filter: Option<&'a str>,
45+
filter: Option<String>,
4646
columns: String,
4747
column_defaults: BTreeMap<&'a str, &'a str>,
4848
}
@@ -59,7 +59,7 @@ impl TableConfig {
5959
if columns.is_empty() {
6060
None
6161
} else {
62-
let filter = self.filter.as_ref().map(String::as_str);
62+
let filter = self.filter.as_ref().map(|s| s.replace('\n', " "));
6363
let column_defaults = self
6464
.column_defaults
6565
.iter()

0 commit comments

Comments
 (0)