[DBAL-188] Make doctrine and sqlite friends Created: 18/Dec/11  Updated: 18/Dec/11  Resolved: 18/Dec/11

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: 2.2
Security Level: All

Type: New Feature Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

https://github.com/doctrine/dbal/pull/66

Schema processing for SQLite is broken in a number of common situations. These patches fix handling of the following:

String column defaults: For columns with a default value that is a string, SQLite returns them wrapped in single quotes. Doctrine does not strip these, so it would treat a value "foobar" as "'foobar'" (with single quotes as part of the value).
Auto-increment: SQLite handling of auto-increment is unusual. In particular, it supports it only on an integer column which is the sole primary key for a table. In addition, it will automatically increment values of an integer primary key column regardless of whether it has been defined as autoincrement BUT, unlike autoincrement, these values are not guaranteed to be unique.
Most problematically, there is no way (without parsing the "create" statements stored in sqlite_master) to determine whether a column is marked as auto-incrementing. Doctrine was treating SQLite integer primary keys as auto-incrementing, but this is not correct and does not work for composite primary keys.
Composite primary keys: As a side-effect of Doctrine treating integer primary keys in SQLite as auto-incrementing and of how SQLite requires autoincrement and primary keys to be declared, it would generate invalid create statements for composite keys in SQLite.
Special indexes: SQLite sometimes automatically generates indexes, which Doctrine treated the same as any other. Because they are internal, however, their names are reserved, so they could not be used to recreate the same index and, since they are automatic, they aren't actually a part of the defined schema.

I've added to the tests to catch these situations in the future as well.


Generated at Thu Oct 23 20:02:41 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.