Aran Clary Deltac > SQL-Dialect-0.02 > SQL::Dialect

Download:
SQL-Dialect-0.02.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.02   Source  

NAME ^

SQL::Dialect - Auto-detection of SQL quirks.

SYNOPSIS ^

    use SQL::Dialect;
    
    my $dialect = SQL::Dialect->new( $dbh );
    
    if ($dialect->supports('limit-xy')) { ... }
    print $dialect->quote_char();
    ...

DESCRIPTION ^

This module detects the SQL dialect of a DBI database handle and exposes a handful of properties describing the features and quirks of that dialect.

CONSTRUCTOR ^

    # Auto-detect the appropriate dialect from a DBI handle:
    my $dialect = SQL::Dialect->new( $dbh );
    
    # Explicitly set the dialect that you want:
    my $dialect = SQL::Dialect->new( 'oracle' );
    
    # The "default" dialect is the default:
    my $dialect = SQL::Dialect->new();

Each implementation, or dialect, of SQL has quirks that slightly (or in some cases drastically) change the way that the SQL must be written to get a particular task done. In order for this module to work a dialect must be declared. The dialect will default to "default" which is very limited and only declares the bare minimum of features.

Currently a dialect type can be one of:

    default
    mysql
    oracle
    postgresql
    sqlite

When declaring the dialect type that you want you can either specify one of the dialects above, or you can just pass a DBI handle ($dbh) and it will be auto-detected. Currently the list of supported DBI Driver is limited to:

    DBD::mysql  (mysql)
    DBD::Oracle (oracle)
    DBD::Pg     (postgresql)
    DBD::PgPP   (postgresql)
    DBD::SQLite (sqlite)

If the driver that you are using is not in the above list then please contact the author and work with them to get it added.

STATEMENT PROPERTIES ^

limit

The dialect of the LIMIT clause.

    offset (postgresql, sqlite)
    xy     (mysql)

returning

The dialect of INSERT/UPDATE/DELETE ... RETURNING syntax.

    into   (oracle)
    select (postgresql)

DATABASE PROPERTIES ^

sequences

Whether the database supports sequences.

    postgresql
    oracle

FUNCTION PROPERTIES ^

last_insert_id

Whether the LAST_INSERT_ID() function is supported.

    mysql

last_insert_rowid

Whether the LAST_INSERT_ROWID() function is supported.

    sqlite

OTHER PROPERTIES ^

rownum

Returns true if the dialect supports the rownum pseudo column.

    oracle

quote_char

The character that is used to quote identifiers, such as table and column names.

sep_char

The character that is used to separate linked identifiers, such as a table name followed by a column name.

METHODS ^

supports

    # Do something if the dialect supports any form of limit and
    # only the select flavor of returning:
    if ($dialect->supports('limit', 'returning-select')) { ... }

Given a list of feature names, optionally dash-suffixed with a specific quirk, this will return true or false if the dialect supports them all.

TODO ^

CONTRIBUTING ^

If you'd like to contribute bug fixes, enhancements, additional test covergage, or documentation to this module then by all means do so. You can fork this repository using github and then send the author a pull request.

Please contact the author if you are considering doing this and discuss your ideas.

SUPPORT ^

Currently there is no particular mailing list or IRC channel for this project. You can shoot the author an e-mail if you have a question.

If you'd like to report an issue you can use github's issue tracker.

REFERENCES ^

AUTHOR ^

Aran Clary Deltac <bluefeet@gmail.com>

LICENSE ^

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

syntax highlighting: