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.

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+\(.*\)$/) 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+\(.*\)$/) 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 date keywords are:

epoch
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.

validate_datetime_keyword STRING

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

allballs
epoch
infinity
-infinity
now
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.

validate_time_keyword STRING

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

allballs
now

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

validate_timestamp_keyword STRING

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

allballs
epoch
infinity
-infinity
now
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.

AUTHOR

John C. Siracusa (siracusa@gmail.com)

COPYRIGHT

Copyright (c) 2008 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.