From 767c7d10e598fc2b8ea191fc046f4ecb26d2f8b5 Mon Sep 17 00:00:00 2001 From: 1on Date: Mon, 22 Dec 2014 16:59:29 +0300 Subject: [PATCH 1/2] ExistAny function fixed. text_array type added, --- DBAL/Types/TextArrayType.php | 54 +++++++++++++++++++ DQL/ExistsAnyFunction.php | 4 +- DependencyInjection/IntaroHStoreExtension.php | 6 ++- 3 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 DBAL/Types/TextArrayType.php diff --git a/DBAL/Types/TextArrayType.php b/DBAL/Types/TextArrayType.php new file mode 100644 index 0000000..8776d4d --- /dev/null +++ b/DBAL/Types/TextArrayType.php @@ -0,0 +1,54 @@ +getName()); + } + + $result = addcslashes(implode(',', array_filter($value)), self::ESCAPE); + $result = '{' . $result . '}'; + + return $result; + } + + public function getName() + { + return self::TEXT_ARRAY; + } +} diff --git a/DQL/ExistsAnyFunction.php b/DQL/ExistsAnyFunction.php index 7a12169..4ead0a0 100755 --- a/DQL/ExistsAnyFunction.php +++ b/DQL/ExistsAnyFunction.php @@ -13,8 +13,8 @@ class ExistsAnyFunction extends FunctionNode public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) { return 'exists_any(' . - $this->hstoreExpression->dispatch($sqlWalker) . ', ARRAY[' . - $this->keyExpression->dispatch($sqlWalker) . '])'; + $this->hstoreExpression->dispatch($sqlWalker) . ', ' . + $this->keyExpression->dispatch($sqlWalker) . ')'; } public function parse(\Doctrine\ORM\Query\Parser $parser) diff --git a/DependencyInjection/IntaroHStoreExtension.php b/DependencyInjection/IntaroHStoreExtension.php index 773ab8b..78bac87 100644 --- a/DependencyInjection/IntaroHStoreExtension.php +++ b/DependencyInjection/IntaroHStoreExtension.php @@ -26,10 +26,12 @@ public function prepend(ContainerBuilder $container) $dbalConfig = [ 'dbal' => [ 'types' => [ - 'hstore' => 'Intaro\HStoreBundle\DBAL\Types\HStoreType' + 'hstore' => 'Intaro\HStoreBundle\DBAL\Types\HStoreType', + 'text_array' => 'Intaro\HStoreBundle\DBAL\Types\TextArrayType' ], 'mapping_types' => [ - 'hstore' => 'hstore' + 'hstore' => 'hstore', + 'text_array' => 'text_array' ], ], 'orm' => [ From 36fa8a0f45d1697b119adafb9d2a91b2688f6a91 Mon Sep 17 00:00:00 2001 From: 1on Date: Mon, 22 Dec 2014 17:26:48 +0300 Subject: [PATCH 2/2] ExistsAny function removed. text_array type removed. --- DBAL/Types/TextArrayType.php | 54 ------------------- DQL/ExistsAnyFunction.php | 29 ---------- DependencyInjection/IntaroHStoreExtension.php | 7 +-- 3 files changed, 2 insertions(+), 88 deletions(-) delete mode 100644 DBAL/Types/TextArrayType.php delete mode 100755 DQL/ExistsAnyFunction.php diff --git a/DBAL/Types/TextArrayType.php b/DBAL/Types/TextArrayType.php deleted file mode 100644 index 8776d4d..0000000 --- a/DBAL/Types/TextArrayType.php +++ /dev/null @@ -1,54 +0,0 @@ -getName()); - } - - $result = addcslashes(implode(',', array_filter($value)), self::ESCAPE); - $result = '{' . $result . '}'; - - return $result; - } - - public function getName() - { - return self::TEXT_ARRAY; - } -} diff --git a/DQL/ExistsAnyFunction.php b/DQL/ExistsAnyFunction.php deleted file mode 100755 index 4ead0a0..0000000 --- a/DQL/ExistsAnyFunction.php +++ /dev/null @@ -1,29 +0,0 @@ -hstoreExpression->dispatch($sqlWalker) . ', ' . - $this->keyExpression->dispatch($sqlWalker) . ')'; - } - - public function parse(\Doctrine\ORM\Query\Parser $parser) - { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); - $this->hstoreExpression = $parser->StringPrimary(); - $parser->match(Lexer::T_COMMA); - $this->keyExpression = $parser->StringPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); - } -} diff --git a/DependencyInjection/IntaroHStoreExtension.php b/DependencyInjection/IntaroHStoreExtension.php index 78bac87..bc9eaf5 100644 --- a/DependencyInjection/IntaroHStoreExtension.php +++ b/DependencyInjection/IntaroHStoreExtension.php @@ -26,12 +26,10 @@ public function prepend(ContainerBuilder $container) $dbalConfig = [ 'dbal' => [ 'types' => [ - 'hstore' => 'Intaro\HStoreBundle\DBAL\Types\HStoreType', - 'text_array' => 'Intaro\HStoreBundle\DBAL\Types\TextArrayType' + 'hstore' => 'Intaro\HStoreBundle\DBAL\Types\HStoreType' ], 'mapping_types' => [ - 'hstore' => 'hstore', - 'text_array' => 'text_array' + 'hstore' => 'hstore' ], ], 'orm' => [ @@ -39,7 +37,6 @@ public function prepend(ContainerBuilder $container) 'string_functions' => [ 'contains' => 'Intaro\HStoreBundle\DQL\ContainsFunction', 'defined' => 'Intaro\HStoreBundle\DQL\DefinedFunction', - 'existsAny' => 'Intaro\HStoreBundle\DQL\ExistsAnyFunction', 'hstoreDifference' => 'Intaro\HStoreBundle\DQL\HstoreDifferenceFunction', 'fetchval' => 'Intaro\HStoreBundle\DQL\FetchvalFunction' ]