/
07-nulls.t6
50 lines (28 loc) · 1.28 KB
/
07-nulls.t6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
use Test;
use Test::When <extended>;
use DB::MySQL;
plan 16;
isa-ok my $m = DB::MySQL.new(), DB::MySQL, 'Create object';
# Issue #2
lives-ok { $m.execute('CREATE TABLE foo
( bar timestamp NULL default NULL ) engine=InnoDB') },
'create table';
ok $m.execute('INSERT INTO foo (bar) VALUES (NULL)'), 'insert NULL';
is $m.execute('SELECT bar FROM foo').value, DateTime, 'value is NULL';
is $m.query('select bar from foo').value, DateTime, 'value still NULL';
lives-ok { $m.execute('drop table foo') }, 'drop table';
# Issue #3
lives-ok { $m.execute('CREATE TABLE foo ( bar int unsigned ) engine=InnoDB') },
'create table';
ok $m.execute('INSERT INTO foo (bar) VALUES (NULL)'), 'insert NULL';
is $m.execute('SELECT bar FROM foo').value, Int, 'value is NULL';
is $m.query('SELECT bar FROM foo').value, Int, 'value still NULL';
lives-ok { $m.execute('drop table foo') }, 'drop table';
# Issue #4
lives-ok { $m.execute('CREATE TABLE foo ( bar char(1) ) engine=InnoDB') },
'create table';
ok $m.execute('INSERT INTO foo (bar) VALUES (NULL)'), 'insert NULL';
is $m.execute('SELECT bar FROM foo').value, Str, 'value is NULL';
is $m.query('SELECT bar FROM foo').value, Str, 'value still NULL';
lives-ok { $m.execute('drop table foo') }, 'drop table';
done-testing;