Skip to content

Commit 421fd80

Browse files
committed
fix/remove-quote
1 parent 3b642e2 commit 421fd80

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/ops/targets/postgres.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,8 @@ fn to_column_type_sql(column_type: &ValueType) -> String {
356356

357357
fn qualified_table_name(table_id: &TableId) -> String {
358358
match &table_id.schema {
359-
Some(schema) => format!("\"{}\".\"{}\"", schema, table_id.table_name),
360-
None => format!("\"{}\"", table_id.table_name),
359+
Some(schema) => format!("\"{}\".{}", schema, table_id.table_name),
360+
None => table_id.table_name.clone(),
361361
}
362362
}
363363

@@ -571,12 +571,6 @@ impl setup::ResourceSetupChange for SetupChange {
571571

572572
impl SetupChange {
573573
async fn apply_change(&self, db_pool: &PgPool, table_id: &TableId) -> Result<()> {
574-
// Create schema if specified
575-
if let Some(schema) = &table_id.schema {
576-
let sql = format!("CREATE SCHEMA IF NOT EXISTS \"{}\"", schema);
577-
sqlx::query(&sql).execute(db_pool).await?;
578-
}
579-
580574
let table_name = qualified_table_name(table_id);
581575

582576
if self.actions.table_action.drop_existing {
@@ -596,6 +590,12 @@ impl SetupChange {
596590
if let Some(table_upsertion) = &self.actions.table_action.table_upsertion {
597591
match table_upsertion {
598592
TableUpsertionAction::Create { keys, values } => {
593+
// Create schema if specified
594+
if let Some(schema) = &table_id.schema {
595+
let sql = format!("CREATE SCHEMA IF NOT EXISTS \"{}\"", schema);
596+
sqlx::query(&sql).execute(db_pool).await?;
597+
}
598+
599599
let mut fields = (keys
600600
.iter()
601601
.map(|(name, typ)| format!("\"{name}\" {typ} NOT NULL")))

0 commit comments

Comments
 (0)