Skip to content

Commit

Permalink
Merge pull request #76 from piotaixr/feature/dbal3.0
Browse files Browse the repository at this point in the history
Make code compatible (and requiring) Doctrine ORM 2.10 and DBAL 3.0
  • Loading branch information
Hikariii committed Jan 12, 2022
2 parents f65796d + b3b8e0f commit a5a2309
Show file tree
Hide file tree
Showing 61 changed files with 130 additions and 209 deletions.
99 changes: 58 additions & 41 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,44 +1,61 @@
{
"name": "scienta/doctrine-json-functions",
"name": "scienta/doctrine-json-functions",
"abandoned": false,
"type": "library",
"description": "A set of extensions to Doctrine 2 that add support for json query functions.",
"keywords": ["doctrine", "orm", "json", "dql", "database", "mysql", "postgres", "postgresql", "mariadb", "sqlite"],
"license": "MIT",
"authors": [
{
"name": "Doctrine Json Functions Contributors",
"homepage": "https://github.com/ScientaNL/DoctrineJsonFunctions/contributors"
}
],
"require": {
"php": "^7.1 || ^8.0",
"ext-pdo": "*",
"doctrine/orm": "2.*",
"doctrine/dbal": "2.*"
},
"require-dev": {
"doctrine/orm": "^2.7",
"doctrine/coding-standard": "^8.0 || ^9.0",
"phpunit/phpunit": "^8.0 || ^9.0"
},
"autoload": {
"psr-4": {
"Scienta\\DoctrineJsonFunctions\\" : "src/"
}
},
"autoload-dev": {
"psr-4": {
"Doctrine\\Tests\\": "tests/Doctrine/Tests",
"Scienta\\DoctrineJsonFunctions\\Tests\\": "tests/"
}
},
"extra": {
"branch-alias": {
"dev-master": "4.1-dev"
}
},
"suggest": {
"dunglas/doctrine-json-odm": "To serialize / deserialize objects as JSON documents."
}
"type": "library",
"description": "A set of extensions to Doctrine 2 that add support for json query functions.",
"keywords": [
"doctrine",
"orm",
"json",
"dql",
"database",
"mysql",
"postgres",
"postgresql",
"mariadb",
"sqlite"
],
"license": "MIT",
"authors": [
{
"name": "Doctrine Json Functions Contributors",
"homepage": "https://github.com/ScientaNL/DoctrineJsonFunctions/contributors"
}
],
"require": {
"php": "^7.3 || ^8.0",
"ext-pdo": "*",
"doctrine/orm": "^2.0",
"doctrine/dbal": "^3.0"
},
"require-dev": {
"doctrine/coding-standard": "^8.0 || ^9.0",
"phpunit/phpunit": "^8.0 || ^9.0",
"doctrine/annotations": "^1.13"
},
"autoload": {
"psr-4": {
"Scienta\\DoctrineJsonFunctions\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Doctrine\\Tests\\": "tests/Doctrine/Tests",
"Scienta\\DoctrineJsonFunctions\\Tests\\": "tests/"
}
},
"extra": {
"branch-alias": {
"dev-master": "4.1-dev"
}
},
"suggest": {
"dunglas/doctrine-json-odm": "To serialize / deserialize objects as JSON documents."
},
"config": {
"allow-plugins": {
"composer/package-versions-deprecated": true,
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
6 changes: 3 additions & 3 deletions src/Query/AST/Functions/AbstractJsonFunctionNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Scienta\DoctrineJsonFunctions\Query\AST\Functions;

use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Exception;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\AST\Literal;
use Doctrine\ORM\Query\AST\Node;
Expand Down Expand Up @@ -153,7 +153,7 @@ private function matchStringLiteral(Parser $parser, Lexer $lexer): Literal
/**
* @param SqlWalker $sqlWalker
* @return string
* @throws DBALException
* @throws Exception
* @throws \Doctrine\ORM\Query\AST\ASTException
*/
public function getSql(SqlWalker $sqlWalker): string
Expand Down Expand Up @@ -190,7 +190,7 @@ protected function getSQLFunction(): string

/**
* @param SqlWalker $sqlWalker
* @throws DBALException
* @throws Exception
*/
abstract protected function validatePlatform(SqlWalker $sqlWalker): void;
}
10 changes: 5 additions & 5 deletions src/Query/AST/Functions/Mariadb/MariadbJsonFunctionNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

namespace Scienta\DoctrineJsonFunctions\Query\AST\Functions\Mariadb;

use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\ORM\Query\SqlWalker;
use Scienta\DoctrineJsonFunctions\Query\AST\Functions\AbstractJsonFunctionNode;

abstract class MariadbJsonFunctionNode extends AbstractJsonFunctionNode
{
/**
* @param SqlWalker $sqlWalker
* @throws DBALException
* @throws Exception
*/
protected function validatePlatform(SqlWalker$sqlWalker): void
{
if (!$sqlWalker->getConnection()->getDatabasePlatform() instanceof MySqlPlatform) {
throw DBALException::notSupported(static::FUNCTION_NAME);
if (!$sqlWalker->getConnection()->getDatabasePlatform() instanceof MySQLPlatform) {
throw Exception::notSupported(static::FUNCTION_NAME);
}
}
}
7 changes: 0 additions & 7 deletions src/Query/AST/Functions/Mysql/JsonContains.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@

namespace Scienta\DoctrineJsonFunctions\Query\AST\Functions\Mysql;

use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;

/**
* "JSON_CONTAINS" "(" StringPrimary "," StringPrimary {"," StringPrimary } ")"
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Query/AST/Functions/Mysql/JsonContainsPath.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Scienta\DoctrineJsonFunctions\Query\AST\Functions\Mysql;

use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Exception;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;

Expand All @@ -15,7 +15,7 @@ class JsonContainsPath extends JsonSearch

/**
* @param Parser $parser
* @throws DBALException
* @throws Exception
* @throws \Doctrine\ORM\Query\QueryException
*/
public function parse(Parser $parser): void
Expand Down
7 changes: 0 additions & 7 deletions src/Query/AST/Functions/Mysql/JsonExtract.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@

namespace Scienta\DoctrineJsonFunctions\Query\AST\Functions\Mysql;

use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;

/**
* "JSON_EXTRACT" "(" StringPrimary "," StringPrimary {"," StringPrimary }* ")"
*/
Expand Down
7 changes: 0 additions & 7 deletions src/Query/AST/Functions/Mysql/JsonKeys.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@

namespace Scienta\DoctrineJsonFunctions\Query\AST\Functions\Mysql;

use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;

/**
* "JSON_KEYS" "(" StringPrimary {"," StringPrimary } ")"
*/
Expand Down
7 changes: 0 additions & 7 deletions src/Query/AST/Functions/Mysql/JsonMerge.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@

namespace Scienta\DoctrineJsonFunctions\Query\AST\Functions\Mysql;

use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;

/**
* "JSON_MERGE" "(" StringPrimary "," StringPrimary { "," StringPrimary }* ")"
*/
Expand Down
7 changes: 0 additions & 7 deletions src/Query/AST/Functions/Mysql/JsonMergePatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@

namespace Scienta\DoctrineJsonFunctions\Query\AST\Functions\Mysql;

use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;

/**
* "JSON_MERGE_PATCH" "(" StringPrimary "," StringPrimary { "," StringPrimary }* ")"
*/
Expand Down
7 changes: 0 additions & 7 deletions src/Query/AST/Functions/Mysql/JsonOverlaps.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@

namespace Scienta\DoctrineJsonFunctions\Query\AST\Functions\Mysql;

use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;

/**
* "JSON_OVERLAPS" "(" StringPrimary "," StringPrimary ")"
*/
Expand Down
7 changes: 0 additions & 7 deletions src/Query/AST/Functions/Mysql/JsonPretty.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@

namespace Scienta\DoctrineJsonFunctions\Query\AST\Functions\Mysql;

use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;

/**
* "JSON_PRETTY" "(" NewValue ")"
*/
Expand Down
7 changes: 0 additions & 7 deletions src/Query/AST/Functions/Mysql/JsonQuote.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@

namespace Scienta\DoctrineJsonFunctions\Query\AST\Functions\Mysql;

use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;

/**
* "JSON_QUOTE" "(" NewValue ")"
*/
Expand Down
8 changes: 4 additions & 4 deletions src/Query/AST/Functions/Mysql/JsonSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Scienta\DoctrineJsonFunctions\Query\AST\Functions\Mysql;

use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Exception;
use Doctrine\ORM\Query\AST\Node;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
Expand Down Expand Up @@ -31,7 +31,7 @@ class JsonSearch extends MysqlJsonFunctionNode

/**
* @param Parser $parser
* @throws DBALException
* @throws Exception
* @throws \Doctrine\ORM\Query\QueryException
*/
public function parse(Parser $parser): void
Expand Down Expand Up @@ -61,7 +61,7 @@ public function parse(Parser $parser): void

/**
* @param Parser $parser
* @throws DBALException
* @throws Exception
* @return Node
*/
protected function parsePathMode(Parser $parser)
Expand All @@ -78,6 +78,6 @@ protected function parsePathMode(Parser $parser)
return $parser->Literal();
}

throw DBALException::notSupported("Mode '$value' is not supported by " . static::FUNCTION_NAME . ".");
throw Exception::notSupported("Mode '$value' is not supported by " . static::FUNCTION_NAME . ".");
}
}
7 changes: 0 additions & 7 deletions src/Query/AST/Functions/Mysql/JsonType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@

namespace Scienta\DoctrineJsonFunctions\Query\AST\Functions\Mysql;

use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;

/**
* "JSON_TYPE" "(" StringPrimary ")"
*/
Expand Down
10 changes: 5 additions & 5 deletions src/Query/AST/Functions/Mysql/MysqlJsonFunctionNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

namespace Scienta\DoctrineJsonFunctions\Query\AST\Functions\Mysql;

use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\ORM\Query\SqlWalker;
use Scienta\DoctrineJsonFunctions\Query\AST\Functions\AbstractJsonFunctionNode;

abstract class MysqlJsonFunctionNode extends AbstractJsonFunctionNode
{
/**
* @param SqlWalker $sqlWalker
* @throws DBALException
* @throws Exception
*/
protected function validatePlatform(SqlWalker$sqlWalker): void
{
if (!$sqlWalker->getConnection()->getDatabasePlatform() instanceof MySqlPlatform) {
throw DBALException::notSupported(static::FUNCTION_NAME);
if (!$sqlWalker->getConnection()->getDatabasePlatform() instanceof MySQLPlatform) {
throw Exception::notSupported(static::FUNCTION_NAME);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

namespace Scienta\DoctrineJsonFunctions\Query\AST\Functions\Postgresql;

use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
use Doctrine\ORM\Query\SqlWalker;
use Scienta\DoctrineJsonFunctions\Query\AST\Functions\AbstractJsonFunctionNode;

abstract class PostgresqlJsonFunctionNode extends AbstractJsonFunctionNode
{
/**
* @param SqlWalker $sqlWalker
* @throws DBALException
* @throws Exception
*/
protected function validatePlatform(SqlWalker$sqlWalker): void
{
if (!$sqlWalker->getConnection()->getDatabasePlatform() instanceof PostgreSqlPlatform) {
throw DBALException::notSupported(static::FUNCTION_NAME);
if (!$sqlWalker->getConnection()->getDatabasePlatform() instanceof PostgreSQL94Platform) {
throw Exception::notSupported(static::FUNCTION_NAME);
}
}

Expand Down
Loading

0 comments on commit a5a2309

Please sign in to comment.