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

DESCRIPTION

This is the subclass that Rose::DB blesses an object into when the driver is "Pg". This mapping of drivers to class names is configurable. See the documentation for Rose::DB's new() and driver_class()|Rose::DB/driver_class methods for more information.

Using this class directly is not recommended. Instead, use Rose::DB and let it bless objects into the appropriate class for you, according to its driver_class()|Rose::DB/driver_class mappings.

This class inherits from Rose::DB. Only the methods that are new or have different behaviors are documented here. See the Rose::DB documentation for information on the inherited 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. If the array or list contains undefined values, a fatal error will occur.

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_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@mindspring.com)

COPYRIGHT

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