Alzabo

 view release on metacpan or  search on metacpan

t/17-insert-handle.t  view on Meta::CPAN

#!/usr/bin/perl -w

use strict;

use File::Spec;

use lib '.', File::Spec->catdir( File::Spec->curdir, 't', 'lib' );

use Alzabo::Test::Utils;

use Test::More;


use Alzabo::Create;
use Alzabo::Config;
use Alzabo::Runtime;


my @rdbms_names = Alzabo::Test::Utils->rdbms_names;

unless (@rdbms_names)
{
    plan skip_all => 'no test config provided';
    exit;
}

plan tests => 25;


Alzabo::Test::Utils->remove_all_schemas;


# doesn't matter which RDBMS is used
my $rdbms = $rdbms_names[0];

if ( $rdbms eq 'mysql' )
{
    # prevent subroutine redefinition warnings
    local $^W = 0;
    eval 'use Alzabo::SQLMaker::MySQL qw(:all)';
}
elsif ( $rdbms eq 'pg' )
{
    local $^W = 0;
    eval 'use Alzabo::SQLMaker::PostgreSQL qw(:all)';
}

Alzabo::Test::Utils->make_schema($rdbms);

my $config = Alzabo::Test::Utils->test_config_for($rdbms);

my $s = Alzabo::Runtime::Schema->load_from_file( name => $config->{schema_name} );

$s->connect( Alzabo::Test::Utils->connect_params_for($rdbms)  );

my $department = $s->table('department')->insert( values => { name => 'D 1' } );
my $dep_id = $department->select('department_id');

{
    my $handle =
        $s->table('employee')->insert_handle
            ( columns => [ $s->table('employee')->columns( 'name', 'dep_id' ) ] );

    foreach my $name ( qw( Faye Jet Maggie ) )
    {
        my $row =
            $handle->insert( values =>



( run in 1.187 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )