diff --git a/src/QueryObject/PostgreQueryObjectInterface.php b/src/QueryObject/PostgreQueryObjectInterface.php new file mode 100644 index 0000000..de93ab9 --- /dev/null +++ b/src/QueryObject/PostgreQueryObjectInterface.php @@ -0,0 +1,10 @@ +addColumnPrefix($_column); $_column = $this->getJoinedEntityColumnName($_column); + if ($this instanceof PostgreQueryObjectInterface && $this->hasDqlStringFunction('CAST')) { + switch ($mode) { + case QueryObjectByMode::EQUALS: + case QueryObjectByMode::NOT_EQUALS: + case QueryObjectByMode::STARTS_WITH: + case QueryObjectByMode::ENDS_WITH: + case QueryObjectByMode::CONTAINS: + case QueryObjectByMode::NOT_CONTAINS: + case QueryObjectByMode::IS_NULL: + case QueryObjectByMode::IS_NOT_NULL: + case QueryObjectByMode::IN_ARRAY: + case QueryObjectByMode::NOT_IN_ARRAY: + $_column = sprintf('CAST(%s AS TEXT)', $_column); + break; + } + } + switch ($mode) { case QueryObjectByMode::EQUALS: $condition = "$_column = :$paramName"; @@ -981,4 +999,11 @@ final public function addPostFetch(string $fieldName): static $this->postFetch[] = $fieldName; return $this; } + + protected function hasDqlStringFunction(string $name): bool + { + $config = $this->em->getConfiguration(); + + return (bool)$config->getCustomStringFunction($name); + } }