NAME

DBIO::Sybase::Introspect::Columns - Introspect Sybase ASE columns

VERSION

version 0.900007

DESCRIPTION

Fetches column metadata from the ASE system catalog: syscolumns joined to sysobjects / sysusers (owner) and systypes, plus syscomments for the text of column defaults. SAP ASE has no INFORMATION_SCHEMA views.

METHODS

fetch

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

Given the tables hashref from DBIO::Sybase::Introspect::Tables, returns a hashref keyed by table name. Each value is an arrayref of column hashrefs in colid order with keys: column_name, data_type, not_null, default_value, is_pk, pk_position, is_auto_increment, and size where it applies.

The values are read so they re-render through DBIO::Sybase::DDL exactly as the DDL that created the column wrote them -- both sides of DBIO::Sybase::Deploy's test-deploy-and-compare are introspected, so any drift between catalog value and rendering is a phantom diff:

  • data_type is the systypes name found through syscolumns.usertype -- the declared type (int, bigint, numeric). syscolumns.type would report the nullable storage variant (intn, numericn) for every nullable column.

  • not_null is status & 8 clear; is_auto_increment is status & 0x80.

  • size is syscolumns.length for character types -- halved for the UTF-16 unichar / univarchar, and divided by @@ncharsize for nchar / nvarchar, whose length is the declared size times the byte width of the server's default character set (1 under iso_1, 3 under utf8) -- the byte length for binary / varbinary, [prec, scale] for numeric / decimal, and absent otherwise (a text/image column's length of 16 is the page pointer, not a width).

  • default_value comes from the syscomments text behind syscolumns.cdefault (DEFAULT 'x', or create default d as ... for a bound default). A single-quoted literal becomes its bare value with '' unescaped -- "sybase_default_clause" in DBIO::Sybase::DDL quotes it again -- and anything else (getdate()) becomes a SCALAR ref, which that function emits verbatim. The column type decides like it does there: on a numeric column an unquoted number (DEFAULT 0, DEFAULT -1.5) is the bare literal, and a quoted text (DEFAULT '0', as other DDL writers emit it, and a VARCHAR constant every defaulted INSERT trips over) is a SCALAR ref carrying the quotes, so a diff against the desired 0 sees the difference and replaces it.

is_pk / pk_position are left at 0 here: the primary key is the PK-constraint index (sysindexes.status & 2048), which DBIO::Sybase::Introspect::Indexes reads, and DBIO::Sybase::Introspect marks the columns from it.

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.