NAME

DBIO::Sybase::Quote - Quote an identifier the way Sybase ASE reads it

VERSION

version 0.900007

DESCRIPTION

The one place where DBIO::Sybase writes an identifier -- table, column, index, constraint, view -- into DDL (DBIO::Sybase::DDL, the DBIO::Sybase::Diff::* operations).

A name is written bare when it is a simple identifier (a letter or _, then letters, digits and _) and no ASE keyword, and in square brackets otherwise: [dummy], [my table]. The default is the bare form for the same reason it was before: a diff and a deployment of the same schema compare by name, and sysobjects holds the name without its brackets either way.

Brackets and not double quotes: "name" is an identifier only with set quoted_identifier on, which a login does not have by default, and ASE answers it with Msg 102 (measured, ASE 16.0 SP02, 2026-10-24). [name] parses always. A ] inside a name is written ]] (measured: [a]]b] is the table a]b, stored without the brackets).

Two kinds of name no quoting reaches, and "quote_ident" refuses them itself with a DBIO::Exception naming the name and the reason, instead of passing the server's error on: a name that starts with # or @ (a temporary table or a variable; the server answers Msg 11717 and 16366 even in brackets), and one with a dot, which ASE reads as owner.name in brackets too (Msg 2734). The driver sends no temporary table through here (its temporary database is named by DBIO::Sybase::Deploy itself).

METHODS

keywords

my @words = keywords();

The list above, sorted, lower case.

is_keyword

is_keyword('dummy');    # true

True when the name, in any case, is on the list of words ASE refuses as an identifier.

quote_ident

my $sql = quote_ident($name);

The identifier as it goes into a statement: $name itself if it is simple and no keyword, otherwise [$name] with every ] doubled. Throws a DBIO::Exception for a name that starts with # or @ or contains a dot.

THE KEYWORD LIST

A word of this list is refused bare as the name of a table, a column, an index or a constraint (Msg 156, or 102 where the parser meets it before the name): create table dummy (id int) is Msg 156: Incorrect syntax near the keyword 'dummy', the case that started it (the table of DBIO::Test::Schema::Dummy).

Source: the server's catalog, master..spt_values rows of type = 'W', which ASE 16.0 SP02 PL02 has (218 words, read 2026-10-25). The list is that catalog plus four words the catalog does not name and a measurement found refused all the same: called and log as an index name, unsigned as a column name, identity_insert in all four places. Measured 2026-10-24 (DBD::Sybase 1.27 on FreeTDS 1.3.17) by sending about 600 candidate words -- the Reference Manual's reserved words as remembered, the SQL-92 words, the type names, the names columns commonly have -- bare as CREATE TABLE w, CREATE TABLE t (w int), CREATE INDEX w ON t (id) and CREATE TABLE t (id int, CONSTRAINT w PRIMARY KEY (id)), and again in brackets where one of them failed: 215 failed bare, none failed in brackets. Compared with the catalog, 211 of the 215 are in it, and the catalog has seven the measurement did not try (compressed, decrypt, decrypt_default, dual_control, encrypt, manage, release_locks_on_close). The words of the manual that ASE accepts (func, new, scrollable, ...), the type names (int, varchar, text) and the SQL-92 words (left, cast, current_date) are neither in the catalog nor on this list, and are written bare.

The list is fixed in the code; the driver does not read the catalog at run time. t/96-quote-ident-live.t reads it from the server it runs against and reports both directions of a difference: a catalog word missing here fails the test, a word here that the catalog lacks is kept and named in the output.

Not a guarantee: a server of another release may have more words, and a word missing from both the catalog and the measurement is refused by the server with Msg 156, as it was before this module.

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.