formatting

This commit is contained in:
Matthew Bucci
2024-02-26 16:15:07 -08:00
parent f602b49a5b
commit cf88b4d075
9 changed files with 40 additions and 39 deletions
+3 -3
View File
@@ -61,12 +61,12 @@ class ReplaceIntoSQLRewriter extends AbstractSQLRewriter
// Extract SQL components
$tableSection = trim(substr($statement, $insertIndex, $columnsStartIndex - $insertIndex));
$valuesSection = trim(substr($statement, $valuesIndex, strlen($statement) - $valuesIndex));
$columnsSection = trim(substr($statement, $columnsStartIndex, $columnsEndIndex - $columnsStartIndex + 1));
$columnsSection = trim(substr($statement, $columnsStartIndex, $columnsEndIndex - $columnsStartIndex + 1));
// Extract and clean up column names from the update section
$updateCols = explode(',', substr($columnsSection, 1, strlen($columnsSection) - 2));
$updateCols = array_map(function ($col) {
return trim($col);
return trim($col);
}, $updateCols);
// Choose a primary key for ON CONFLICT
@@ -91,7 +91,7 @@ class ReplaceIntoSQLRewriter extends AbstractSQLRewriter
}
// trim any preceding commas
$updateSection = ltrim($updateSection,", ");
$updateSection = ltrim($updateSection, ", ");
// Construct the PostgreSQL query
$postgresSQL = sprintf('%s %s %s ON CONFLICT (%s) DO UPDATE SET %s', $tableSection, $columnsSection, $valuesSection, $primaryKey, $updateSection);