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

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

Closed
doctrinebot opened this issue Apr 12, 2013 · 4 comments
Closed
Labels

Comments

@doctrinebot
Copy link

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
Copy link
Author

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
Copy link
Author

Issue was closed with resolution "Can't Fix"

@deeky666
Copy link
Member

deeky666 commented Jan 8, 2016

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

@deeky666 deeky666 reopened this Jan 8, 2016
@morozov morozov closed this as completed Sep 3, 2022
@github-actions
Copy link

github-actions bot commented Oct 4, 2022

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants