@@ -148,14 +148,14 @@ pub async fn store_table_schema(
148
148
// Insert or update table schema record
149
149
let table_schema_id: i64 = sqlx:: query (
150
150
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,
157
157
updated_at = now()
158
- RETURNING id
158
+ returning id
159
159
"# ,
160
160
)
161
161
. bind ( pipeline_id)
@@ -167,7 +167,7 @@ pub async fn store_table_schema(
167
167
. get ( 0 ) ;
168
168
169
169
// 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" )
171
171
. bind ( table_schema_id)
172
172
. execute ( & mut * tx)
173
173
. await ?;
@@ -178,9 +178,9 @@ pub async fn store_table_schema(
178
178
179
179
sqlx:: query (
180
180
r#"
181
- INSERT INTO etl.table_columns
181
+ insert into etl.table_columns
182
182
(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)
184
184
"# ,
185
185
)
186
186
. bind ( table_schema_id)
@@ -209,7 +209,7 @@ pub async fn load_table_schemas(
209
209
) -> Result < Vec < TableSchema > , sqlx:: Error > {
210
210
let rows = sqlx:: query (
211
211
r#"
212
- SELECT
212
+ select
213
213
ts.table_id,
214
214
ts.schema_name,
215
215
ts.table_name,
@@ -219,10 +219,10 @@ pub async fn load_table_schemas(
219
219
tc.nullable,
220
220
tc.primary_key,
221
221
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
226
226
"# ,
227
227
)
228
228
. bind ( pipeline_id)
0 commit comments