From e8d106f98d74a833a0dc32d520883735235bd594 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 8 May 2023 15:41:41 +0000 Subject: [PATCH] Apply hackfmt with applicable args --- .hhconfig | 3 +- src/AsyncMysql/AsyncMysqlClient.php | 2 +- src/BuildSchemaCLI.php | 5 +- src/DataIntegrity.php | 97 +++++++++++++++----------- src/Expressions/ConstantExpression.php | 5 +- src/Metrics.php | 5 +- src/Parser/CreateTableParser.php | 19 ++--- src/Query/FromClause.php | 2 +- src/Query/JoinProcessor.php | 10 ++- src/SchemaGenerator.php | 2 +- src/VitessQueryValidator.php | 8 +-- tests/JSONFunctionTest.hack | 15 ++-- tests/JoinQueryTest.php | 15 ++-- tests/MultiQueryTest.php | 5 +- tests/SQLFunctionTest.php | 29 +++----- tests/SelectClauseTest.php | 14 ++-- tests/SelectExpressionTest.php | 13 ++-- tests/SharedSetup.php | 4 +- tests/UpdateQueryTest.php | 4 +- 19 files changed, 116 insertions(+), 141 deletions(-) diff --git a/.hhconfig b/.hhconfig index 6f6d160..ab337fa 100644 --- a/.hhconfig +++ b/.hhconfig @@ -1,5 +1,4 @@ hackfmt.line_width=120 +hackfmt.tabs=true allowed_decl_fixme_codes=2053,3012,4045,4047,4341 allowed_fixme_codes_strict=2011,2049,2050,2053,2083,3012,3084,4027,4038,4045,4047,4104,4105,4106,4107,4108,4110,4128,4135,4188,4223,4240,4323,4341,4390,4401 - - diff --git a/src/AsyncMysql/AsyncMysqlClient.php b/src/AsyncMysql/AsyncMysqlClient.php index 20e0d50..220f3bc 100644 --- a/src/AsyncMysql/AsyncMysqlClient.php +++ b/src/AsyncMysql/AsyncMysqlClient.php @@ -25,7 +25,7 @@ public static function setPoolsConnectionLimit(int $_limit): void {} int $_tcp_timeout_micros = 0, string $_sni_server_name = '', string $_server_cert_extension = '', - string $_server_cert_values = '', + string $_server_cert_values = '', ): Awaitable<\AsyncMysqlConnection> { return new AsyncMysqlConnection($host, $port, $dbname); } diff --git a/src/BuildSchemaCLI.php b/src/BuildSchemaCLI.php index 2b50373..dc77193 100644 --- a/src/BuildSchemaCLI.php +++ b/src/BuildSchemaCLI.php @@ -77,9 +77,8 @@ protected function getSupportedOptions(): vec { HackBuilderValues::shapeWithPerKeyRendering( shape( 'name' => HackBuilderValues::export(), - 'indexes' => HackBuilderValues::vec( - HackBuilderValues::shapeWithUniformRendering(HackBuilderValues::export()), - ), + 'indexes' => + HackBuilderValues::vec(HackBuilderValues::shapeWithUniformRendering(HackBuilderValues::export())), 'fields' => HackBuilderValues::vec(HackBuilderValues::shapeWithPerKeyRendering( shape( 'name' => HackBuilderValues::export(), diff --git a/src/DataIntegrity.php b/src/DataIntegrity.php index a3d1010..6758f13 100644 --- a/src/DataIntegrity.php +++ b/src/DataIntegrity.php @@ -108,51 +108,66 @@ public static function ensureFieldsPresent(dict $row, table_schem $row[$field_name] = (int)$row[$field_name]; } } else { - $signed = !($field_unsigned); - $field_value = (int)$row[$field_name]; + $signed = !($field_unsigned); + $field_value = (int)$row[$field_name]; - switch($field_mysql_type) { - case DataType::TINYINT: - if ($field_value < (($signed) ? -\pow(2,7) : 0) || $field_value >= (($signed) ? \pow(2,7) : \pow(2,8))){ - throw new SQLFakeRuntimeException( - "Column '{$field_name}' on '{$schema['name']}' expects a valid '{$field_mysql_type}'", - ); - } - break; - case DataType::SMALLINT: - if ($field_value < (($signed) ? -\pow(2,15) : 0) || $field_value >= (($signed) ? \pow(2,15) : \pow(2,16))){ - throw new SQLFakeRuntimeException( - "Column '{$field_name}' on '{$schema['name']}' expects a valid '{$field_mysql_type}'", - ); - } - break; - case DataType::MEDIUMINT: - if ($field_value < (($signed) ? -\pow(2,23) : 0) || $field_value >= (($signed) ? \pow(2,23) : \pow(2,24))){ - throw new SQLFakeRuntimeException( - "Column '{$field_name}' on '{$schema['name']}' expects a valid '{$field_mysql_type}'", - ); - } - break; - case DataType::INT: - if ($field_value < (($signed) ? -\pow(2,31) : 0) || $field_value >= (($signed) ? \pow(2,31) : \pow(2,32))){ - throw new SQLFakeRuntimeException( - "Column '{$field_name}' on '{$schema['name']}' expects a valid '{$field_mysql_type}'", - ); - } - break; - case DataType::BIGINT: - if ($field_value < (($signed) ? -\pow(2,63) : 0) || $field_value >= (($signed) ? \pow(2,63) : \pow(2,64))){ - throw new SQLFakeRuntimeException( - "Column '{$field_name}' on '{$schema['name']}' expects a valid '{$field_mysql_type}'", - ); - } - break; - default: + switch ($field_mysql_type) { + case DataType::TINYINT: + if ( + $field_value < (($signed) ? -\pow(2, 7) : 0) || + $field_value >= (($signed) ? \pow(2, 7) : \pow(2, 8)) + ) { throw new SQLFakeRuntimeException( "Column '{$field_name}' on '{$schema['name']}' expects a valid '{$field_mysql_type}'", ); - break; - } + } + break; + case DataType::SMALLINT: + if ( + $field_value < (($signed) ? -\pow(2, 15) : 0) || + $field_value >= (($signed) ? \pow(2, 15) : \pow(2, 16)) + ) { + throw new SQLFakeRuntimeException( + "Column '{$field_name}' on '{$schema['name']}' expects a valid '{$field_mysql_type}'", + ); + } + break; + case DataType::MEDIUMINT: + if ( + $field_value < (($signed) ? -\pow(2, 23) : 0) || + $field_value >= (($signed) ? \pow(2, 23) : \pow(2, 24)) + ) { + throw new SQLFakeRuntimeException( + "Column '{$field_name}' on '{$schema['name']}' expects a valid '{$field_mysql_type}'", + ); + } + break; + case DataType::INT: + if ( + $field_value < (($signed) ? -\pow(2, 31) : 0) || + $field_value >= (($signed) ? \pow(2, 31) : \pow(2, 32)) + ) { + throw new SQLFakeRuntimeException( + "Column '{$field_name}' on '{$schema['name']}' expects a valid '{$field_mysql_type}'", + ); + } + break; + case DataType::BIGINT: + if ( + $field_value < (($signed) ? -\pow(2, 63) : 0) || + $field_value >= (($signed) ? \pow(2, 63) : \pow(2, 64)) + ) { + throw new SQLFakeRuntimeException( + "Column '{$field_name}' on '{$schema['name']}' expects a valid '{$field_mysql_type}'", + ); + } + break; + default: + throw new SQLFakeRuntimeException( + "Column '{$field_name}' on '{$schema['name']}' expects a valid '{$field_mysql_type}'", + ); + break; + } } break; case 'double': diff --git a/src/Expressions/ConstantExpression.php b/src/Expressions/ConstantExpression.php index d3a6a07..a68c7e6 100644 --- a/src/Expressions/ConstantExpression.php +++ b/src/Expressions/ConstantExpression.php @@ -32,9 +32,8 @@ private function extractConstantValue(token $token): mixed { case TokenType::NULL_CONSTANT: return null; default: - throw new SQLFakeRuntimeException( - "Attempted to assign invalid token type {$token['type']} to Constant Expression", - ); + throw + new SQLFakeRuntimeException("Attempted to assign invalid token type {$token['type']} to Constant Expression"); } } diff --git a/src/Metrics.php b/src/Metrics.php index ad6b867..034660d 100644 --- a/src/Metrics.php +++ b/src/Metrics.php @@ -92,7 +92,7 @@ public static function getTotalQueryCount(): int { */ public static function trackQuery(QueryType $type, string $host, string $table_name, string $sql): void { - if (!self::$enable){ + if (!self::$enable) { return; } @@ -117,7 +117,8 @@ protected static function getBacktrace(): string { // filter out this library if ( - Str\contains($trace[0]['file'] ?? '', \realpath(__DIR__.'/..')) || ($trace[0]['class'] ?? '') === AsyncMysqlConnection::class + Str\contains($trace[0]['file'] ?? '', \realpath(__DIR__.'/..')) || + ($trace[0]['class'] ?? '') === AsyncMysqlConnection::class ) { $trace = Vec\drop($trace, 1); continue; diff --git a/src/Parser/CreateTableParser.php b/src/Parser/CreateTableParser.php index ec37e2a..7b2f947 100644 --- a/src/Parser/CreateTableParser.php +++ b/src/Parser/CreateTableParser.php @@ -228,11 +228,8 @@ private function walk(vec $tokens, string $sql, vec<(int, int)> $source_ if (C\count($temp)) { $statements[] = shape( 'tuples' => $temp, - 'sql' => Str\slice( - $sql, - $source_map[$start][0], - $source_map[$i][0] - $source_map[$start][0] + $source_map[$i][1], - ), + 'sql' => + Str\slice($sql, $source_map[$start][0], $source_map[$i][0] - $source_map[$start][0] + $source_map[$i][1]), ); } $temp = vec[]; @@ -244,11 +241,8 @@ private function walk(vec $tokens, string $sql, vec<(int, int)> $source_ if (C\count($temp)) { $statements[] = shape( 'tuples' => $temp, - 'sql' => Str\slice( - $sql, - $source_map[$start][0], - $source_map[$i][0] - $source_map[$start][0] + $source_map[$i][1], - ), + 'sql' => + Str\slice($sql, $source_map[$start][0], $source_map[$i][0] - $source_map[$start][0] + $source_map[$i][1]), ); } @@ -859,10 +853,7 @@ private function extractTokens(string $sql, vec<(int, int)> $source_map): vec; $m = dict[]; foreach ($row as $field => $val) { diff --git a/src/Query/JoinProcessor.php b/src/Query/JoinProcessor.php index 08aeda1..169fc4f 100644 --- a/src/Query/JoinProcessor.php +++ b/src/Query/JoinProcessor.php @@ -195,12 +195,10 @@ protected static function addJoinFilterExpression( string $right_column, ): BinaryOperatorExpression { - $left = new ColumnExpression( - shape('type' => TokenType::IDENTIFIER, 'value' => $left_column, 'raw' => $left_column), - ); - $right = new ColumnExpression( - shape('type' => TokenType::IDENTIFIER, 'value' => $right_column, 'raw' => $right_column), - ); + $left = + new ColumnExpression(shape('type' => TokenType::IDENTIFIER, 'value' => $left_column, 'raw' => $left_column)); + $right = + new ColumnExpression(shape('type' => TokenType::IDENTIFIER, 'value' => $right_column, 'raw' => $right_column)); // making a binary expression ensuring those two tokens are equal $expr = new BinaryOperatorExpression($left, /* $negated */ false, Operator::EQUALS, $right); diff --git a/src/SchemaGenerator.php b/src/SchemaGenerator.php index 885fdce..647e903 100644 --- a/src/SchemaGenerator.php +++ b/src/SchemaGenerator.php @@ -34,7 +34,7 @@ public function generateFromString(string $sql): dict { if ($default is nonnull && $default !== 'NULL') { $f['default'] = $default; } - + $unsigned = ($field['unsigned'] ?? null); if ($unsigned is nonnull) { $f['unsigned'] = $unsigned; diff --git a/src/VitessQueryValidator.php b/src/VitessQueryValidator.php index 4a91bd0..e8e69c6 100644 --- a/src/VitessQueryValidator.php +++ b/src/VitessQueryValidator.php @@ -75,8 +75,7 @@ public static function enablePrimaryVindexColumnValidator(): void { public function getHandlers(): dict)> { $handlers = dict[]; if (static::$isPrimaryVindexColumnValidatorEnabled) { - $handlers[UnsupportedCases::PRIMARY_VINDEX_COLUMN] = async () ==> - await $this->updateChangesPrimaryVindexColumn(); + $handlers[UnsupportedCases::PRIMARY_VINDEX_COLUMN] = async () ==> await $this->updateChangesPrimaryVindexColumn(); } return $handlers; @@ -205,9 +204,8 @@ private function isCrossShardQuery(): bool { case MultiOperand::UNION_ALL: case MultiOperand::INTERSECT: case MultiOperand::EXCEPT: - throw new SQLFakeVitessQueryViolation( - Str\format('Vitess query validation error: %s', UnsupportedCases::UNIONS), - ); + throw + new SQLFakeVitessQueryViolation(Str\format('Vitess query validation error: %s', UnsupportedCases::UNIONS)); } } } diff --git a/tests/JSONFunctionTest.hack b/tests/JSONFunctionTest.hack index 34d4930..ce09f8a 100644 --- a/tests/JSONFunctionTest.hack +++ b/tests/JSONFunctionTest.hack @@ -328,10 +328,7 @@ final class JSONFunctionTest extends HackTest { tuple("JSON_EXTRACT(JSON_EXTRACT('[true]', '$[0]'), '$')", shape('value' => 'true')), // JSON as doc for JSON_REPLACE - tuple( - "JSON_REPLACE(JSON_EXTRACT('{\"a\":{\"b\": 2}}', '$.a'), '$.b', true)", - shape('value' => '{"b":true}'), - ), + tuple("JSON_REPLACE(JSON_EXTRACT('{\"a\":{\"b\": 2}}', '$.a'), '$.b', true)", shape('value' => '{"b":true}')), tuple("JSON_REPLACE(JSON_EXTRACT(\"[false]\", '$[0]'), '$.a', 'test')", shape('value' => 'false')), tuple( @@ -341,10 +338,7 @@ final class JSONFunctionTest extends HackTest { tuple("JSON_REPLACE('{\"b\":2}', '$.b', 1 < 2)", shape('value' => '{"b":true}')), // JSON value as replacement in JSON_REPLACE - tuple( - "JSON_REPLACE('[0,1]', '$[1]', JSON_EXTRACT('{\"a\": \"test\"}', '$.a'))", - shape('value' => '[0,"test"]'), - ), + tuple("JSON_REPLACE('[0,1]', '$[1]', JSON_EXTRACT('{\"a\": \"test\"}', '$.a'))", shape('value' => '[0,"test"]')), tuple( "JSON_REPLACE('{\"a\":2}', JSON_UNQUOTE(JSON_EXTRACT('{\"b\":\"$.a\"}', '$.b')), 4)", shape('value' => '{"a":4}'), @@ -396,7 +390,10 @@ final class JSONFunctionTest extends HackTest { tuple("JSON_CONTAINS('null', '2', '$.a')", shape('exception' => SQLFakeRuntimeException::class)), tuple("JSON_CONTAINS('[]', 45, '$.a')", shape('exception' => SQLFakeRuntimeException::class)), tuple("JSON_CONTAINS('2', 45, '$.a')", shape('exception' => SQLFakeRuntimeException::class)), - tuple("JSON_CONTAINS('{\"a\": {\"b\":\"test\"}}', '45', '$.b')", shape('exception' => SQLFakeRuntimeException::class)), + tuple( + "JSON_CONTAINS('{\"a\": {\"b\":\"test\"}}', '45', '$.b')", + shape('exception' => SQLFakeRuntimeException::class), + ), // existent path - array tuple("JSON_CONTAINS('[]', '4', '$')", shape('value' => 0)), diff --git a/tests/JoinQueryTest.php b/tests/JoinQueryTest.php index 4ac73b7..d56d427 100644 --- a/tests/JoinQueryTest.php +++ b/tests/JoinQueryTest.php @@ -49,9 +49,8 @@ final class JoinQueryTest extends HackTest { $results = await $conn->query('SELECT * FROM table3 JOIN association_table ON id = table_3_id'); expect($results->rows())->toBeSame($expected, 'with no aliases and column names inferred from table schema'); - $results = await $conn->query( - 'SELECT * FROM table3 JOIN association_table ON table3.id = association_table.table_3_id', - ); + $results = + await $conn->query('SELECT * FROM table3 JOIN association_table ON table3.id = association_table.table_3_id'); expect($results->rows())->toBeSame($expected, 'with columns using explicitly specified table names'); $results = await $conn->query( @@ -91,9 +90,8 @@ final class JoinQueryTest extends HackTest { public async function testLeftJoin(): Awaitable { $conn = static::$conn as nonnull; - $results = await $conn->query( - 'SELECT id, table_4_id FROM table3 LEFT OUTER JOIN association_table ON id=table_3_id', - ); + $results = + await $conn->query('SELECT id, table_4_id FROM table3 LEFT OUTER JOIN association_table ON id=table_3_id'); expect($results->rows())->toBeSame(vec[ dict['id' => 1, 'table_4_id' => 1000], dict['id' => 1, 'table_4_id' => 1001], @@ -121,9 +119,8 @@ final class JoinQueryTest extends HackTest { public async function testCrossJoin(): Awaitable { $conn = static::$conn as nonnull; - $results = await $conn->query( - 'SELECT table_3_id, id as table_4_id FROM association_table, table4 WHERE table4.id=1003', - ); + $results = + await $conn->query('SELECT table_3_id, id as table_4_id FROM association_table, table4 WHERE table4.id=1003'); expect($results->rows())->toBeSame(vec[ dict['table_3_id' => 1, 'table_4_id' => 1003], dict['table_3_id' => 1, 'table_4_id' => 1003], diff --git a/tests/MultiQueryTest.php b/tests/MultiQueryTest.php index 9e674d4..9d26f30 100644 --- a/tests/MultiQueryTest.php +++ b/tests/MultiQueryTest.php @@ -10,9 +10,8 @@ final class MultiQueryTest extends HackTest { public async function testSubqueryInSelect(): Awaitable { $conn = static::$conn as nonnull; - $results = await $conn->query( - 'SELECT * FROM (SELECT id FROM table4 WHERE id = 1001 OR id = 1004) as sub WHERE id = 1001', - ); + $results = + await $conn->query('SELECT * FROM (SELECT id FROM table4 WHERE id = 1001 OR id = 1004) as sub WHERE id = 1001'); expect($results->rows())->toBeSame(vec[ dict['id' => 1001], ]); diff --git a/tests/SQLFunctionTest.php b/tests/SQLFunctionTest.php index fc6a60d..22dd353 100644 --- a/tests/SQLFunctionTest.php +++ b/tests/SQLFunctionTest.php @@ -36,14 +36,12 @@ final class SQLFunctionTest extends HackTest { $results = await $conn->query('select group_id, count(*) from association_table group by 1'); expect($results->rows())->toBeSame($expected, 'with positional reference in group_by'); - $results = await $conn->query( - 'select group_id, count(*) from association_table group by association_table.group_id', - ); + $results = + await $conn->query('select group_id, count(*) from association_table group by association_table.group_id'); expect($results->rows())->toBeSame($expected, 'with column and alias reference in group_by'); - $results = await $conn->query( - 'select group_id, count(1) from association_table group by association_table.group_id', - ); + $results = + await $conn->query('select group_id, count(1) from association_table group by association_table.group_id'); expect($results->rows())->toBeSame( vec[dict['group_id' => 12345, 'count(1)' => 3], dict['group_id' => 0, 'count(1)' => 1]], 'with count(1) instead of count(*)', @@ -60,9 +58,8 @@ final class SQLFunctionTest extends HackTest { public async function testCountDistinct(): Awaitable { $conn = static::$conn as nonnull; - $results = await $conn->query( - 'select group_id, count(DISTINCT table_3_id) from association_table group by group_id', - ); + $results = + await $conn->query('select group_id, count(DISTINCT table_3_id) from association_table group by group_id'); expect($results->rows())->toBeSame( vec[ dict['group_id' => 12345, 'count(DISTINCT table_3_id)' => 2], @@ -114,9 +111,8 @@ final class SQLFunctionTest extends HackTest { public async function testMinMax(): Awaitable { $conn = static::$conn as nonnull; - $results = await $conn->query( - 'SELECT group_id, MIN(table_4_id), MAX(table_4_id) FROM association_table GROUP BY group_id', - ); + $results = + await $conn->query('SELECT group_id, MIN(table_4_id), MAX(table_4_id) FROM association_table GROUP BY group_id'); expect($results->rows())->toBeSame( vec[ dict[ @@ -135,9 +131,8 @@ final class SQLFunctionTest extends HackTest { public async function testAggNoGroupBy(): Awaitable { $conn = static::$conn as nonnull; - $results = await $conn->query( - 'SELECT COUNT(*), MIN(table_4_id), MAX(table_4_id), AVG(table_4_id) FROM association_table', - ); + $results = + await $conn->query('SELECT COUNT(*), MIN(table_4_id), MAX(table_4_id), AVG(table_4_id) FROM association_table'); expect($results->rows())->toBeSame( vec[ dict[ @@ -370,9 +365,7 @@ final class SQLFunctionTest extends HackTest { // with alias being the same as the column name $results = await $conn->query('select max(id) as id, group_id from table3 group by group_id order by id'); - expect($results->rows())->toBeSame( - vec[dict['id' => 3, 'group_id' => 12345], dict['id' => 6, 'group_id' => 6]], - ); + expect($results->rows())->toBeSame(vec[dict['id' => 3, 'group_id' => 12345], dict['id' => 6, 'group_id' => 6]]); // with positional identifier $results = await $conn->query('select max(id), group_id from table3 group by group_id order by 1'); diff --git a/tests/SelectClauseTest.php b/tests/SelectClauseTest.php index b66d340..06cadb7 100644 --- a/tests/SelectClauseTest.php +++ b/tests/SelectClauseTest.php @@ -63,9 +63,8 @@ final class SelectClauseTest extends HackTest { 'with backtick quoted identifiers', ); - $results = await $conn->query( - 'SELECT table3.id, table3.group_id as my_fav_group_id FROM `db2`.`table3` WHERE group_id=6', - ); + $results = + await $conn->query('SELECT table3.id, table3.group_id as my_fav_group_id FROM `db2`.`table3` WHERE group_id=6'); expect($results->rows())->toBeSame( vec[ dict['id' => 4, 'my_fav_group_id' => 6], @@ -194,9 +193,8 @@ final class SelectClauseTest extends HackTest { public async function testLimit(): Awaitable { $conn = static::$conn as nonnull; - $results = await $conn->query( - 'select group_id, table_4_id from association_table ORDER BY group_id, 2 DESC LIMIT 2', - ); + $results = + await $conn->query('select group_id, table_4_id from association_table ORDER BY group_id, 2 DESC LIMIT 2'); expect($results->rows())->toBeSame( vec[ dict['group_id' => 0, 'table_4_id' => 1003], @@ -235,9 +233,7 @@ final class SelectClauseTest extends HackTest { public async function testOutOfOrderClauses(): Awaitable { $conn = static::$conn as nonnull; - expect( - () ==> $conn->query('select group_id, table_4_id from association_table LIMIT 2 ORDER BY group_id, 2 DESC'), - ) + expect(() ==> $conn->query('select group_id, table_4_id from association_table LIMIT 2 ORDER BY group_id, 2 DESC')) ->toThrow(SQLFakeParseException::class, 'Unexpected ORDER'); } diff --git a/tests/SelectExpressionTest.php b/tests/SelectExpressionTest.php index b9847d4..7a317f9 100644 --- a/tests/SelectExpressionTest.php +++ b/tests/SelectExpressionTest.php @@ -46,9 +46,8 @@ final class SelectExpressionTest extends HackTest { public async function testSelectExpressions(): Awaitable { $conn = static::$conn as nonnull; - $results = await $conn->query( - 'SELECT id, group_id as my_fav_group_id, id*1000 as math FROM table3 WHERE group_id=6', - ); + $results = + await $conn->query('SELECT id, group_id as my_fav_group_id, id*1000 as math FROM table3 WHERE group_id=6'); expect($results->rows())->toBeSame( vec[ dict['id' => 4, 'my_fav_group_id' => 6, 'math' => 4000], @@ -200,9 +199,7 @@ final class SelectExpressionTest extends HackTest { // weird this is even valid SQL, and possibly pedantic, but this demonstrates a lot of how // case statements are implemented such that it doesn't blow up on the second THEN or second CASE - $results = await $conn->query( - "SELECT CASE WHEN 4 = CASE WHEN 1 = 2 THEN 3 ELSE 4 END THEN 'yes' ELSE 'no' END", - ); + $results = await $conn->query("SELECT CASE WHEN 4 = CASE WHEN 1 = 2 THEN 3 ELSE 4 END THEN 'yes' ELSE 'no' END"); expect($results->rows())->toBeSame( vec[ dict["CASE WHEN 4 = CASE WHEN 1 = 2 THEN 3 ELSE 4 END THEN 'yes' ELSE 'no' END" => 'yes'], @@ -341,9 +338,7 @@ final class SelectExpressionTest extends HackTest { public async function testNotParens(): Awaitable { $conn = static::$conn as nonnull; - $results = await $conn->query( - "SELECT id FROM table3 WHERE group_id=12345 AND NOT (name='name1' OR name='name3')", - ); + $results = await $conn->query("SELECT id FROM table3 WHERE group_id=12345 AND NOT (name='name1' OR name='name3')"); expect($results->rows())->toBeSame(vec[ dict['id' => 2], ]); diff --git a/tests/SharedSetup.php b/tests/SharedSetup.php index e72b46a..c8b91fb 100644 --- a/tests/SharedSetup.php +++ b/tests/SharedSetup.php @@ -185,7 +185,7 @@ final class SharedSetup { 'name' => 'PRIMARY', 'type' => 'PRIMARY', 'fields' => keyset['id'], - ) + ), ], ), 'table_with_more_fields' => shape( @@ -386,7 +386,7 @@ final class SharedSetup { 'name' => 'PRIMARY', 'type' => 'PRIMARY', 'fields' => keyset['id'], - ) + ), ], ), 'association_table' => shape( diff --git a/tests/UpdateQueryTest.php b/tests/UpdateQueryTest.php index 88aa1f5..8624834 100644 --- a/tests/UpdateQueryTest.php +++ b/tests/UpdateQueryTest.php @@ -71,9 +71,7 @@ final class UpdateQueryTest extends HackTest { dict['id' => 4, 'group_id' => 13, 'name' => 'name34updated'], dict['id' => 6, 'group_id' => 13, 'name' => 'name36updated'], ]; - await $conn->query( - "UPDATE `db2`.`table3` set name=CONCAT(name, id, 'updated'), group_id = 13 WHERE group_id=6", - ); + await $conn->query("UPDATE `db2`.`table3` set name=CONCAT(name, id, 'updated'), group_id = 13 WHERE group_id=6"); $results = await $conn->query('SELECT * FROM table3 WHERE group_id=13'); expect($results->rows())->toBeSame($expected, 'with backticks'); }