Skip to content

Commit 90097e9

Browse files
authored
Merge pull request #1 from sixapart/master
Update to upstream
2 parents 670ade9 + 42d1546 commit 90097e9

28 files changed

Lines changed: 166 additions & 48 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@
1616
!LICENSE
1717
/cpanfile.snapshot
1818
/local
19+
/*.db

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ perl:
66
- "5.16"
77
- "5.18"
88
- "5.20"
9+
- "5.22"
10+
- "5.24"
911
before_install:
1012
- cpanm -n DBD::SQLite Devel::Cover::Report::Coveralls
1113
script:

Changes

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
{{$NEXT}}
22

3+
0.17 2019-03-12T04:24:20Z
4+
5+
- Bump version
6+
7+
0.16 2019-03-07T07:07:14Z
8+
9+
- Avoid SQL syntax error: column IN () (charsbar) #26
10+
- Add disconnect method explicitly to pass tests for windows (twata1) #25
11+
12+
0.15 2017-04-19T01:41:02Z
13+
14+
- Fix failed tests with Perl 5.25.11 (miniuchi) #24
15+
316
0.14 2016-01-14T03:03:02Z
417

518
- Fix test for SQLite 3.10 compatibility (ziguzagu) #21

META.json

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"-2006"
55
],
66
"dynamic_config" : 0,
7-
"generated_by" : "Minilla/v3.0.1, CPAN::Meta::Converter version 2.150001",
7+
"generated_by" : "Minilla/v3.1.4, CPAN::Meta::Converter version 2.150010",
88
"license" : [
99
"artistic_2"
1010
],
1111
"meta-spec" : {
1212
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
13-
"version" : "2"
13+
"version" : 2
1414
},
1515
"name" : "Data-ObjectDriver",
1616
"no_index" : {
@@ -79,31 +79,37 @@
7979
"web" : "https://github.com/sixapart/data-objectdriver"
8080
}
8181
},
82-
"version" : "0.14",
82+
"version" : "0.17",
8383
"x_authority" : "cpan:SIXAPART",
8484
"x_contributors" : [
85-
"Mart Atkins <matkins@sixapart.com>",
86-
"Jonathan Steinert <jsteinert@sixapart.com>",
87-
"Paul Lindner <paul@inuus.com>",
85+
"Adam Thomason <athomason@sixapart.com>",
86+
"Akira Sawada <akira@peatix.com>",
87+
"Ben Trott <ben@sixapart.com>",
88+
"Brad Choate <bchoate@sixapart.com>",
8889
"Brad Fitzpatrick <brad@danga.com>",
89-
"Mischa <none@sixapart.com>",
90+
"Brad Whitaker <whitaker@sixapart.com>",
91+
"David Steinbrunner <dsteinbrunner@pobox.com>",
9092
"Garth Webb <gwebb@sixapart.com>",
9193
"Graham Blankenbaker <gblankenbaker@sixapart.com>",
92-
"Brad Choate <bchoate@sixapart.com>",
94+
"Jonathan Steinert <jsteinert@sixapart.com>",
95+
"Kenichi Ishigaki <ishigaki@cpan.org>",
96+
"Kevin Goess <kgoess@sixapart.com>",
9397
"Mark Paschal <mpaschal@sixapart.com>",
98+
"Mart Atkins <matkins@sixapart.com>",
99+
"Masahiro Iuchi <miuchi@sixapart.com>",
100+
"Mischa <none@sixapart.com>",
101+
"Paul Lindner <paul@inuus.com>",
94102
"Sekimura <sekimura@sixapart.com>",
95103
"Simon Wistow <swistow@sixapart.com>",
104+
"Takatsugu Shigeta <shigeta@cpan.org>",
105+
"Takatsugu Shigeta <tshigeta@sixapart.com>",
106+
"Taku AMANO <taku@toi-planning.net>",
96107
"Tatsuhiko Miyagawa <miyagawa@sixapart.com>",
97-
"Ben Trott <ben@sixapart.com>",
98-
"Kevin Goess <kgoess@sixapart.com>",
99-
"Adam Thomason <athomason@sixapart.com>",
100-
"Brad Whitaker <whitaker@sixapart.com>",
108+
"Tsuyoshi Watanabe <twata_1@yahoo.co.jp>",
101109
"Yann Kerherve <yann@cyberion.net>",
102-
"Taku AMANO <taku@toi-planning.net>",
103110
"ambs <ambs@cpan.org>",
104-
"David Steinbrunner <dsteinbrunner@pobox.com>",
105-
"Akira Sawada <akira@peatix.com>",
106-
"Masahiro Iuchi <miuchi@sixapart.com>",
107111
"ziguzagu <ziguzagu@gmail.com>"
108-
]
112+
],
113+
"x_serialization_backend" : "JSON::PP version 2.97001",
114+
"x_static_install" : 1
109115
}

lib/Data/ObjectDriver.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use Data::ObjectDriver::Iterator;
1111

1212
__PACKAGE__->mk_accessors(qw( pk_generator txn_active ));
1313

14-
our $VERSION = '0.14';
14+
our $VERSION = '0.17';
1515
our $DEBUG = $ENV{DOD_DEBUG} || 0;
1616
our $PROFILE = $ENV{DOD_PROFILE} || 0;
1717
our $PROFILER;

lib/Data/ObjectDriver/SQL.pm

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,25 +247,65 @@ sub _mk_term {
247247
$term = join " $logic ", @terms;
248248
} else {
249249
$col = $m->($col) if $m = $stmt->column_mutator;
250-
$term = "$col IN (".join(',', ('?') x scalar @$val).')';
250+
$term = $stmt->_mk_term_arrayref($col, 'IN', $val);
251251
@bind = @$val;
252252
}
253253
} elsif (ref($val) eq 'HASH') {
254254
my $c = $val->{column} || $col;
255255
$c = $m->($c) if $m = $stmt->column_mutator;
256-
$term = "$c $val->{op} ?";
257-
push @bind, $val->{value};
256+
my $op = uc $val->{op};
257+
if (($op eq 'IN' or $op eq 'NOT IN') and ref $val->{value} eq 'ARRAY') {
258+
$term = $stmt->_mk_term_arrayref($c, $op, $val->{value});
259+
push @bind, @{$val->{value}};
260+
} elsif (($op eq 'IN' or $op eq 'NOT IN') and ref $val->{value} eq 'REF') {
261+
my @values = @{${$val->{value}}};
262+
$term = "$c $op (" . (shift @values) . ")";
263+
push @bind, @values;
264+
} elsif ($op eq 'BETWEEN' and ref $val->{value} eq 'ARRAY') {
265+
Carp::croak "USAGE: foo => {op => 'BETWEEN', value => [\$a, \$b]}" if @{$val->{value}} != 2;
266+
$term = "$c $op ? AND ?";
267+
push @bind, @{$val->{value}};
268+
} else {
269+
if (ref $val->{value} eq 'SCALAR') {
270+
$term = "$c $val->{op} " . ${$val->{value}};
271+
} else {
272+
$term = "$c $val->{op} ?";
273+
push @bind, $val->{value};
274+
}
275+
}
258276
} elsif (ref($val) eq 'SCALAR') {
259277
$col = $m->($col) if $m = $stmt->column_mutator;
260278
$term = "$col $$val";
279+
} elsif (ref($val) eq 'REF') {
280+
$col = $m->($col) if $m = $stmt->column_mutator;
281+
my @values = @{$$val};
282+
$term = "$col " . (shift @values);
283+
push @bind, @values;
261284
} else {
262285
$col = $m->($col) if $m = $stmt->column_mutator;
263-
$term = "$col = ?";
264-
push @bind, $val;
286+
if (defined $val) {
287+
$term = "$col = ?";
288+
push @bind, $val;
289+
} else {
290+
$term = "$col IS NULL";
291+
}
265292
}
266293
($term, \@bind, $col);
267294
}
268295

296+
sub _mk_term_arrayref {
297+
my ($stmt, $col, $op, $val) = @_;
298+
if (@$val) {
299+
return "$col $op (".join(',', ('?') x scalar @$val).')';
300+
} else {
301+
if ($op eq 'IN') {
302+
return '0 = 1';
303+
} elsif ($op eq 'NOT IN') {
304+
return '1 = 1';
305+
}
306+
}
307+
}
308+
269309
sub _add_index_hint {
270310
my $stmt = shift;
271311
my ($tbl_name) = @_;

t/01-col-inheritance.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use strict;
44

55
use lib 't/lib';
66

7-
require 't/lib/db-common.pl';
7+
require './t/lib/db-common.pl';
88

99
use Test::More;
1010
unless (eval { require DBD::SQLite }) {

t/02-basic.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use strict;
55
use lib 't/lib';
66
use lib 't/lib/cached';
77

8-
require 't/lib/db-common.pl';
8+
require './t/lib/db-common.pl';
99

1010
use Test::More;
1111
use Test::Exception;

t/03-primary-keys.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use strict;
55
use lib 't/lib';
66
use lib 't/lib/cached';
77

8-
require 't/lib/db-common.pl';
8+
require './t/lib/db-common.pl';
99

1010
use Test::More;
1111
use Test::Exception;

t/04-clone.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use strict;
55
use lib 't/lib';
66
use lib 't/lib/cached';
77

8-
require 't/lib/db-common.pl';
8+
require './t/lib/db-common.pl';
99

1010
use Test::More;
1111
use Test::Exception;

0 commit comments

Comments
 (0)