Skip to content

Commit

Permalink
[Doctrine] Use parameters instead of embedded
Browse files Browse the repository at this point in the history
In a very old version it was possible to have either embedded values
or parameters. Then to simplify generation, embedded values were introduced.

However, Doctrine ORM doesn't have a native escaping system for embedding values
directly. Making the current system rather hacky, plus that the previous parameter system
didn't allow value-splitting in conversions.

Note. DBAL conversions are no longer applied in ORM, ORM now has it's own
conversion API that operates directly with DQL (not SQL). Meaning special
functions must be registered separately.

_Minimum PHP version for the monorep was updated to PHP 7.2_
  • Loading branch information
sstok committed Sep 13, 2020
1 parent f86be19 commit bdb25e9
Show file tree
Hide file tree
Showing 84 changed files with 2,036 additions and 2,425 deletions.
38 changes: 0 additions & 38 deletions .github/phpunit/mysql.xml

This file was deleted.

38 changes: 0 additions & 38 deletions .github/phpunit/pgsql.xml

This file was deleted.

24 changes: 0 additions & 24 deletions .github/phpunit/sqlite.xml

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ env:
ES_HTTP_PORT: '59200'
ELASTICSEARCH_HOST: 'localhost'
ELASTICSEARCH_PORT: '59200'
DB_HOST: 127.0.0.1

jobs:
test:
Expand Down Expand Up @@ -89,9 +90,8 @@ jobs:
SYMFONY_DEPRECATIONS_HELPER: weak
run: |
vendor/bin/phpunit --verbose
vendor/bin/phpunit --verbose --configuration .github/phpunit/sqlite.xml
vendor/bin/phpunit --verbose --configuration .github/phpunit/pgsql.xml
vendor/bin/phpunit --verbose --configuration .github/phpunit/mysql.xml
vendor/bin/phpunit --verbose --configuration phpunit/pgsql.xml
vendor/bin/phpunit --verbose --configuration phpunit/mysql.xml
lint:
name: PHP-QA
Expand Down
54 changes: 52 additions & 2 deletions UPGRADE-2.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,61 @@ UPGRADE FROM 2.0-ALPHA21 to 2.0-ALPHA22

* The `$forceNew` argument in `SearchConditionBuilder::field()` is deprecated and will
be removed in v2.0.0-BETA1, use `overwriteField()` instead.

### Doctrine DBAL

* Support for SQLite was removed in Doctrine DBAL.

* Values are no longer embedded but are now provided as parameters,
make sure to bind these before executing the query.

Before:

```php
$whereClause = $conditionGenerator->getWhereClause();
$statement = $connection->execute('SELECT * FROM tableName '.$whereClause);

$rows = $statement->fetchAll(\PDO::FETCH_ASSOC);
```

Now:

```php
$whereClause = $conditionGenerator->getWhereClause();
$statement = $connection->prepare('SELECT * FROM tableName '.$whereClause);

* Support for Doctrine ORM NativeQuery was removed, use the Doctrine DBAL
$conditionGenerator->bindParameters($statement);

$statement->execute();

$rows = $statement->fetchAll(\PDO::FETCH_ASSOC);
```

* The `Rollerworks\Component\Search\Doctrine\Dbal\ValueConversion::convertValue()` method
now expects a `string` type is returned, and requires a return-type.

* Conversion strategies was changed to return a different column/value
statement rather than keeping all strategies cached.

Use the `ConversionHint` new parameters and helper method to determine
the value for the Column.

### Doctrine ORM

* Support for Doctrine ORM NativeQuery was removed, use the Doctrine DBAL
condition-generator instead for this usage.

* Values are no longer embedded but are now provided as parameters,
make sure to bind these before executing the query.

Note: Using the `updateQuery()` method already performs the binding process.

* Doctrine DBAL conversions are no longer applied, instead the Doctrine ORM
integration now has it's own conversion API with a much more powerful integration.

**Note:** Any functions used in the conversion-generated DQL must be registered
with the EntityManager configuration, refer to the Doctrine ORM manual for details.

* Support for SQLite was removed in Doctrine DBAL and ORM.

UPGRADE FROM 2.0-ALPHA19 to 2.0-ALPHA20
=======================================
Expand Down
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
],
"require": {
"php": "^7.1",
"php": "^7.2",
"psr/container": "^1.0.0",
"symfony/intl": "^4.4 || ^5.0",
"symfony/options-resolver": "^4.4 || ^5.0",
Expand All @@ -35,9 +35,9 @@
},
"require-dev": {
"api-platform/core": "^2.4.5",
"doctrine/dbal": "^2.8.0",
"doctrine/dbal": "^2.10.3",
"doctrine/doctrine-bundle": "^1.9.1 || ^2.0",
"doctrine/orm": "^2.6.2",
"doctrine/orm": "^2.7.3",
"friendsofsymfony/elastica-bundle": "^5.0 || ^5.2@dev",
"matthiasnoback/symfony-dependency-injection-test": "^3.0 || ^4.1.1",
"moneyphp/money": "^3.2.0",
Expand All @@ -62,6 +62,7 @@
},
"config": {
"preferred-install": {
"api-platform/core": "source",
"doctrine/dbal": "source",
"doctrine/orm": "source",
"*": "dist"
Expand Down
Loading

0 comments on commit bdb25e9

Please sign in to comment.