doctrine/dbal — pull request #66 by mrtorrent (2011-10-15 11:21:51+00:00)
Title: Make doctrine and sqlite friends

Hi,

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.

Best regards,
Miquel