Skip to content

Commit 70337ce

Browse files
authored
ref(sql): Make queries lowercase (#298)
1 parent c314294 commit 70337ce

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

etl-postgres/src/replication/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub async fn get_table_name_from_oid(
4646
let query = "
4747
select n.nspname as schema_name, c.relname as table_name
4848
from pg_class c
49-
join pg_namespace n ON c.relnamespace = n.oid
49+
join pg_namespace n on c.relnamespace = n.oid
5050
where c.oid = $1
5151
";
5252

etl-postgres/src/replication/schema.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,14 @@ pub async fn store_table_schema(
148148
// Insert or update table schema record
149149
let table_schema_id: i64 = sqlx::query(
150150
r#"
151-
INSERT INTO etl.table_schemas (pipeline_id, table_id, schema_name, table_name)
152-
VALUES ($1, $2, $3, $4)
153-
ON CONFLICT (pipeline_id, table_id)
154-
DO UPDATE SET
155-
schema_name = EXCLUDED.schema_name,
156-
table_name = EXCLUDED.table_name,
151+
insert into etl.table_schemas (pipeline_id, table_id, schema_name, table_name)
152+
values ($1, $2, $3, $4)
153+
on conflict (pipeline_id, table_id)
154+
do update set
155+
schema_name = excluded.schema_name,
156+
table_name = excluded.table_name,
157157
updated_at = now()
158-
RETURNING id
158+
returning id
159159
"#,
160160
)
161161
.bind(pipeline_id)
@@ -167,7 +167,7 @@ pub async fn store_table_schema(
167167
.get(0);
168168

169169
// Delete existing columns for this table schema to handle schema changes
170-
sqlx::query("DELETE FROM etl.table_columns WHERE table_schema_id = $1")
170+
sqlx::query("delete from etl.table_columns where table_schema_id = $1")
171171
.bind(table_schema_id)
172172
.execute(&mut *tx)
173173
.await?;
@@ -178,9 +178,9 @@ pub async fn store_table_schema(
178178

179179
sqlx::query(
180180
r#"
181-
INSERT INTO etl.table_columns
181+
insert into etl.table_columns
182182
(table_schema_id, column_name, column_type, type_modifier, nullable, primary_key, column_order)
183-
VALUES ($1, $2, $3, $4, $5, $6, $7)
183+
values ($1, $2, $3, $4, $5, $6, $7)
184184
"#,
185185
)
186186
.bind(table_schema_id)
@@ -209,7 +209,7 @@ pub async fn load_table_schemas(
209209
) -> Result<Vec<TableSchema>, sqlx::Error> {
210210
let rows = sqlx::query(
211211
r#"
212-
SELECT
212+
select
213213
ts.table_id,
214214
ts.schema_name,
215215
ts.table_name,
@@ -219,10 +219,10 @@ pub async fn load_table_schemas(
219219
tc.nullable,
220220
tc.primary_key,
221221
tc.column_order
222-
FROM etl.table_schemas ts
223-
INNER JOIN etl.table_columns tc ON ts.id = tc.table_schema_id
224-
WHERE ts.pipeline_id = $1
225-
ORDER BY ts.table_id, tc.column_order
222+
from etl.table_schemas ts
223+
inner join etl.table_columns tc on ts.id = tc.table_schema_id
224+
where ts.pipeline_id = $1
225+
order by ts.table_id, tc.column_order
226226
"#,
227227
)
228228
.bind(pipeline_id)

etl-postgres/src/replication/table_mappings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub async fn store_table_mapping(
1919
values ($1, $2, $3)
2020
on conflict (pipeline_id, source_table_id)
2121
do update set
22-
destination_table_id = EXCLUDED.destination_table_id,
22+
destination_table_id = excluded.destination_table_id,
2323
updated_at = now()
2424
"#,
2525
)

0 commit comments

Comments
 (0)