Skip to content

Fix sqlite autoincrement detection #515

Merged
merged 2 commits into from Feb 8, 2014

7 participants

@bartv2
bartv2 commented Jan 17, 2014

When there are 2 PK-columns the code would still mark the first column as autoincrement.

@doctrinebot

Hello,

thank you for creating this pull request. I have automatically opened an issue
on our Jira Bug Tracker for you. See the issue link:

http://www.doctrine-project.org/jira/browse/DBAL-792

We use Jira to track the state of pull requests and the versions they got
included in.

@bartv2 bartv2 referenced this pull request in owncloud/3rdparty Jan 17, 2014
Closed

Fix Sqlite PK detection #68

@Ocramius Ocramius commented on an outdated diff Jan 20, 2014
...Functional/Schema/SchemaManagerFunctionalTestCase.php
@@ -493,6 +493,18 @@ public function testAutoincrementDetection()
$inferredTable = $this->_sm->listTableDetails('test_autoincrement');
$this->assertTrue($inferredTable->hasColumn('id'));
$this->assertTrue($inferredTable->getColumn('id')->getAutoincrement());
+
+ $table = new \Doctrine\DBAL\Schema\Table('test_not_autoincrement');
@Ocramius
Doctrine member
Ocramius added a note Jan 20, 2014

Create a new test method instead (with @group DBAL-792)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@Ocramius Ocramius commented on the diff Jan 20, 2014
lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php
@@ -220,7 +220,7 @@ protected function _getPortableTableColumnList($table, $database, $tableColumns)
$autoincrementColumn = null;
$autoincrementCount = 0;
foreach ($tableColumns as $tableColumn) {
- if ('1' == $tableColumn['pk']) {
+ if ('0' != $tableColumn['pk']) {
@Ocramius
Doctrine member
Ocramius added a note Jan 20, 2014

What does the magic 0 stand for here?

@deeky666
Doctrine member
deeky666 added a note Jan 20, 2014

@Ocramius This number indicates the 1-based ordinal position in the PK index when retrieving the data with the PRAGMA statement. PK columns have a value > 0, all other columns have 0. http://www.sqlite.org/pragma.html#pragma_table_info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@beberlei beberlei merged commit 3faa3a6 into doctrine:master Feb 8, 2014

1 check passed

Details default The Travis CI build passed
@bartv2 bartv2 deleted the unknown repository branch Feb 10, 2014
@bartv2 bartv2 added a commit to owncloud/3rdparty that referenced this pull request Feb 18, 2014
@bartv2 bartv2 doctrine/dbal#515 PR a5daf7e
@DeepDiver1975

@beberlei Can this be backported to 2.4? THX

@deeky666
Doctrine member

@bantu Only @beberlei and @guilhermeblanco merge PRs. They will have a look at the PRs to be merged soon :)

@deeky666
Doctrine member

in this case to be backported of course.

@bantu
bantu commented Mar 26, 2014

@beberlei Can we get this backported to 2.3 please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.