Skip to content

Commit

Permalink
Replace MysqlPlatform check with AbstractMySQLPlatform for MariaDB co…
Browse files Browse the repository at this point in the history
…mpatibility
  • Loading branch information
alexander-schranz committed Jan 26, 2024
1 parent 3271be8 commit 1fd59eb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/Jackalope/Transport/DoctrineDBAL/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Doctrine\DBAL\Driver\PDO\Connection as PDOConnection;
use Doctrine\DBAL\Exception as DBALException;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
Expand Down Expand Up @@ -1385,7 +1385,7 @@ private function getSystemIdForNode(string $identifier, string $workspaceName =
$query = 'SELECT id FROM phpcr_nodes WHERE identifier = ? AND workspace_name = ?';
} else {
$platform = $this->getConnection()->getDatabasePlatform();
if ($platform instanceof MySQLPlatform) {
if ($platform instanceof AbstractMySQLPlatform) {
$query = 'SELECT id FROM phpcr_nodes WHERE path COLLATE '.$this->getCaseSensitiveEncoding().' = ? AND workspace_name = ?';
} else {
$query = 'SELECT id FROM phpcr_nodes WHERE path = ? AND workspace_name = ?';
Expand Down Expand Up @@ -1713,7 +1713,7 @@ private function moveNode(string $srcAbsPath, string $destAbsPath): void
// Calculate CAST type for CASE statement

$intType = 'integer';
if ($this->getConnection()->getDatabasePlatform() instanceof MySQLPlatform) {
if ($this->getConnection()->getDatabasePlatform() instanceof AbstractMySQLPlatform) {
$intType = 'unsigned';
}

Expand Down
14 changes: 7 additions & 7 deletions src/Jackalope/Transport/DoctrineDBAL/Query/QOMWalker.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
Expand Down Expand Up @@ -119,7 +119,7 @@ public function walkQOMQuery(QueryObjectModel $qom): array
$offset = $qom->getOffset();

if (null !== $offset && null === $limit
&& ($this->platform instanceof MySQLPlatform || $this->platform instanceof SqlitePlatform)
&& ($this->platform instanceof AbstractMySQLPlatform || $this->platform instanceof SqlitePlatform)
) {
$limit = PHP_INT_MAX;
}
Expand Down Expand Up @@ -628,7 +628,7 @@ public function walkNumComparisonConstraint(QOM\PropertyValueInterface $property
$alias = $this->getTableAlias($propertyOperand->getSelectorName().'.'.$propertyOperand->getPropertyName());
$property = $propertyOperand->getPropertyName();

if ($this->platform instanceof MySQLPlatform && '=' === $operator) {
if ($this->platform instanceof AbstractMySQLPlatform && '=' === $operator) {
return sprintf(
"0 != FIND_IN_SET('%s', REPLACE(EXTRACTVALUE(%s.props, '//sv:property[@sv:name=%s]/sv:value'), ' ', ','))",
$literalOperand->getLiteralValue(),
Expand Down Expand Up @@ -806,7 +806,7 @@ private function getLiteralValue(QOM\LiteralInterface $operand): string
*/
private function sqlXpathValueExists(string $alias, string $property): string
{
if ($this->platform instanceof MySQLPlatform) {
if ($this->platform instanceof AbstractMySQLPlatform) {
return sprintf("EXTRACTVALUE(%s.props, 'count(//sv:property[@sv:name=%s]/sv:value[1])') = 1", $alias, Xpath::escape($property));
}

Expand All @@ -826,7 +826,7 @@ private function sqlXpathValueExists(string $alias, string $property): string
*/
private function sqlXpathExtractValue(string $alias, string $property, string $column = 'props'): string
{
if ($this->platform instanceof MySQLPlatform) {
if ($this->platform instanceof AbstractMySQLPlatform) {
return sprintf("EXTRACTVALUE(%s.%s, '//sv:property[@sv:name=%s]/sv:value[1]')", $alias, $column, Xpath::escape($property));
}

Expand All @@ -852,7 +852,7 @@ private function sqlXpathExtractNumValue(string $alias, string $property): strin

private function sqlXpathExtractValueAttribute(string $alias, string $property, string $attribute, int $valueIndex = 1): string
{
if ($this->platform instanceof MySQLPlatform) {
if ($this->platform instanceof AbstractMySQLPlatform) {
return sprintf("EXTRACTVALUE(%s.props, '//sv:property[@sv:name=%s]/sv:value[%d]/@%s')", $alias, Xpath::escape($property), $valueIndex, $attribute);
}

Expand All @@ -875,7 +875,7 @@ private function sqlXpathComparePropertyValue(string $alias, string $property, s
{
$expression = null;

if ($this->platform instanceof MySQLPlatform) {
if ($this->platform instanceof AbstractMySQLPlatform) {
$expression = sprintf("EXTRACTVALUE(%s.props, 'count(//sv:property[@sv:name=%s]/sv:value[text()%%s%%s]) > 0')", $alias, Xpath::escape($property));
// mysql does not escape the backslashes for us, while postgres and sqlite do
$value = Xpath::escapeBackslashes($value);
Expand Down

0 comments on commit 1fd59eb

Please sign in to comment.