mirror of
https://github.com/PostgreSQL-For-Wordpress/postgresql-for-wordpress.git
synced 2025-07-30 17:57:13 +02:00
formatting
This commit is contained in:
@ -216,7 +216,8 @@ class AlterTableSQLRewriter extends AbstractSQLRewriter
|
|||||||
return $sql;
|
return $sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function rewrite_numeric_type($sql){
|
private function rewrite_numeric_type($sql)
|
||||||
|
{
|
||||||
// Numeric types in MySQL which need to be rewritten
|
// Numeric types in MySQL which need to be rewritten
|
||||||
$numeric_types = ["bigint", "int", "integer", "smallint", "mediumint", "tinyint", "double", "decimal"];
|
$numeric_types = ["bigint", "int", "integer", "smallint", "mediumint", "tinyint", "double", "decimal"];
|
||||||
$numeric_types_imploded = implode('|', $numeric_types);
|
$numeric_types_imploded = implode('|', $numeric_types);
|
||||||
|
@ -88,7 +88,8 @@ class CreateTableSQLRewriter extends AbstractSQLRewriter
|
|||||||
return $sql;
|
return $sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function rewrite_numeric_type($sql){
|
private function rewrite_numeric_type($sql)
|
||||||
|
{
|
||||||
// Numeric types in MySQL which need to be rewritten
|
// Numeric types in MySQL which need to be rewritten
|
||||||
$numeric_types = ["bigint", "int", "integer", "smallint", "mediumint", "tinyint", "double", "decimal"];
|
$numeric_types = ["bigint", "int", "integer", "smallint", "mediumint", "tinyint", "double", "decimal"];
|
||||||
$numeric_types_imploded = implode('|', $numeric_types);
|
$numeric_types_imploded = implode('|', $numeric_types);
|
||||||
|
@ -130,7 +130,7 @@ class InsertSQLRewriter extends AbstractSQLRewriter
|
|||||||
$sql = $sql_before_semicolon . ' RETURNING *' . $sql_after_semicolon;
|
$sql = $sql_before_semicolon . ' RETURNING *' . $sql_after_semicolon;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$sql = $sql .=" RETURNING *";
|
$sql = $sql .= " RETURNING *";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,23 +138,22 @@ class InsertSQLRewriter extends AbstractSQLRewriter
|
|||||||
}
|
}
|
||||||
|
|
||||||
// finds semicolons that aren't in variables
|
// finds semicolons that aren't in variables
|
||||||
private function findSemicolon($sql) {
|
private function findSemicolon($sql)
|
||||||
|
{
|
||||||
$quoteOpened = false;
|
$quoteOpened = false;
|
||||||
$parenthesisDepth = 0;
|
$parenthesisDepth = 0;
|
||||||
|
|
||||||
$sqlAsArray = str_split($sql);
|
$sqlAsArray = str_split($sql);
|
||||||
for($i=0; $i<count($sqlAsArray); $i++) {
|
for($i = 0; $i < count($sqlAsArray); $i++) {
|
||||||
if(($sqlAsArray[$i] == '"' || $sqlAsArray[$i]=="'") && ($i == 0 || $sqlAsArray[$i-1]!='\\'))
|
if(($sqlAsArray[$i] == '"' || $sqlAsArray[$i] == "'") && ($i == 0 || $sqlAsArray[$i - 1] != '\\')) {
|
||||||
$quoteOpened = !$quoteOpened;
|
$quoteOpened = !$quoteOpened;
|
||||||
|
} elseif($sqlAsArray[$i] == '(' && !$quoteOpened) {
|
||||||
else if($sqlAsArray[$i] == '(' && !$quoteOpened)
|
|
||||||
$parenthesisDepth++;
|
$parenthesisDepth++;
|
||||||
|
} elseif($sqlAsArray[$i] == ')' && !$quoteOpened) {
|
||||||
else if($sqlAsArray[$i] == ')' && !$quoteOpened)
|
|
||||||
$parenthesisDepth--;
|
$parenthesisDepth--;
|
||||||
|
} elseif($sqlAsArray[$i] == ';' && !$quoteOpened && $parenthesisDepth == 0) {
|
||||||
else if($sqlAsArray[$i] == ';' && !$quoteOpened && $parenthesisDepth == 0)
|
|
||||||
return $i;
|
return $i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ class ReplaceIntoSQLRewriter extends AbstractSQLRewriter
|
|||||||
}
|
}
|
||||||
|
|
||||||
// trim any preceding commas
|
// trim any preceding commas
|
||||||
$updateSection = ltrim($updateSection,", ");
|
$updateSection = ltrim($updateSection, ", ");
|
||||||
|
|
||||||
// Construct the PostgreSQL query
|
// Construct the PostgreSQL query
|
||||||
$postgresSQL = sprintf('%s %s %s ON CONFLICT (%s) DO UPDATE SET %s', $tableSection, $columnsSection, $valuesSection, $primaryKey, $updateSection);
|
$postgresSQL = sprintf('%s %s %s ON CONFLICT (%s) DO UPDATE SET %s', $tableSection, $columnsSection, $valuesSection, $primaryKey, $updateSection);
|
||||||
|
BIN
tests/tools/php-cs-fixer.phar
Normal file
BIN
tests/tools/php-cs-fixer.phar
Normal file
Binary file not shown.
Reference in New Issue
Block a user