From b16a4b73698a856c01572f3c380362845e230adc Mon Sep 17 00:00:00 2001 From: sasanuma Date: Thu, 22 Aug 2019 15:54:00 +0900 Subject: [PATCH 1/3] Delete .php_cs.cache --- .php_cs.cache | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .php_cs.cache diff --git a/.php_cs.cache b/.php_cs.cache deleted file mode 100644 index daa9d0c..0000000 --- a/.php_cs.cache +++ /dev/null @@ -1 +0,0 @@ -{"php":"7.2.2","version":"2.11.1:v2.11.1#ad94441c17b8ef096e517acccdbf3238af8a2da8","rules":{"braces":true,"class_definition":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_constants":true,"lowercase_keywords":true,"method_argument_space":{"ensure_fully_multiline":true},"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":true,"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"binary_operator_spaces":{"align_equals":false,"align_double_arrow":false},"blank_line_after_opening_tag":true,"blank_line_before_return":true,"cast_spaces":true,"combine_consecutive_unsets":true,"concat_space":{"spacing":"one"},"declare_equal_normalize":true,"dir_constant":true,"ereg_to_preg":true,"function_typehint_space":true,"general_phpdoc_annotation_remove":["author","category","package","copyright","version"],"hash_to_slash_comment":true,"heredoc_to_nowdoc":true,"include":true,"linebreak_after_opening_tag":true,"lowercase_cast":true,"method_separation":true,"modernize_types_casting":true,"native_function_casing":true,"no_alias_functions":true,"no_blank_lines_after_class_opening":true,"no_blank_lines_after_phpdoc":true,"no_blank_lines_before_namespace":true,"no_empty_comment":true,"no_empty_phpdoc":true,"no_empty_statement":true,"no_extra_consecutive_blank_lines":["break","continue","curly_brace_block","extra","parenthesis_brace_block","return","square_brace_block","throw","use","useTrait"],"no_leading_import_slash":true,"no_leading_namespace_whitespace":true,"no_mixed_echo_print":{"use":"echo"},"no_multiline_whitespace_around_double_arrow":true,"no_multiline_whitespace_before_semicolons":true,"no_short_bool_cast":true,"no_singleline_whitespace_before_semicolons":true,"no_spaces_around_offset":true,"no_trailing_comma_in_list_call":true,"no_trailing_comma_in_singleline_array":true,"no_unneeded_control_parentheses":true,"no_unreachable_default_argument_value":true,"no_unused_imports":true,"no_useless_else":true,"no_useless_return":true,"no_whitespace_before_comma_in_array":true,"no_whitespace_in_blank_line":true,"normalize_index_brace":true,"not_operator_with_successor_space":true,"object_operator_without_whitespace":true,"ordered_class_elements":true,"ordered_imports":true,"php_unit_construct":true,"php_unit_dedicate_assert":true,"php_unit_fqcn_annotation":true,"php_unit_strict":true,"phpdoc_align":true,"phpdoc_annotation_without_dot":true,"phpdoc_indent":true,"phpdoc_inline_tag":true,"phpdoc_no_access":true,"phpdoc_no_alias_tag":{"property-read":"property","property-write":"property","type":"var"},"phpdoc_no_empty_return":true,"phpdoc_no_package":true,"phpdoc_order":true,"phpdoc_return_self_reference":true,"phpdoc_scalar":true,"phpdoc_separation":true,"phpdoc_single_line_var_spacing":true,"phpdoc_to_comment":true,"phpdoc_trim":true,"phpdoc_types":true,"phpdoc_var_without_name":true,"pow_to_exponentiation":true,"protected_to_private":true,"psr0":true,"psr4":true,"random_api_migration":true,"return_type_declaration":{"space_before":"one"},"self_accessor":true,"short_scalar_cast":true,"single_quote":true,"space_after_semicolon":true,"standardize_not_equals":true,"ternary_operator_spaces":true,"strict_param":true,"ternary_to_null_coalescing":true,"trim_array_spaces":true,"unary_operator_spaces":true,"whitespace_after_comma_in_array":true},"hashes":{"docs\/demo\/run.php":2483873100,"docs\/demo\/run_by_app_module.php":2448157359,"src\/Annotation\/AuraSql.php":2523396732,"src\/Annotation\/AuraSqlConfig.php":3768193418,"src\/Annotation\/AuraSqlQueryConfig.php":3420158299,"src\/Annotation\/HttpMethod.php":3872489593,"src\/Annotation\/PagerViewOption.php":274007204,"src\/Annotation\/Read.php":4218120782,"src\/Annotation\/ReadOnlyConnection.php":838095801,"src\/Annotation\/Transactional.php":501260211,"src\/Annotation\/Write.php":2471329221,"src\/Annotation\/WriteConnection.php":2807184036,"src\/AuraSqlConnectionInterceptor.php":2101153996,"src\/AuraSqlDeleteInject.php":4160340900,"src\/AuraSqlInject.php":2652586600,"src\/AuraSqlInsertInject.php":80617665,"src\/AuraSqlMasterDbInterceptor.php":2913027295,"src\/AuraSqlModule.php":3561694108,"src\/AuraSqlPagerInject.php":3967314392,"src\/AuraSqlQueryDeleteProvider.php":2950921497,"src\/AuraSqlQueryInsertProvider.php":647480651,"src\/AuraSqlQueryModule.php":3573101983,"src\/AuraSqlQueryPagerInject.php":3109472959,"src\/AuraSqlQuerySelectProvider.php":2919842578,"src\/AuraSqlQueryUpdateProvider.php":1477743913,"src\/AuraSqlReplicationDbProvider.php":3825755618,"src\/AuraSqlReplicationModule.php":975267636,"src\/AuraSqlSelectInject.php":2463843758,"src\/AuraSqlSlaveDbInterceptor.php":3661729200,"src\/AuraSqlUpdateInject.php":866483140,"src\/Connection.php":2941558335,"src\/Exception\/InvalidTransactionalPropertyException.php":2463591483,"src\/Exception\/NotInitialized.php":1741463030,"src\/Exception\/RollbackException.php":147184266,"src\/IsInMethodMatcher.php":1543861884,"src\/NamedPdoModule.php":104698874,"src\/Pagerfanta\/AuraSqlPager.php":1678101597,"src\/Pagerfanta\/AuraSqlPagerFactory.php":3429289797,"src\/Pagerfanta\/AuraSqlPagerFactoryInterface.php":3775904222,"src\/Pagerfanta\/AuraSqlPagerInterface.php":842843383,"src\/Pagerfanta\/AuraSqlPagerModule.php":3286946385,"src\/Pagerfanta\/AuraSqlQueryAdapter.php":1646048919,"src\/Pagerfanta\/AuraSqlQueryPager.php":369891081,"src\/Pagerfanta\/AuraSqlQueryPagerFactory.php":877025118,"src\/Pagerfanta\/AuraSqlQueryPagerFactoryInterface.php":1483897641,"src\/Pagerfanta\/AuraSqlQueryPagerInterface.php":167676663,"src\/Pagerfanta\/DefaultRouteGenerator.php":1470348604,"src\/Pagerfanta\/ExtendedPdoAdapter.php":1223112917,"src\/Pagerfanta\/Page.php":3407649518,"src\/Pagerfanta\/RouteGeneratorInterface.php":3941237520,"src\/TransactionalInterceptor.php":449549119,"src\/TransactionalModule.php":1271295187,"src-files\/uri_template.php":252873380,"tests\/AuraSqlLocatorModuleTest.php":3900833926,"tests\/AuraSqlModuleTest.php":2061022394,"tests\/AuraSqlQueryModuleTest.php":3659410328,"tests\/AuraSqlReplicationModuleTest.php":1124321860,"tests\/bootstrap.php":2583268030,"tests\/NamedPdoModuleTest.php":1923855803,"tests\/Pagerfanta\/AbstractPdoTestCase.php":1676964091,"tests\/Pagerfanta\/AuraSqlPagerFactoryTest.php":1834754159,"tests\/Pagerfanta\/AuraSqlPagerModuleTest.php":4260873639,"tests\/Pagerfanta\/AuraSqlPagerTest.php":2780596722,"tests\/Pagerfanta\/AuraSqlQueryAdapterTest.php":1758512414,"tests\/Pagerfanta\/AuraSqlQueryPagerModuleTest.php":2112842154,"tests\/Pagerfanta\/AuraSqlQueryPagerTest.php":3098750173,"tests\/Pagerfanta\/AuraSqlQueryTestCase.php":1877157032,"tests\/Pagerfanta\/ExtendedPdoAdapterTest.php":1497025875,"tests\/Pagerfanta\/PdoMySqlAdapterTest.php":3363251830,"tests\/TransactionalTest.php":853013930,"src\/AuraSqlLocatorModule.php":284506944}} \ No newline at end of file From 988776492cbf882bff3a0a9dbfe3ff29a6d6faaf Mon Sep 17 00:00:00 2001 From: sasanuma Date: Thu, 22 Aug 2019 15:54:37 +0900 Subject: [PATCH 2/3] add red test --- tests/Pagerfanta/ExtendedPdoAdapterTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Pagerfanta/ExtendedPdoAdapterTest.php b/tests/Pagerfanta/ExtendedPdoAdapterTest.php index 6d449f1..fa8213c 100644 --- a/tests/Pagerfanta/ExtendedPdoAdapterTest.php +++ b/tests/Pagerfanta/ExtendedPdoAdapterTest.php @@ -62,6 +62,7 @@ public function splProvider() ['SELECT * FROM posts', [], 'SELECT COUNT(*) FROM posts', 50], ['SELECT DISTINCT id FROM posts', [], '', 50], ['SELECT * FROM posts WHERE id > :num', ['num' => 10], 'SELECT COUNT(*) FROM posts WHERE id > :num', 40], + ['SELECT id FROM posts UNION SELECT id FROM posts', [], '', 50], ]; } From e0a087da641b52f2137d65c90283ff46a515c8e9 Mon Sep 17 00:00:00 2001 From: sasanuma Date: Thu, 22 Aug 2019 15:55:32 +0900 Subject: [PATCH 3/3] =?UTF-8?q?UNION=E3=81=8C=E5=90=AB=E3=81=BE=E3=82=8C?= =?UTF-8?q?=E3=81=9FSQL=E3=82=92countQuery=E7=94=9F=E6=88=90=E3=81=8B?= =?UTF-8?q?=E3=82=89=E9=99=A4=E5=A4=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Pagerfanta/ExtendedPdoAdapter.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Pagerfanta/ExtendedPdoAdapter.php b/src/Pagerfanta/ExtendedPdoAdapter.php index 91e6bf8..a6c6cae 100644 --- a/src/Pagerfanta/ExtendedPdoAdapter.php +++ b/src/Pagerfanta/ExtendedPdoAdapter.php @@ -109,6 +109,9 @@ public function getLimitClause($offset, $length) */ public function rewriteCountQuery($query) { + if (\is_int(\strpos(\strtolower($query), 'union'))) { + return ''; + } if (\preg_match('/^\s*SELECT\s+\bDISTINCT\b/is', $query) || \preg_match('/\s+GROUP\s+BY\s+/is', $query)) { return ''; }