NAME

DBIO::SQLite::Introspect::Columns - Introspect SQLite columns

VERSION

version 0.900007

DESCRIPTION

Fetches column metadata via PRAGMA table_info() (or table_xinfo when available, which also reports hidden/generated columns).

METHODS

fetch

my $columns = DBIO::SQLite::Introspect::Columns->fetch($dbh, $tables);

Given the tables hashref produced by DBIO::SQLite::Introspect::Tables, returns a hashref keyed by table name. Each value is an arrayref of column hashrefs (in declaration order) with keys: column_name, data_type, size (present only on a column whose declared type has one), not_null, default_value, is_pk, pk_position, hidden (xinfo only), and is_auto_increment (1, present only on the column that has it).

The size of a column is read out of its declared type, which is where SQLite keeps it: CHARACTER(10) is data_type CHARACTER with size 10, NUMERIC(10, 2) is NUMERIC with [ 10, 2 ] ("split_type_size" in DBIO::SQLite::Util). A type without a size, or with something else in the parentheses, is data_type as declared and has no size.

is_auto_increment is set for the rowid alias and nothing else: the single primary key column of a rowid table whose declared type is exactly INTEGER. That column assigns its own keys with or without the AUTOINCREMENT keyword, which the DDL does not write (ADR 0004); the keyword only adds the never-reuse guarantee and is not what is reported. A composite key, an INT key and a WITHOUT ROWID table do not assign keys and carry no such key.

not_null is the negation of "column_is_nullable" in DBIO::SQLite::Util, the single nullability rule this driver has, and not the raw notnull flag of the PRAGMA. The two differ for exactly one column shape, the rowid alias (INTEGER PRIMARY KEY on a rowid table): it cannot hold NULL whatever it was declared as, because there NULL is the "assign a rowid" input token rather than a value that gets stored. The PRAGMA reports the declaration, so the same alias reads notnull = 0 written one way and notnull = 1 written the other -- and a model that passed that difference on made two spellings of one table look like two different tables. Every other column keeps the PRAGMA's answer unchanged, including a non-alias key column that really can hold NULL.

AUTHOR

DBIO & DBIx::Class Authors

COPYRIGHT AND LICENSE

Copyright (C) 2026 DBIO Authors Portions Copyright (C) 2005-2025 DBIx::Class Authors Based on DBIx::Class, heavily modified.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.