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

Fix returning the proper last inserted id in MSSQL #3523

Closed
Changes from 2 commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
8304622
Decouple unique index from unique constraint
guilhermeblanco Sep 22, 2016
ee858e3
Added flag support to unique constraint
guilhermeblanco Sep 22, 2016
708641b
Fixed tests
guilhermeblanco Sep 24, 2016
2bfa56d
Removed identifier generator type from schema table definition
guilhermeblanco Sep 24, 2016
846869f
Fixing rebase with master
guilhermeblanco Jun 21, 2017
bb7ff36
Fixed undefined result of rebase
guilhermeblanco Jun 22, 2017
103d1a3
Moved getSequencePrefix() from ClassMetadata (ORM) to AbstractPlatfor…
guilhermeblanco Jul 11, 2017
66541a0
Bump version to 3.0.x-dev
Majkl578 Jan 5, 2018
e2b67d3
[BC] Removed support for PDO::PARAM_INPUT_OUTPUT in Statement::bindPa…
morozov Dec 27, 2017
b36fd3c
[BC] Replaced extension of \PDOStatement with a composition to avoid …
morozov Jan 2, 2018
3971de2
[BC] Replaced PDO constants with values
morozov Jan 1, 2018
6fcb0ff
Updated UPGRADE.md for 3.x
morozov Dec 25, 2017
7c23689
Drop Doctrine\DBAL\Version in favor of Ocramius\PackageVersions
Majkl578 Jan 5, 2018
101df0c
Drop Drizzle support
BenMorel Mar 7, 2018
768738e
Add note to UPGRADE.md
BenMorel Mar 7, 2018
09c614f
Introduce a null SQL logger
BenMorel Mar 8, 2018
40a8851
Make NullLogger final
BenMorel Mar 8, 2018
7ead557
One-liner for Configuration::getSQLLogger()
BenMorel Mar 8, 2018
7e08661
Change the SQLLogger interface signature
BenMorel Mar 8, 2018
4af1ea1
Add UPGRADE note
BenMorel Mar 8, 2018
b4276f5
Ignore NullLogger in code coverage
BenMorel Mar 8, 2018
e35f9f9
Make SQLLogger implementations final
BenMorel Mar 8, 2018
8f5f3cc
Update UPGRADE.md
BenMorel Mar 8, 2018
b39c81a
Do not accept null in Configuration::setSQLLogger()
BenMorel Mar 8, 2018
1a867b8
Add note about setSQLLogger()
BenMorel Mar 8, 2018
59524c7
Don't catch Exception anymore
BenMorel Mar 9, 2018
cdb0e9f
When rendering SQL, only render the alias if it's different from the …
morozov Mar 13, 2018
e0685e1
Drop support for PostgreSQL <9.3
Majkl578 Mar 16, 2018
7aa3d53
Drop support for SQL Server <2008
Majkl578 Mar 16, 2018
a7589c8
Drop support for SQL Anywhere <16
Majkl578 Mar 16, 2018
cd8dff9
Drop PDO DB2 driver
Majkl578 Mar 17, 2018
0ffd7e8
Remove MsSQLKeywords
Majkl578 Mar 17, 2018
4bbcf60
Reorder keywords and type mappings alphabetically
Majkl578 Mar 17, 2018
658a5e2
Fixed build failure on SQL Server (sqlsrv)
morozov Mar 20, 2018
c10a94d
Fixed build failure on SQL Server (pdo_sqlsrv)
morozov Mar 20, 2018
d8409a7
[DBAL-3079] Reworked the usage of PDO in PDOConnection from inheritan…
morozov Apr 2, 2018
67eb2ef
[DBAL-3079] Added type hints to query-related method parameters and r…
morozov Apr 11, 2018
c1c11a1
Added string mapping in SqlitePlatform - used by make bundle
Apr 28, 2018
3d793b2
[DBAL-3079] Updated upgrade documentation
morozov Apr 12, 2018
59a5ea1
Revert complex type specification in Connection
Majkl578 Apr 20, 2018
983fa1f
Merge pull request #3119 from DeyV/develop
Ocramius Apr 28, 2018
34c3f80
Merge pull request #3113 from Majkl578/revert-complex-type-spec
Majkl578 May 2, 2018
27829b2
Removed support for DB-generated UUIDs
morozov Jul 11, 2018
7522514
Removed the logic of using BLOB columns for BINARY type of fields
morozov Jun 6, 2018
0d6b63d
Fixed and suppressed issues found by PHPStan on develop
morozov Aug 3, 2018
51e7956
Merge pull request #3211 from morozov/issues/3167
morozov Aug 2, 2018
ded8cee
Removed dbal:import CLI command
morozov Aug 7, 2018
35eec30
Merge pull request #3238 from morozov/phpstan-develop
Ocramius Aug 3, 2018
7502b94
Made the OFFSET in LIMIT queries non-nullable
morozov Aug 11, 2018
937fd01
Merge pull request #3241 from morozov/issues/3237
morozov Aug 8, 2018
506a04b
Merge pull request #3248 from morozov/non-nullable-offset
morozov Aug 12, 2018
62b9e66
Remove Doctrine\DBAL\Types\Type::__toString()
Majkl578 Aug 17, 2018
8bbe46a
Remove Doctrine\DBAL\Types\Type::getDefaultLength()
Majkl578 Aug 17, 2018
a282db0
Got rid of func_num_args in AbstractPlatform::getDummySelectSQL()
morozov Oct 6, 2018
32eff18
Transaction-related Statement methods return void
morozov Mar 13, 2019
3d912ba
Statement::fetchColumn() will throw an exception in the case of inval…
morozov Dec 1, 2018
968d971
Handle binding errors in OCI8Statement::execute() and MySQLiStatement…
morozov Dec 1, 2018
f143086
Connection::setAutoCommit() will return void
morozov Mar 13, 2019
cfd1c33
Merge pull request #3417 from morozov/issues/3358
morozov Feb 9, 2019
38382fa
Moved rowCount() from Statement to ResultStatement
morozov Jan 24, 2019
4012f0a
Merge pull request #3480 from morozov/transaction-void
Ocramius Mar 13, 2019
576f094
Merge pull request #3483 from morozov/row-count
morozov Mar 15, 2019
b56fa47
Connection::quote() can only quote strings
morozov Mar 16, 2019
49bbed0
Assert that the username is specified on the connection when listing …
morozov Mar 16, 2019
ff1c22a
Converted Connection and Statement methods which returned false in ca…
morozov Mar 15, 2019
0a6eaaa
Make the $tableName argument of _getPortableTableIndexesList() required
morozov Mar 16, 2019
3ae6993
Merge pull request #3486 from morozov/conn-stmt-void
morozov Mar 16, 2019
2ec034f
Changed the type of `$char` in `AbstractPlatform::getTrimExpression()…
morozov Mar 17, 2019
f89e2f9
Merge pull request #3488 from morozov/quote-only-string
Ocramius Mar 16, 2019
1165b64
Merge pull request #3491 from morozov/get-trim-expr
Ocramius Mar 18, 2019
66416c6
Modified AbstractPlatform::getLocateExpression() and ::getSubstringEx…
morozov Mar 18, 2019
8d76f73
Reworked AbstractPlatform::get*Expression() methods
morozov Mar 22, 2019
3631ed5
Merge pull request #3494 from morozov/get-locate-expr
Ocramius Mar 21, 2019
eb2d67f
Merge pull request #3498 from morozov/get-other-expr
Ocramius Mar 27, 2019
82509ef
Enable strict types
Majkl578 Feb 8, 2019
6ed3302
Merge pull request #2854 from Majkl578/strict-types
morozov Apr 2, 2019
4380ce4
Removed DB2SchemaManager::_getPortableForeignKeyRuleDef()
morozov Mar 30, 2019
532cc11
Merge pull request #3502 from morozov/db2-get-portable-foreign-key-ru…
Majkl578 Apr 3, 2019
1d8921c
Reworking driver exceptions
morozov Apr 5, 2019
6fb21e1
Merge pull request #3505 from morozov/driver-exceptions
Ocramius Apr 5, 2019
6ee1d09
Removed errorCode() and errorInfo() methods from Connection and State…
morozov Apr 5, 2019
6029aeb
Reworked `AbstractSchemaManager::extractDoctrineTypeFromComment()` re…
morozov Mar 29, 2019
af11239
Merge pull request #3507 from morozov/error-code-info
Ocramius Apr 6, 2019
62f7ad8
Drop support for feferred misspelling in
jwage Apr 17, 2019
3ed2f25
Merge pull request #3501 from morozov/extract-type-from-comment
morozov Apr 13, 2019
490dbe2
Added type hints to the Column class
morozov Apr 7, 2019
fbe5f07
Merge pull request #3520 from doctrine/drop-misspelling-in-foreign-ke…
jwage Apr 17, 2019
78c135d
Fix UniqueConstraint with empty name.
jwage Apr 17, 2019
cc54415
Merge pull request #3511 from morozov/column-type-hints
morozov Apr 17, 2019
000f5a0
Implemented support for persistent connections in PDO and mysqli drivers
morozov Apr 14, 2019
5af3a45
Merge pull request #3519 from doctrine/fix-unique-constraint-with-emp…
jwage Apr 19, 2019
91159d1
Extract exception factory methods into specific exceptions
Majkl578 May 4, 2018
d007efe
Merge pull request #3515 from morozov/persistent-connections
morozov Apr 23, 2019
5494b34
Merge pull request #3525 from doctrine/exceptions
morozov Apr 29, 2019
83b6ac2
Improve consistency of exception message formatting.
jwage Apr 30, 2019
89766f8
Merge pull request #3536 from jwage/improve-exception-messages
morozov May 8, 2019
20e707f
Remove user provided PDO functionality
morozov May 20, 2019
bf0d7c6
Connection::ping() will return void
morozov Mar 14, 2019
e3f4726
Merge pull request #3548 from morozov/issues/3545
morozov May 22, 2019
fb869d7
Merge pull request #3485 from morozov/ping-void
Ocramius May 22, 2019
22d677b
Enforced parameter and return value types in Statement classes
morozov May 23, 2019
600d79f
Merge pull request #3552 from morozov/statement-types
morozov May 23, 2019
0cd6baa
Remove deprecated json_array type
Majkl578 Apr 15, 2019
101950b
Remove deprecated Connection::TRANSACTION_* constants
Majkl578 Apr 15, 2019
623ca14
Remove deprecated AbstractPlatform::DATE_INTERVAL_UNIT_* and Abstract…
Majkl578 Apr 15, 2019
0dbca36
Remove deprecated MysqlSessionInit listener
Majkl578 Apr 15, 2019
cab0ce4
Remove deprecated MysqlPlatform::getCollationFieldDeclaration()
Majkl578 Apr 15, 2019
9d652f9
Remove deprecated AbstractPlatform::getIdentityColumnNullInsertSQL()
Majkl578 Apr 15, 2019
a28941b
Remove deprecated Table::addUnnamedForeignKeyConstraint() and Table::…
Majkl578 Apr 15, 2019
9539988
SQLParserUtils::*_TOKEN constants made private
Majkl578 Apr 15, 2019
4924169
Remove deprecated SQLParserUtils::getPlaceholderPositions()
Majkl578 Apr 15, 2019
d370eeb
Remove deprecated Table::renameColumn()
Majkl578 Apr 15, 2019
1993fc2
Remove deprecated AbstractSchemaManager::getFilterSchemaAssetsExpress…
Majkl578 Apr 15, 2019
d1c6699
Merge pull request #3518 from Majkl578/drop-deprecated
morozov May 23, 2019
40f26b1
Removed Driver::getName()
morozov May 23, 2019
0723eeb
Merge pull request #3553 from morozov/remove-driver-name
morozov May 24, 2019
f9dcaf3
add test for issue 3516 - invalid last inserted id in mssql when the …
sarven Apr 15, 2019
dc3ccf1
fix getting proper last inserted id when the table has a trigger with…
sarven Apr 15, 2019
2d36c21
change the number of insert statements in the trigger
sarven Apr 16, 2019
44f4888
fix PDOSqlsrv to get proper last inserted id when the table has a tri…
sarven Apr 18, 2019
3bf0d1e
fix phpstan errors
sarven Apr 18, 2019
e20814e
fix phpcs
sarven Apr 18, 2019
fb28489
fix phpdoc for stmt
sarven Apr 19, 2019
e3eaa58
fix typehint
sarven Apr 19, 2019
5b4fa18
convert fetchColumn result to string
sarven Apr 19, 2019
101c745
remove unnecessary if
sarven Apr 19, 2019
0c36944
remove whitespace
sarven Apr 19, 2019
0239670
convert fetchColumn to string
sarven Apr 19, 2019
de77ce0
remove getAttribute method which is not in the Connection interface
sarven Apr 19, 2019
ecf04f6
fix typehint
sarven Apr 19, 2019
e440b91
change sqlsrv version from devel to stable
sarven May 10, 2019
080c619
adjust changes to develop branch
sarven May 18, 2019
d10ff38
adjust PDOSqlsrvStatement
sarven May 23, 2019
a4b7904
Revert "change sqlsrv version from devel to stable"
sarven May 24, 2019
49b5b55
move DBAL3516Test to ConnectionTest
sarven May 24, 2019
79b93df
Connection in PDOSqlsrv as subtype of PDOConnection
sarven May 24, 2019
2e19509
fix alias
sarven May 24, 2019
96d9c5b
change protected to private
sarven May 28, 2019
98710f2
add missing typehints to LastInsertId
sarven May 28, 2019
6a06832
fix cs
sarven May 28, 2019
5122cc2
id as nullable
sarven May 28, 2019
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
7 changes: 6 additions & 1 deletion lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php
Original file line number Diff line number Diff line change
@@ -56,6 +56,11 @@ public function __construct(array $params, $username, $password, array $driverOp

$socket = $params['unix_socket'] ?? ini_get('mysqli.default_socket');
$dbname = $params['dbname'] ?? '';
$host = $params['host'];

if (! empty($params['persistent'])) {
$host = 'p:' . $host;
}

$flags = $driverOptions[static::OPTION_FLAGS] ?? 0;

@@ -67,7 +72,7 @@ public function __construct(array $params, $username, $password, array $driverOp
set_error_handler(static function () {
});
try {
if (! $this->conn->real_connect($params['host'], $username, $password, $dbname, $port, $socket, $flags)) {
if (! $this->conn->real_connect($host, $username, $password, $dbname, $port, $socket, $flags)) {
throw MysqliException::fromConnectionError($this->conn);
}
} finally {
5 changes: 5 additions & 0 deletions lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
use Doctrine\DBAL\Driver\AbstractMySQLDriver;
use Doctrine\DBAL\Driver\PDOConnection;
use Doctrine\DBAL\Driver\PDOException;
use PDO;

/**
* PDO MySql driver.
@@ -19,6 +20,10 @@ class Driver extends AbstractMySQLDriver
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
{
if (! empty($params['persistent'])) {
$driverOptions[PDO::ATTR_PERSISTENT] = true;
}

try {
$conn = new PDOConnection(
$this->constructPdoDsn($params),
5 changes: 5 additions & 0 deletions lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
use Doctrine\DBAL\Driver\AbstractOracleDriver;
use Doctrine\DBAL\Driver\PDOConnection;
use Doctrine\DBAL\Driver\PDOException;
use PDO;

/**
* PDO Oracle driver.
@@ -24,6 +25,10 @@ class Driver extends AbstractOracleDriver
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
{
if (! empty($params['persistent'])) {
$driverOptions[PDO::ATTR_PERSISTENT] = true;
}

try {
return new PDOConnection(
$this->constructPdoDsn($params),
4 changes: 4 additions & 0 deletions lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php
Original file line number Diff line number Diff line change
@@ -21,6 +21,10 @@ class Driver extends AbstractPostgreSQLDriver
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
{
if (! empty($params['persistent'])) {
$driverOptions[PDO::ATTR_PERSISTENT] = true;
}

try {
$connection = new PDOConnection(
$this->_constructPdoDsn($params),
5 changes: 5 additions & 0 deletions lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
namespace Doctrine\DBAL\Driver\PDOSqlsrv;

use Doctrine\DBAL\Driver\AbstractSQLServerDriver;
use PDO;
use function is_int;
use function sprintf;

@@ -28,6 +29,10 @@ public function connect(array $params, $username = null, $password = null, array
}
}

if (! empty($params['persistent'])) {
$pdoOptions[PDO::ATTR_PERSISTENT] = true;
}

return new Connection(
$this->_constructPdoDsn($params, $dsnOptions),
$username,
28 changes: 28 additions & 0 deletions tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php
Original file line number Diff line number Diff line change
@@ -7,9 +7,13 @@
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\ConnectionException;
use Doctrine\DBAL\Driver\Connection as DriverConnection;
use Doctrine\DBAL\Driver\PDOConnection;
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Platforms\SQLServerPlatform;
use Doctrine\Tests\DbalFunctionalTestCase;
use Doctrine\Tests\TestUtil;
use Error;
use Exception;
use PDO;
@@ -326,4 +330,28 @@ public function testUserProvidedPDOConnection() : void
])->ping()
);
}

public function testPersistentConnection() : void
{
$platform = $this->connection->getDatabasePlatform();

if ($platform instanceof SqlitePlatform
|| $platform instanceof SQLServerPlatform) {
self::markTestSkipped('The platform does not support persistent connections');
}

$params = TestUtil::getConnectionParams();
$params['persistent'] = true;

$connection = DriverManager::getConnection($params);
$driverConnection = $connection->getWrappedConnection();

if (! $driverConnection instanceof PDOConnection) {
self::markTestSkipped('Unable to test if the connection is persistent');
}

$pdo = $driverConnection->getWrappedConnection();

self::assertTrue($pdo->getAttribute(PDO::ATTR_PERSISTENT));
}
}