<<

Bugzilla::DB::QuoteIdentifier

NAME

Bugzilla::DB::QuoteIdentifier

SYNOPSIS

  my %q;
  tie %q, 'Bugzilla::DB::QuoteIdentifier', db => Bugzilla->dbh;

  is("this is $q{something}", 'this is ' . Bugzilla->dbh->quote_identifier('something'));

DESCRIPTION

Bugzilla has many strings with bare sql column names or table names. Sometimes, as in the case of MySQL 8, formerly unreserved keywords can become reserved.

This module provides a shortcut for quoting identifiers in strings by way of overloading a hash so that we can easily call quote_identifier inside double-quoted strings.

METHODS

TIEHASH

This class can be used as a tied hash, which is only done to allow quoting identifiers inside double-quoted strings.

Exmaple:

    my $qi = Bugzilla->dbh->qi;
    my $sql = "SELECT $qi->{bug_id} FROM $qi->{bugs}";

FETCH

Returns the quoted identifier for the given key, this just calls quote_identifier on the database handle.

FIRSTKEY

This returns nothing, as this tied hash has no keys or values.

FIRSTVALUE

This returns nothing, as this tied hash has no keys or values.

EXISTS

This always returns true, as this tied hash has no keys or values but technically every key exists.

DELETE

This always returns true, as this tied hash has no keys or values but technically every key can be deleted.

db

This is a weak reference to the database handle that is used to quote identifiers.

SEE ALSO

Bugzilla::DB::Schema

<<