Skip to content

Loading…

DBAL-493: Schema\Comparator incorrect diff with sqlite and unsigned integer #1695

Open
doctrinebot opened this Issue · 3 comments

3 participants

@doctrinebot

Jira issue originally created by user richardhinkamp:

Using the Schema\Comparator to diff a table in sqlite with a unsigned integer. When creating the table and comparing it with the same definition it gives a diff which is not expected:

$schema = new \Doctrine\DBAL\Schema\Schema();
$usersTable = $schema->createTable("test_users");
$usersTable->addColumn("id", "integer", array("unsigned" => true, 'autoincrement' => true));
$usersTable->setPrimaryKey(array("id"));
$usersTable->addColumn("username", "string", array("length" => 32));
$usersTable->addIndex( array( 'username' ) );
$usersTable->addColumn("password", "string", array("length" => 64));

$platform = new \Doctrine\DBAL\Platforms\SqlitePlatform();
$queries = $platform->getCreateTableSQL($usersTable);
foreach($queries as $query) {
    $conn->query($query);
}

$tableDetail = $sm->listTableDetails($usersTable->getName());
$comparator = new \Doctrine\DBAL\Schema\Comparator();
$diff = $comparator->diffTable($tableDetail, $usersTable);
if ($diff) {
    print(implode("\n",$platform->getAlterTableSQL($diff)));
} else {
    print("no diff");
}

Expect result:

no diff

Actual result:

DROP INDEX IDX_1F5D03E2F85E0677
CREATE TEMPORARY TABLE *_temp__test_users AS SELECT id, username, password FROM test*users
DROP TABLE test_users
CREATE TABLE test_users (id INTEGER NOT NULL, username VARCHAR(32) NOT NULL, password VARCHAR(64) NOT NULL, PRIMARY KEY(id))
INSERT INTO test*users (id, username, password) SELECT id, username, password FROM __temp__test*users
DROP TABLE *_temp__test*users
CREATE INDEX IDX*1F5D03E2F85E0677 ON test*users (username)

When setting unsigned to false everything works. Shouldn't Doctrine know unsigned is not supported in sqlite?

@doctrinebot

Comment created by @beberlei:

SQLite doesn't have the notion of unsigned. You have to remote the "unsigned" => true flag to stop confusing Sqlite and the Comparision and it will work.

@doctrinebot

Issue was closed with resolution "Can't Fix"

@doctrinebot doctrinebot added the Bug label
@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot closed this
@deeky666
Doctrine member

Reopening as this is not a Can't fix. See #2283

@deeky666 deeky666 reopened this
@beberlei beberlei was unassigned by deeky666
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.