DB-Object
view release on metacpan or search on metacpan
lib/DB/Object/Postgres.pm view on Meta::CPAN
# We cache it
$self->{_db_version} = version->parse( $ver );
return( $ver );
}
sub _check_connect_param
{
my $self = shift( @_ );
my $param = $self->SUPER::_check_connect_param( @_ ) || return( $self->pass_error );
# This is also what the psql command line tool does
$param->{login} = ( getpwuid( $> ) )[0] if( !$param->{login} );
$param->{database} = 'postgres' if( !$param->{database} );
# By default
$param->{port} = 5432 if( !length( $param->{port} ) );
return( $param );
}
# Called from connect once all check was done to see if there are default to set
sub _check_default_option
{
my $self = shift( @_ );
t/002_postgres.t view on Meta::CPAN
host => ( $ENV{DB_HOST} || 'localhost' ),
driver => 'Pg',
debug => $DEBUG,
};
if( $^O eq 'MSWin32' )
{
$con_params->{login} = ( $ENV{DB_LOGIN} || getlogin ) if( !$ENV{DB_CON_FILE} );
}
else
{
$con_params->{login} = ( $ENV{DB_LOGIN} || getlogin || (getpwuid( $> ))[0] ) if( !$ENV{DB_CON_FILE} );
}
my $dbh1 = DB::Object->connect( $con_params );
if( !defined( $dbh1 ) )
{
skip( "Database connection failed, cancelling other tests: ". DB::Object->error, 17 );
}
# $pg->debug(3);
ok( $dbh1, "Getting DB::Object::Postgres object" );
isa_ok( $dbh1, 'DB::Object::Postgres', "Checking class of object" );
t/004_mysql.t view on Meta::CPAN
'host' => ( $ENV{DB_HOST} || 'localhost' ),
'driver' => 'mysql',
'debug' => $DEBUG,
};
if( $^O eq 'MSWin32' )
{
$con_params->{login} = ( $ENV{DB_LOGIN} || getlogin ) if( !$ENV{DB_CON_FILE} );
}
else
{
$con_params->{login} = ( $ENV{DB_LOGIN} || getlogin || (getpwuid( $> ))[0] ) if( !$ENV{DB_CON_FILE} );
}
my $dbh1 = DB::Object->connect( $con_params );
if( !defined( $dbh1 ) )
{
skip( "Database connection failed, cancelling other tests: $DB::Object::ERROR", 18 );
}
ok( $dbh1, "Getting DB::Object::Mysql object" );
isa_ok( $dbh1, 'DB::Object::Mysql', "Checking class of object" );
$ENV{DB_HOST} ||= 'localhost';
t/007_element.t view on Meta::CPAN
driver => 'Pg',
debug => $DEBUG,
};
$con_params->{conf_file} = $ENV{DB_CONF} if( exists( $ENV{DB_CONF} ) && $ENV{DB_CONF} );
if( $^O eq 'MSWin32' )
{
$con_params->{login} = ( $ENV{DB_LOGIN} || getlogin ) if( !$ENV{DB_CON_FILE} );
}
else
{
$con_params->{login} = ( $ENV{DB_LOGIN} || getlogin || (getpwuid( $> ))[0] ) if( !$ENV{DB_CON_FILE} );
}
eval
{
require DB::Object::Postgres;
};
skip( "DBD::Pg not installed", 1 ) if( $@ );
my $dbh = DB::Object::Postgres->connect( $con_params );
if( !defined( $dbh ) )
( run in 0.437 second using v1.01-cache-2.11-cpan-8d75d55dd25 )