dbsrgits / sql-translator

SQL::Translator (SQLFairy)
http://sqlfairy.sourceforge.net/
82 stars 91 forks source link

Round-trip AUTOINCREMENT in SQLite parser #158

Closed nrdvana closed 1 year ago

nrdvana commented 1 year ago

Currently, the SQLite parser sees the AUTOINCREMENT keyword and sets the column flag is_auto_increment, but the SQLite Producer will not write the AUTOINCREMENT keyword unless extra.auto_increment_type is 'monotonic'. This breaks round-trip by the AUTOINCREMENT keyword getting lost.

This was mentioned as a needed related fix in the discussion of #47, but it seems to have never been added.

nrdvana commented 1 year ago

The auto_increment_type is only relevant to SQLite, so the other parsers and producers don't operate on it. SQLite gives you auto-generated primary key integers that are not guaranteed to be monotonically increasing unless you specify the AUTOINCREMENT keyword. DBIC originally just used the default non-monotonic SQLite behavior for columns declared as auto_increment, and then needed an extra flag to differentiate for when users really need the monotonic behavior. The issue 47 I referenced added the flag to the producer, but not the parser.