comparison DBD/t/23null.t @ 0:cedccb7e0143

Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
author Sjoerd Mullender <sjoerd@acm.org>
date Mon, 19 Sep 2016 15:15:52 +0200 (2016-09-19)
parents
children a0ec9e080a5b
comparison
equal deleted inserted replaced
-1:000000000000 0:cedccb7e0143
1 #!perl -I./t
2
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 #
7 # Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V.
8
9 $| = 1;
10
11 use strict;
12 use warnings;
13 use DBI();
14 use DBD_TEST();
15
16 use Test::More;
17
18 if ( defined $ENV{DBI_DSN} ) {
19 plan tests => 14;
20 } else {
21 plan skip_all => 'Cannot test without DB info';
22 }
23
24 pass('NULL tests');
25
26 my $dbh = DBI->connect or die "Connect failed: $DBI::errstr\n";
27 $dbh->{RaiseError} = 1;
28 $dbh->{PrintError} = 0;
29 pass('Database connection created');
30
31 my $tbl = $DBD_TEST::table_name;
32 my @col = sort keys %DBD_TEST::TestFieldInfo;
33
34 ok( DBD_TEST::tab_create( $dbh ),"CREATE TABLE $tbl");
35
36 ok( $dbh->do("INSERT INTO $tbl( $_ ) VALUES( ? )", undef, undef ),"Inserting NULL into $_")
37 for @col;
38
39 my $Cols = join ', ', @col;
40 my $Qs = join ', ', map {'?'} @col;
41 my $sth = $dbh->prepare("INSERT INTO $tbl( $Cols ) VALUES( $Qs )");
42 ok( defined $sth,'Prepare insert statement');
43
44 my $i = 0;
45 for ( @col ) {
46 my $ti = DBD_TEST::get_type_for_column( $dbh, $_ );
47 ok( $sth->bind_param( ++$i, undef, { TYPE => $ti->{DATA_TYPE} } ),"Bind parameter for column $_");
48 }
49 ok( $sth->execute,'Execute prepared statement with bind params');
50
51 ok( $dbh->disconnect,'Disconnect');