NAME

Rose::DB::Pg - PostgreSQL driver class for Rose::DB.

SYNOPSIS

use Rose::DB;

Rose::DB->register_db(
  domain   => 'development',
  type     => 'main',
  driver   => 'Pg',
  database => 'dev_db',
  host     => 'localhost',
  username => 'devuser',
  password => 'mysecret',
  server_time_zone => 'UTC',
  european_dates   => 1,
);

Rose::DB->default_domain('development');
Rose::DB->default_type('main');
...

$db = Rose::DB->new; # $db is really a Rose::DB::Pg-derived object
...

DESCRIPTION

Rose::DB blesses objects into a class derived from Rose::DB::Pg when the driver is "pg". This mapping of driver names to class names is configurable. See the documentation for Rose::DB's new() and driver_class() methods for more information.

This class cannot be used directly. You must use Rose::DB and let its new() method return an object blessed into the appropriate class for you, according to its driver_class() mappings.

Only the methods that are new or have different behaviors than those in Rose::DB are documented here. See the Rose::DB documentation for the full list of methods.

OBJECT METHODS

european_dates [BOOL]

Get or set the boolean value that determines whether or not dates are assumed to be in european dd/mm/yyyy format. The default is to assume US mm/dd/yyyy format (because this is the default for PostgreSQL).

This value will be passed to DateTime::Format::Pg as the value of the european parameter in the call to the constructor new(). This DateTime::Format::Pg object is used by Rose::DB::Pg to parse and format date-related column values in methods like parse_date, format_date, etc.

next_value_in_sequence SEQUENCE

Advance the sequence named SEQUENCE and return the new value. Returns undef if there was an error.

server_time_zone [TZ]

Get or set the time zone used by the database server software. TZ should be a time zone name that is understood by DateTime::TimeZone. The default value is "floating".

This value will be passed to DateTime::Format::Pg as the value of the server_tz parameter in the call to the constructor new(). This DateTime::Format::Pg object is used by Rose::DB::Pg to parse and format date-related column values in methods like parse_date, format_date, etc.

See the DateTime::TimeZone documentation for acceptable values of TZ.

pg_enable_utf8 [BOOL]

Get or set the pg_enable_utf8 database handle attribute. This is set directly on the dbh, if one exists. Otherwise, it will be set when the dbh is created. If no value for this attribute is defined (the default) then it will not be set when the dbh is created, deferring instead to whatever default value DBD::Pg chooses.

Returns the value of this attribute in the dbh, if one exists, or the value that will be set when the dbh is next created.

See the DBD::Pg documentation to learn more about this attribute.

sslmode [MODE]

Get or set the SSL mode of the connection. Valid values for MODE are disable, allow, prefer, and require. This attribute is used to build the DBI dsn. Setting it has no effect until the next connection. See the DBD::Pg documentation to learn more about this attribute.

Value Parsing and Formatting

format_array ARRAYREF | LIST

Given a reference to an array or a list of values, return a string formatted according to the rules of PostgreSQL's "ARRAY" column type. Undef is returned if ARRAYREF points to an empty array or if LIST is not passed.

format_interval DURATION

Given a DateTime::Duration object, return a string formatted according to the rules of PostgreSQL's "INTERVAL" column type. If DURATION is undefined, a DateTime::Duration object, a valid interval keyword (according to validate_interval_keyword), or if it looks like a function call (matches /^\w+\(.*\)$/) and keyword_function_calls is true, then it is returned unmodified.

parse_array STRING

Parse STRING and return a reference to an array. STRING should be formatted according to PostgreSQL's "ARRAY" data type. Undef is returned if STRING is undefined.

parse_interval STRING

Parse STRING and return a DateTime::Duration object. STRING should be formatted according to the PostgreSQL native "interval" (years, months, days, hours, minutes, seconds) data type.

If STRING is a DateTime::Duration object, a valid interval keyword (according to validate_interval_keyword), or if it looks like a function call (matches /^\w+\(.*\)$/) and keyword_function_calls is true, then it is returned unmodified. Otherwise, undef is returned if STRING could not be parsed as a valid "interval" value.

validate_date_keyword STRING

Returns true if STRING is a valid keyword for the PostgreSQL "date" data type. Valid (case-insensitive) date keywords are:

current_date
epoch
now
now()
today
tomorrow
yesterday

The keywords are case sensitive. Any string that looks like a function call (matches /^\w+\(.*\)$/) is also considered a valid date keyword if keyword_function_calls is true.

validate_datetime_keyword STRING

Returns true if STRING is a valid keyword for the PostgreSQL "datetime" data type, false otherwise. Valid (case-insensitive) datetime keywords are:

-infinity
allballs
current_date
current_time
current_time()
current_timestamp
current_timestamp()
epoch
infinity
localtime
localtime()
localtimestamp
localtimestamp()
now
now()
timeofday()
today
tomorrow
yesterday

The keywords are case sensitive. Any string that looks like a function call (matches /^\w+\(.*\)$/) is also considered a valid datetime keyword if keyword_function_calls is true.

validate_time_keyword STRING

Returns true if STRING is a valid keyword for the PostgreSQL "time" data type, false otherwise. Valid (case-insensitive) timestamp keywords are:

allballs
current_time
current_time()
localtime
localtime()
now
now()
timeofday()

The keywords are case sensitive. Any string that looks like a function call (matches /^\w+\(.*\)$/) is also considered a valid timestamp keyword if keyword_function_calls is true.

validate_timestamp_keyword STRING

Returns true if STRING is a valid keyword for the PostgreSQL "timestamp" data type, false otherwise. Valid (case-insensitive) timestamp keywords are:

-infinity
allballs
current_date
current_time
current_time()
current_timestamp
current_timestamp()
epoch
infinity
localtime
localtime()
localtimestamp
localtimestamp()
now
now()
timeofday()
today
tomorrow
yesterday

The keywords are case sensitive. Any string that looks like a function call (matches /^\w+\(.*\)$/) is also considered a valid timestamp keyword if keyword_function_calls is true.

AUTHOR

John C. Siracusa (siracusa@gmail.com)

LICENSE

Copyright (c) 2010 by John C. Siracusa. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.