Skip to content

Commit 70662b5

Browse files
committed
make sure @isa is populated even if import() was not called
1 parent e437e0b commit 70662b5

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

‎lib/SQL/Abstract/More.pm‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,11 @@ my %params_for_WITH = (
230230

231231
sub new {
232232
my $class = shift;
233+
234+
# make sure @ISA is populated, in case import() was not already called
235+
$class->import() if !@ISA;
236+
237+
# accept params either as hash or as hashref
233238
my %params = does($_[0], 'HASH') ? %{$_[0]} : @_;
234239

235240
# extract params for this subclass

‎t/08-no-import.t‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use strict;
2+
use warnings;
3+
use Test::More;
4+
use SQL::Abstract::Test import => [qw/is_same_sql_bind/];
5+
6+
require SQL::Abstract::More; # no "use" ... so no import()
7+
8+
my $sqla = SQL::Abstract::More->new; # import() called implicitly through new()
9+
10+
ok $sqla->isa('SQL::Abstract::Classic'), '@ISA was populated';
11+
12+
my ($sql, @bind) = $sqla->select(
13+
-columns => [qw/bar/],
14+
-from => 'Foo',
15+
-where => {bar => {">" => 123}},
16+
-order_by => ['bar']
17+
);
18+
is_same_sql_bind(
19+
$sql, \@bind,
20+
"SELECT bar FROM Foo WHERE bar > ? ORDER BY bar", [123],
21+
"select",
22+
);
23+
24+
25+
done_testing;
26+
27+

0 commit comments

Comments
 (0)