FAQ
Recently I've been working on the DBIx::Class::Schema::Loader support for
SQLite -- specifically, removing all of the "parse SQL from sqlite_master"
hacks from it. Things have been going quite well, but the heuristic I have for
determining whether a column is an autoinc PK is fragile.

I see that SQLite provides a definitive answer to the question of whether a
column is autoinc via the sqlite3_table_column_metadata API function, and
DBD::SQLite already makes use of this function to provide the NULLABLE sth
attribute. Does adding a private statement handle attribute that
returns the autoinc information from the same API function sound like a
reasonable solution to my problem?

Many thanks,

Andrew Rodland (IRC: hobbs)

Search Discussions

  • Zbigniew Lukasiak at May 19, 2010 at 9:48 am

    On Wed, May 19, 2010 at 7:46 AM, Andrew Rodland wrote:
    Recently I've been working on the DBIx::Class::Schema::Loader support for
    SQLite -- specifically, removing all of the "parse SQL from sqlite_master"
    hacks from it. Things have been going quite well, but the heuristic I have for
    determining whether a column is an autoinc PK is fragile.

    I see that SQLite provides a definitive answer to the question of whether a
    column is autoinc via the sqlite3_table_column_metadata API function, and
    DBD::SQLite already makes use of this function to provide the NULLABLE sth
    attribute. Does adding a private statement handle attribute that
    returns the autoinc information from the same API function sound like a
    reasonable solution to my problem?

    It's likely that you already know that - but just in case. In SQLite
    all INTEGER PRIMARY KEY columns are autoincrement in the DBIC meaning
    (ie. that you don't specify a value for this column when inserting),
    AUTOINCREMENT in the column type means only that the values in this
    column are never reused: http://www.sqlite.org/autoinc.html

    Cheers,
    Zbigniew Lukasiak
    http://brudnopis.blogspot.com/
    http://perlalchemy.blogspot.com/
  • Andrew Rodland at May 19, 2010 at 10:46 am

    On Wednesday, May 19, 2010 04:48:55 am you wrote:
    It's likely that you already know that - but just in case. In SQLite
    all INTEGER PRIMARY KEY columns are autoincrement in the DBIC meaning
    (ie. that you don't specify a value for this column when inserting),
    AUTOINCREMENT in the column type means only that the values in this
    column are never reused: http://www.sqlite.org/autoinc.html
    Well I *did* know that, but it managed to slip my mind for days at a time.
    Sorry for being dumb.

    (Although SQLite *still* doesn't expose exactly the right information, because
    it's possible for pragma table_info to show type='INTEGER' and pk=1 for a
    column and yet for that column not to be the INTEGER PRIMARY KEY by SQLite
    standards, as demonstrated on the page you linked above. Unlikely, but
    possible. I'm still pretty sure that the "parse the SQL from sqlite_master"
    technique is worse though :)

    Andrew

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdbd-sqlite @
postedMay 19, '10 at 6:46a
activeMay 19, '10 at 10:46a
posts3
users2
websiteshadowcat.co.uk

People

Translate

site design / logo © 2021 Grokbase