Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manually merge 3.0.x into master #4432

Merged
merged 45 commits into from
Nov 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
22a95b2
Improve formatting and grammar in the upgrade guide
greg0ire Oct 23, 2020
3becaec
Merge pull request #4384 from greg0ire/proofread-upgrade-guide
greg0ire Oct 24, 2020
a500d5e
Fix headline in the upgrade docs
jdreesen Oct 28, 2020
1906c5f
Merge pull request #4390 from jdreesen/patch-1
greg0ire Oct 28, 2020
f80b055
Remove segfault comment from PDOOracle driver
mvorisek Oct 31, 2020
09eafbc
Catch PDOException
greg0ire Oct 31, 2020
b8665ec
Merge pull request #4396 from greg0ire/fix-php8-mysql-mariadb
morozov Nov 1, 2020
435c7fd
Update PHP_CodeSniffer to 3.5.8
morozov Nov 1, 2020
c2b989e
Merge pull request #4398 from morozov/phpcs-3.5.8
morozov Nov 1, 2020
d67f89d
Merge branch '2.12.x' into 3.0.x
morozov Nov 1, 2020
29fc5c6
Remove no longer valid comment - pdo_oci is maintaned by php people
mvorisek Nov 1, 2020
26fe027
Store query in driver exceptions
BenMorel Oct 5, 2020
83113ce
Merge pull request #4387 from BenMorel/exception-params
morozov Nov 1, 2020
cad295a
Merge pull request #4393 from mvorisek/patch-1
morozov Nov 1, 2020
7b4f16a
Deprecate colon prefix for prepared statement parameters
morozov Nov 3, 2020
d76bf72
Add missing instanceof check
BenMorel Nov 1, 2020
1a9da6d
Merge pull request #4401 from BenMorel/unused-var
morozov Nov 3, 2020
ff83e0b
Merge pull request #4407 from morozov/deprecate-named-param-colon-prefix
morozov Nov 4, 2020
9babd9e
Deprecate inappropriate usage of prepared statement parameters
morozov Nov 5, 2020
403b27f
Remove support for colon prefix in statement parameters
morozov Nov 3, 2020
f91860d
Merge pull request #4410 from morozov/remove-named-param-colon-prefix
morozov Nov 5, 2020
3622d6d
Merge pull request #4411 from morozov/deprecate-parser-abuse
morozov Nov 5, 2020
7322944
Remove redundant phpstan param from DriverManager::getConnection()
simPod Nov 2, 2020
12508e6
ResultCacheStatement::fetchAllAssociative does not store results in c…
morozov Nov 8, 2020
97ee7c4
Merge pull request #4414 from morozov/issues/4406
greg0ire Nov 8, 2020
b085da7
Testing Guidelines
morozov Oct 18, 2020
d31c697
Merge pull request #4356 from morozov/testing-guidelines
SenseException Nov 8, 2020
b63a652
Added /ci to .gitattributes
bytestream Nov 9, 2020
32f96b1
Merge pull request #4416 from bytestream/bytestream-patch-1
morozov Nov 9, 2020
d3c8a87
QueryBuilder must use 0-based positional parameter keys
morozov Nov 11, 2020
f716ba6
Add missing word
greg0ire Nov 11, 2020
75b309e
Merge pull request #4423 from doctrine/greg0ire-patch-1
greg0ire Nov 11, 2020
3b90aba
Merge pull request #4422 from morozov/issues/4421
morozov Nov 11, 2020
1c908c3
Mark SQLParserUtils internal
morozov Nov 11, 2020
5f94000
Merge pull request #4424 from morozov/sql-parser-utils-internal
morozov Nov 11, 2020
a501e55
Merge branch '2.12.x' into 3.0.x
morozov Nov 12, 2020
4fbd7ac
Port SQL parser from PDO
morozov Nov 1, 2020
3ed11aa
LockMode::NONE should not set WITH (NOLOCK)
BenMorel Nov 1, 2020
74bc147
Merge pull request #4400 from BenMorel/with-nolock
morozov Nov 12, 2020
6d151f9
Throw exception on invalid LockMode
morozov Nov 13, 2020
e456ab1
Merge pull request #4429 from morozov/issues/4428
morozov Nov 13, 2020
041df42
Merge pull request #4397 from morozov/issues/4383
morozov Nov 14, 2020
c2c8488
Merge pull request #4403 from simPod/patch-1
morozov Nov 14, 2020
0f55c0d
Merge branch '2.12.x' into 3.0.x
morozov Nov 14, 2020
d13a24d
Merge branch '3.0.x'
morozov Nov 14, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/.appveyor.yml export-ignore
/ci export-ignore
/composer.lock export-ignore
/docs export-ignore
/.doctrine-project.json export-ignore
Expand Down
151 changes: 112 additions & 39 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ The Doctrine\DBAL\Version class is no longer available: please refrain from chec

# Upgrade to 3.0

## BC BREAK: leading colon in named parameter names not supported

The usage of the colon prefix when binding named parameters is no longer supported.

## BC BREAK `Doctrine\DBAL\Abstraction\Result` removed

The `Doctrine\DBAL\Abstraction\Result` interface is removed. Use the `Doctrine\DBAL\Result` class instead.
Expand All @@ -264,23 +268,22 @@ The `Doctrine\DBAL\Types\Type::getDefaultLength()` method has been removed as it

## BC BREAK: `Doctrine\DBAL\DBALException` class renamed

The `Doctrine\DBAL\DBALException` class has been renamed to `Doctrine\DBAL\Exception`.
The `Doctrine\DBAL\DBALException` class has been renamed to `Doctrine\DBAL\Exception`.

## BC BREAK: Doctrine\DBAL\Schema\Table constructor new parameter
## BC BREAK: `Doctrine\DBAL\Schema\Table` constructor new parameter

Deprecated parameter `$idGeneratorType` removed and added a new parameter `$uniqueConstraints`.
Constructor changed from:

`__construct($name, array $columns = [], array $indexes = [], array $fkConstraints = [], $idGeneratorType = 0, array $options = [])`

To the new constructor:
Constructor changed like so:

`__construct($name, array $columns = [], array $indexes = [], array $uniqueConstraints = [], array $fkConstraints = [], array $options = [])`
```diff
- __construct($name, array $columns = [], array $indexes = [], array $fkConstraints = [], $idGeneratorType = 0, array $options = [])
+ __construct($name, array $columns = [], array $indexes = [], array $uniqueConstraints = [], array $fkConstraints = [], array $options = [])
```

## BC BREAK: change in the behavior of `SchemaManager::dropDatabase()`

When dropping a database, the DBAL no longer attempts to kill the client sessions that use the database.
It's the responsibility of the operator to make sure that the database is not being used.
It's the responsibility of the operator to make sure that the database is not being used.

## BC BREAK: removed `Synchronizer` package

Expand All @@ -298,14 +301,14 @@ The following methods of the `Connection` class have been removed:

The wrapper-level `Connection` and `Statement` classes no longer implement the corresponding driver-level interfaces.

## BC BREAK: Removed DBALException factory methods
## BC BREAK: Removed `DBALException` factory methods

The following factory methods of the DBALException class have been removed:
The following factory methods of the `DBALException` class have been removed:

1. `DBALException::invalidPlatformSpecified()`.
2. `DBALException::invalidPdoInstance()`.

## BC BREAK: PDO-based driver classes are moved under the PDO namespace
## BC BREAK: PDO-based driver classes are moved under the `PDO` namespace

The following classes have been renamed:

Expand All @@ -331,17 +334,17 @@ The following classes have been renamed:

## BC BREAK: Changes in wrapper-level exceptions

1. `DBALException::invalidTableName()` has been replaced with the `InvalidTableName` class.
`DBALException::invalidTableName()` has been replaced with the `InvalidTableName` class.

## BC BREAK: Changes in driver-level exception handling

1. The `convertException()` method has been removed from the `Driver` interface. The logic of exception conversion has been moved to the `ExceptionConverter` interface. The drivers now must implement the `getExceptionConverter()` method.
2. The `driverException()` and `driverExceptionDuringQuery()` factory methods have been removed from the `DBALException` class.
3. Non-driver exceptions (e.g. exceptions of type `Error`) are no longer wrapped in a `DBALException`.

## BC BREAK: More driver-level methods are allowed to throw a Driver\Exception.
## BC BREAK: More driver-level methods are allowed to throw a `Driver\Exception`.

The following driver-level methods are allowed to throw a Driver\Exception:
The following driver-level methods are allowed to throw a `Driver\Exception`:

- `Connection::prepare()`
- `Connection::lastInsertId()`
Expand Down Expand Up @@ -454,7 +457,7 @@ The `Doctrine\DBAL\Driver::getName()` has been removed.

## BC BREAK changes the `Driver::connect()` signature

The method no longer accepts the `$username`, `$password` and `$driverOptions` arguments. The corresponding values are expected to be passed as the "user", "password" and "driver_options" keys of the `$params` argument respectively.
The method no longer accepts the `$username`, `$password` and `$driverOptions` arguments. The corresponding values are expected to be passed as the `"user"`, `"password"` and `"driver_options"` keys of the `$params` argument respectively.

## Removed `MasterSlaveConnection`

Expand Down Expand Up @@ -538,15 +541,15 @@ The following classes have been removed:
DBAL now requires MariaDB 10.1 or newer, support for unmaintained versions has been dropped.
If you are using any of the legacy versions, you have to upgrade to a newer MariaDB version (10.1+ is recommended).

## BC BREAK: The ServerInfoAwareConnection interface now extend Connection
## BC BREAK: The `ServerInfoAwareConnection` interface now extends `Connection`

All implementations of the `ServerInfoAwareConnection` interface have to implement the methods defined in the `Connection` interface as well.

## BC BREAK: VersionAwarePlatformDriver interface now extends Driver
## BC BREAK: `VersionAwarePlatformDriver` interface now extends `Driver`

All implementations of the `VersionAwarePlatformDriver` interface have to implement the methods defined in the `Driver` interface as well.

## BC BREAK: Removed MsSQLKeywords class
## BC BREAK: Removed `MsSQLKeywords` class

The `Doctrine\DBAL\Platforms\MsSQLKeywords` class has been removed.
Please use `Doctrine\DBAL\Platforms\SQLServerPlatform `instead.
Expand Down Expand Up @@ -575,7 +578,7 @@ The following classes have been removed:

The `AbstractSQLServerDriver` class and its subclasses no longer implement the `VersionAwarePlatformDriver` interface.

## BC BREAK: Removed Doctrine\DBAL\Version
## BC BREAK: Removed `Doctrine\DBAL\Version`

The `Doctrine\DBAL\Version` class is no longer available: please refrain from checking the DBAL version at runtime.

Expand All @@ -591,36 +594,40 @@ In order to share the same `PDO` instances between DBAL and other components, in

Before:

use Doctrine\DBAL\Portability\Connection;
```php
use Doctrine\DBAL\Portability\Connection;

$params = array(
'wrapperClass' => Connection::class,
'fetch_case' => PDO::CASE_LOWER,
);
$params = array(
'wrapperClass' => Connection::class,
'fetch_case' => PDO::CASE_LOWER,
);

$stmt->bindValue(1, 1, PDO::PARAM_INT);
$stmt->fetchAll(PDO::FETCH_COLUMN);
$stmt->bindValue(1, 1, PDO::PARAM_INT);
$stmt->fetchAll(PDO::FETCH_COLUMN);
```

After:

use Doctrine\DBAL\ColumnCase;
use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Portability\Connection;
```php
use Doctrine\DBAL\ColumnCase;
use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Portability\Connection;

$params = array(
'wrapperClass' => Connection::class,
'fetch_case' => ColumnCase::LOWER,
);
$params = array(
'wrapperClass' => Connection::class,
'fetch_case' => ColumnCase::LOWER,
);

$stmt->bindValue(1, 1, ParameterType::INTEGER);
$stmt->fetchAll(FetchMode::COLUMN);
$stmt->bindValue(1, 1, ParameterType::INTEGER);
$stmt->fetchAll(FetchMode::COLUMN);
```

## BC BREAK: Removed Drizzle support

The Drizzle project is abandoned and is therefore not supported by Doctrine DBAL anymore.

## BC BREAK: Removed dbal:import CLI command
## BC BREAK: Removed `dbal:import` CLI command

The `dbal:import` CLI command has been removed since it only worked with PDO-based drivers by relying on a non-documented behavior of the extension, and it was impossible to make it work with other drivers.
Please use other database client applications for import, e.g.:
Expand All @@ -629,8 +636,74 @@ Please use other database client applications for import, e.g.:
* For PostgreSQL: `psql [dbname] < data.sql`.
* For SQLite: `sqlite3 /path/to/file.db < data.sql`.

## BC BREAK: Changed signature of `ExceptionConverter::convert()`

Before:

```php
public function convert(string $message, Doctrine\DBAL\Driver\Exception $exception): DriverException
```

After:

```php
public function convert(Doctrine\DBAL\Driver\Exception $exception, ?Doctrine\DBAL\Query $query): DriverException
```

## BC Break: The `DriverException` constructor is now internal

The constructor of `Doctrine\DBAL\Exception\DriverException` is now `@internal`.

# Upgrade to 2.12

## Deprecated non-zero based positional parameter keys

The usage of one-based and other non-zero-based keys when binding positional parameters is deprecated.

It is recommended to not use any array keys so that the value of the parameter array complies with the [`list<>`](https://psalm.dev/docs/annotating_code/type_syntax/array_types/) type constraint.

```php
// This is valid (implicit zero-based parameter indexes)
$conn->fetchNumeric('SELECT ?, ?', [1, 2]);

// This is invalid (one-based parameter indexes)
$conn->fetchNumeric('SELECT ?, ?', [1 => 1, 2 => 2]);

// This is invalid (arbitrary parameter indexes)
$conn->fetchNumeric('SELECT ?, ?', [-31 => 1, 5 => 2]);

// This is invalid (non-sequential parameter indexes)
$conn->fetchNumeric('SELECT ?, ?', [0 => 1, 3 => 2]);
```

## Deprecated skipping prepared statement parameters

Some underlying drivers currently allow skipping prepared statement parameters. For instance:

```php
$conn->fetchOne('SELECT ?');
// NULL
```

This behavior should not be relied upon and may change in future versions.

## Deprecated colon prefix for prepared statement parameters

The usage of the colon prefix when binding named parameters is deprecated.

```php
$sql = 'SELECT * FROM users WHERE name = :name OR username = :username';
$stmt = $conn->prepare($sql);

// The usage of the leading colon is deprecated
$stmt->bindValue(':name', $name);

// Only the parameter name should be passed
$stmt->bindValue('username', $username);

$stmt->execute();
```

## PDO signature changes with php 8

In php 8.0, the method signatures of two PDO classes which are extended by DBAL have changed. This affects the following classes:
Expand Down Expand Up @@ -707,7 +780,7 @@ The following PDO-related classes outside of the PDO namespace have been depreca
3. `prefersSequences()`.
4. `supportsForeignKeyOnUpdate()`.

##`ServerInfoAwareConnection::requiresQueryForServerVersion()` is deprecated.
## `ServerInfoAwareConnection::requiresQueryForServerVersion()` is deprecated.

The `ServerInfoAwareConnection::requiresQueryForServerVersion()` method has been deprecated as an implementation detail which is the same for almost all supported drivers.

Expand Down
17 changes: 11 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions docs/en/reference/data-retrieval-and-manipulation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ are then replaced by their actual values in a second step (execute).
$stmt->bindValue(1, $id);
$stmt->execute();

Placeholders in prepared statements are either simple positional question marks (?) or named labels starting with
a double-colon (:name1). You cannot mix the positional and the named approach. The approach
using question marks is called positional, because the values are bound in order from left to right
Placeholders in prepared statements are either simple positional question marks (``?``) or named labels starting with
a colon (e.g. ``:name1``). You cannot mix the positional and the named approach. You have to bind a parameter
to each placeholder.

The approach using question marks is called positional, because the values are bound in order from left to right
to any question mark found in the previously prepared SQL query. That is why you specify the
position of the variable to bind into the ``bindValue()`` method:

Expand Down
Loading