Showing 9 changed files with 121 additions and 42 deletions
+2 -1
Changes
... ...
@@ -1,6 +1,7 @@
1 1
 0.1678
2 2
     - DBIx::Custom::Model filter attribute can receive hash reference
3
-    - DBIx::Custom::Where clause attribute can receive clause without column name.
3
+    - DBIx::Custom::Where clause attribute can receive clause without column name
4
+    - improved error messages
4 5
 0.1677
5 6
     - improved table search in column and join clause
6 7
     - DEPRECATED table tag. use table option.
+62 -28
lib/DBIx/Custom.pm
... ...
@@ -78,7 +78,8 @@ sub AUTOLOAD {
78 78
         $self->dbh->$dbh_method(@_);
79 79
     }
80 80
     else {
81
-        croak qq/Can't locate object method "$mname" via "$package"/
81
+        croak qq{Can't locate object method "$mname" via "$package"}
82
+            . qq{ (DBIx::Custom::AUTOLOAD)}
82 83
     }
83 84
 }
84 85
 
... ...
@@ -110,10 +111,11 @@ sub apply_filter {
110 111
         
111 112
         # Filter infomation
112 113
         my $finfo = $cinfos[$i + 1] || {};
113
-        croak "$usage (table: $table)" unless  ref $finfo eq 'HASH';
114
+        croak "$usage (table: $table) (DBIx::Custom::apply_filter)"
115
+          unless  ref $finfo eq 'HASH';
114 116
         foreach my $ftype (keys %$finfo) {
115
-            croak "$usage (table: $table 2)" unless $ftype eq 'in' || $ftype eq 'out'
116
-                             || $ftype eq 'end'; 
117
+            croak "$usage (table: $table) (DBIx::Custom::apply_filter)"
118
+              unless $ftype eq 'in' || $ftype eq 'out' || $ftype eq 'end'; 
117 119
         }
118 120
         
119 121
         # Set filters
... ...
@@ -133,6 +135,7 @@ sub apply_filter {
133 135
             
134 136
             # Check filter name
135 137
             croak qq{Filter "$filter" is not registered}
138
+                . qq{ (DBIx::Custom::apply_filter)}
136 139
               if  $state eq 'name'
137 140
                && ! exists $self->filters->{$filter};
138 141
             
... ...
@@ -223,7 +226,11 @@ sub create_query {
223 226
     # Prepare statement handle
224 227
     my $sth;
225 228
     eval { $sth = $self->dbh->prepare($query->{sql})};
226
-    $self->_croak($@, qq{. Following SQL is executed. "$query->{sql}"}) if $@;
229
+    
230
+    if ($@) {
231
+        $self->_croak($@, qq{. Following SQL is executed.\n}
232
+                        . qq{$query->{sql}\n(DBIx::Custom::create_query)});
233
+    }
227 234
     
228 235
     # Set statement handle
229 236
     $query->sth($sth);
... ...
@@ -249,6 +256,7 @@ sub dbh {
249 256
         # From Connction manager
250 257
         if (my $connector = $self->connector) {
251 258
             croak "connector must have dbh() method"
259
+                . " (DBIx::Custom::dbh)"
252 260
               unless ref $connector && $connector->can('dbh');
253 261
               
254 262
             return $self->{dbh} = $connector->dbh;
... ...
@@ -266,13 +274,15 @@ sub delete {
266 274
 
267 275
     # Check arguments
268 276
     foreach my $name (keys %args) {
269
-        croak qq{Argument "$name" is wrong name}
277
+        croak qq{"$name" is wrong option}
278
+            . qq{ (DBIx::Custom::delete)}
270 279
           unless $DELETE_ARGS{$name};
271 280
     }
272 281
     
273 282
     # Arguments
274 283
     my $table = $args{table} || '';
275
-    croak qq{"table" option must be specified} unless $table;
284
+    croak qq{"table" option must be specified. (DBIx::Custom::delete)}
285
+      unless $table;
276 286
     my $where            = delete $args{where} || {};
277 287
     my $append           = delete $args{append};
278 288
     my $allow_delete_all = delete $args{allow_delete_all};
... ...
@@ -283,7 +293,7 @@ sub delete {
283 293
     
284 294
     # Where clause
285 295
     my $where_clause = $where->to_string;
286
-    croak qq{"where" must be specified}
296
+    croak qq{"where" must be specified (DBIx::Custom::delete)}
287 297
       if $where_clause eq '' && !$allow_delete_all;
288 298
 
289 299
     # Delete statement
... ...
@@ -320,13 +330,12 @@ sub delete_at {
320 330
     
321 331
     # Check arguments
322 332
     foreach my $name (keys %args) {
323
-        croak qq{Argument "$name" is wrong name}
333
+        croak qq{"$name" is wrong option (DBIx::Custom::delete_at)}
324 334
           unless $DELETE_AT_ARGS{$name};
325 335
     }
326 336
     
327 337
     # Create where parameter
328 338
     my $where_param = $self->_create_where_param($where, $primary_keys);
329
-
330 339
     
331 340
     return $self->delete(where => $where_param, %args);
332 341
 }
... ...
@@ -357,6 +366,7 @@ sub create_model {
357 366
     
358 367
     # Associate table with model
359 368
     croak "Table name is duplicated"
369
+        . " (DBIx::Custom::create_model)"
360 370
       if exists $self->{_model_from}->{$model->table};
361 371
     $self->{_model_from}->{$model->table} = $model->name;
362 372
 
... ...
@@ -405,7 +415,7 @@ sub execute {
405 415
     
406 416
     # Check argument names
407 417
     foreach my $name (keys %args) {
408
-        croak qq{Argument "$name" is wrong name}
418
+        croak qq{"$name" is wrong option (DBIx::Custom::execute)}
409 419
           unless $EXECUTE_ARGS{$name};
410 420
     }
411 421
     
... ...
@@ -465,6 +475,7 @@ sub execute {
465 475
         }
466 476
         elsif (ref $name ne 'CODE') {
467 477
           croak qq{Filter "$name" is not registered"}
478
+              . qq{ (DBIx::Custom::execute}
468 479
             unless exists $self->filters->{$name};
469 480
           $filter->{$column} = $self->filters->{$name};
470 481
         }
... ...
@@ -488,7 +499,11 @@ sub execute {
488 499
         }
489 500
         $affected = $sth->execute;
490 501
     };
491
-    $self->_croak($@, qq{. Following SQL is executed. "$query->{sql}"}) if $@;
502
+    
503
+    if ($@) {
504
+        $self->_croak($@, qq{. Following SQL is executed.\n}
505
+                        . qq{$query->{sql}\n});
506
+    }
492 507
     
493 508
     # Output SQL for debug
494 509
     warn $query->sql . "\n" if DEBUG;
... ...
@@ -533,14 +548,15 @@ sub insert {
533 548
     
534 549
     # Arguments
535 550
     my $table  = delete $args{table};
536
-    croak qq{"table" option must be specified} unless $table;
551
+    croak qq{"table" option must be specified (DBIx::Custom::insert)}
552
+      unless $table;
537 553
     my $param  = delete $args{param} || {};
538 554
     my $append = delete $args{append} || '';
539 555
     my $query_return  = delete $args{query};
540 556
 
541 557
     # Check arguments
542 558
     foreach my $name (keys %args) {
543
-        croak qq{Argument "$name" is wrong name}
559
+        croak qq{"$name" is wrong option (DBIx::Custom::insert)}
544 560
           unless $INSERT_ARGS{$name};
545 561
     }
546 562
 
... ...
@@ -552,6 +568,7 @@ sub insert {
552 568
     my $safety = $self->safety_character;
553 569
     foreach my $column (keys %$param) {
554 570
         croak qq{"$column" is not safety column name}
571
+            . qq{ (DBIx::Custom::insert)}
555 572
           unless $column =~ /^[$safety\.]+$/;
556 573
           $column = "$q$column$q";
557 574
           $column =~ s/\./$q.$q/;
... ...
@@ -590,7 +607,7 @@ sub insert_at {
590 607
     
591 608
     # Check arguments
592 609
     foreach my $name (keys %args) {
593
-        croak qq{Argument "$name" is wrong name}
610
+        croak qq{"$name" is wrong option (DBIx::Custom::insert_at)}
594 611
           unless $INSERT_AT_ARGS{$name};
595 612
     }
596 613
     
... ...
@@ -611,6 +628,7 @@ sub insert_param_tag {
611 628
     my @placeholders;
612 629
     foreach my $column (keys %$param) {
613 630
         croak qq{"$column" is not safety column name}
631
+            . qq{ (DBIx::Custom::insert_param_tag) }
614 632
           unless $column =~ /^[$safety\.]+$/;
615 633
         $column = "$q$column$q";
616 634
         $column =~ s/\./$q.$q/;
... ...
@@ -633,15 +651,19 @@ sub include_model {
633 651
 
634 652
         # Load name space module
635 653
         croak qq{"$name_space" is invalid class name}
654
+            . qq{ (DBIx::Custom::include_model)}
636 655
           if $name_space =~ /[^\w:]/;
637 656
         eval "use $name_space";
638
-        croak qq{Name space module "$name_space.pm" is needed. $@} if $@;
657
+        croak qq{Name space module "$name_space.pm" is needed. $@}
658
+            . qq{ (DBIx::Custom::include_model)}
659
+          if $@;
639 660
         
640 661
         # Search model modules
641 662
         my $path = $INC{"$name_space.pm"};
642 663
         $path =~ s/\.pm$//;
643 664
         opendir my $dh, $path
644
-          or croak qq{Can't open directory "$path": $!};
665
+          or croak qq{Can't open directory "$path": $!}
666
+                 . qq{ (DBIx::Custom::include_model)};
645 667
         $model_infos = [];
646 668
         while (my $module = readdir $dh) {
647 669
             push @$model_infos, $module
... ...
@@ -668,10 +690,11 @@ sub include_model {
668 690
         else { $model_class = $model_name = $model_table = $model_info }
669 691
         my $mclass = "${name_space}::$model_class";
670 692
         croak qq{"$mclass" is invalid class name}
693
+            . qq{ (DBIx::Custom::inculde_model)}
671 694
           if $mclass =~ /[^\w:]/;
672 695
         unless ($mclass->can('isa')) {
673 696
             eval "use $mclass";
674
-            croak $@ if $@;
697
+            croak "$@ (DBIx::Custom::include_model)" if $@;
675 698
         }
676 699
         
677 700
         # Create model
... ...
@@ -726,7 +749,7 @@ sub model {
726 749
     }
727 750
     
728 751
     # Check model existance
729
-    croak qq{Model "$name" is not included}
752
+    croak qq{Model "$name" is not included (DBIx::Custom::model)}
730 753
       unless $self->models->{$name};
731 754
     
732 755
     # Get model
... ...
@@ -751,7 +774,7 @@ sub new {
751 774
     # Check attributes
752 775
     my @attrs = keys %$self;
753 776
     foreach my $attr (@attrs) {
754
-        croak qq{"$attr" is wrong name}
777
+        croak qq{"$attr" is wrong name (DBIx::Custom::new)}
755 778
           unless $self->can($attr);
756 779
     }
757 780
     
... ...
@@ -803,6 +826,7 @@ sub select {
803 826
     my $append    = delete $args{append};
804 827
     my $join      = delete $args{join} || [];
805 828
     croak qq{"join" must be array reference}
829
+        . qq{ (DBIx::Custom::select)}
806 830
       unless ref $join eq 'ARRAY';
807 831
     my $relation = delete $args{relation};
808 832
     my $param = delete $args{param} || {};
... ...
@@ -810,7 +834,7 @@ sub select {
810 834
 
811 835
     # Check arguments
812 836
     foreach my $name (keys %args) {
813
-        croak qq{Argument "$name" is wrong name}
837
+        croak qq{"$name" is wrong option (DBIx::Custom::select)}
814 838
           unless $SELECT_ARGS{$name};
815 839
     }
816 840
     
... ...
@@ -847,7 +871,8 @@ sub select {
847 871
         push @sql, "$q$main_table$q";
848 872
     }
849 873
     pop @sql if ($sql[-1] || '') eq ',';
850
-    croak "Not found table name" unless $tables->[-1];
874
+    croak "Not found table name (DBIx::Custom::select)"
875
+      unless $tables->[-1];
851 876
 
852 877
     # Add tables in parameter
853 878
     unshift @$tables, @{$self->_search_tables(join(' ', keys %$param) || '')};
... ...
@@ -906,12 +931,13 @@ sub select_at {
906 931
     
907 932
     # Check arguments
908 933
     foreach my $name (keys %args) {
909
-        croak qq{Argument "$name" is wrong name}
934
+        croak qq{"$name" is wrong option (DBIx::Custom::select_at)}
910 935
           unless $SELECT_AT_ARGS{$name};
911 936
     }
912 937
     
913 938
     # Table
914
-    croak qq{"table" option must be specified} unless $args{table};
939
+    croak qq{"table" option must be specified (DBIx::Custom::select_at)}
940
+      unless $args{table};
915 941
     my $table = ref $args{table} ? $args{table}->[-1] : $args{table};
916 942
     
917 943
     # Create where parameter
... ...
@@ -943,7 +969,8 @@ sub update {
943 969
 
944 970
     # Arguments
945 971
     my $table = delete $args{table} || '';
946
-    croak qq{"table" option must be specified} unless $table;
972
+    croak qq{"table" option must be specified (DBIx::Custom::update)}
973
+      unless $table;
947 974
     my $param            = delete $args{param} || {};
948 975
     my $where            = delete $args{where} || {};
949 976
     my $append           = delete $args{append} || '';
... ...
@@ -951,7 +978,7 @@ sub update {
951 978
     
952 979
     # Check argument names
953 980
     foreach my $name (keys %args) {
954
-        croak qq{Argument "$name" is wrong name}
981
+        croak qq{"$name" is wrong option (DBIx::Custom::update)}
955 982
           unless $UPDATE_ARGS{$name};
956 983
     }
957 984
     
... ...
@@ -961,6 +988,7 @@ sub update {
961 988
     my $q = $self->reserved_word_quote;
962 989
     foreach my $column (keys %$param) {
963 990
         croak qq{"$column" is not safety column name}
991
+            . qq{ (DBIx::Custom::update)}
964 992
           unless $column =~ /^[$safety\.]+$/;
965 993
           $column = "$q$column$q";
966 994
           $column =~ s/\./$q.$q/;
... ...
@@ -973,7 +1001,7 @@ sub update {
973 1001
     # Where
974 1002
     $where = $self->_where_to_obj($where);
975 1003
     my $where_clause = $where->to_string;
976
-    croak qq{"where" must be specified}
1004
+    croak qq{"where" must be specified (DBIx::Custom::update)}
977 1005
       if "$where_clause" eq '' && !$allow_update_all;
978 1006
     
979 1007
     # Update statement
... ...
@@ -1017,7 +1045,7 @@ sub update_at {
1017 1045
 
1018 1046
     # Check arguments
1019 1047
     foreach my $name (keys %args) {
1020
-        croak qq{Argument "$name" is wrong name}
1048
+        croak qq{"$name" is wrong option (DBIx::Custom::update_at)}
1021 1049
           unless $UPDATE_AT_ARGS{$name};
1022 1050
     }
1023 1051
     
... ...
@@ -1035,7 +1063,13 @@ sub _create_where_param {
1035 1063
     if ($where) {
1036 1064
         $where = [$where] unless ref $where;
1037 1065
         croak qq{"where" must be constant value or array reference}
1066
+            . " (" . (caller 1)[3] . ")"
1038 1067
           unless !ref $where || ref $where eq 'ARRAY';
1068
+        
1069
+        croak qq{"where" must contain values same count as primary key}
1070
+            . " (" . (caller 1)[3] . ")"
1071
+          unless @$primary_keys eq @$where;
1072
+        
1039 1073
         for(my $i = 0; $i < @$primary_keys; $i ++) {
1040 1074
            $where_param->{$primary_keys->[$i]} = $where->[$i];
1041 1075
         }
+3 -1
lib/DBIx/Custom/Model.pm
... ...
@@ -40,7 +40,8 @@ sub AUTOLOAD {
40 40
         $self->dbi->dbh->$dbh_method(@_);
41 41
     }
42 42
     else {
43
-        croak qq/Can't locate object method "$mname" via "$package"/
43
+        croak qq{Can't locate object method "$mname" via "$package"}
44
+            . qq{ (DBIx::Custom::Model::AUTOLOAD) }
44 45
     }
45 46
 }
46 47
 
... ...
@@ -110,6 +111,7 @@ sub new {
110 111
     my @attrs = keys %$self;
111 112
     foreach my $attr (@attrs) {
112 113
         croak qq{"$attr" is invalid attribute name}
114
+            . qq{ (DBIx::Custom::Model::new) }
113 115
           unless $self->can($attr);
114 116
     }
115 117
     
+1
lib/DBIx/Custom/Query.pm
... ...
@@ -44,6 +44,7 @@ sub filter {
44 44
               && ref $fname ne 'CODE') 
45 45
             {
46 46
               croak qq{Filter "$fname" is not registered"}
47
+                  . qq{ (DBIx::Custom::Query::filter) }
47 48
                 unless exists $self->filters->{$fname};
48 49
               
49 50
               $filter->{$column} = $self->filters->{$fname};
+11 -4
lib/DBIx/Custom/QueryBuilder.pm
... ...
@@ -78,10 +78,12 @@ sub _build_query {
78 78
             
79 79
             # Tag is not registered
80 80
             croak qq{Tag "$tag_name" in "{a }" is not registered}
81
+                . qq{ (DBIx::Custom::QueryBuilder::build_query)}
81 82
               unless $tag;
82 83
             
83 84
             # Tag not sub reference
84 85
             croak qq{Tag "$tag_name" must be sub reference}
86
+                . qq{ (DBIx::Custom::QueryBuilder::build_query)}
85 87
               unless ref $tag eq 'CODE';
86 88
             
87 89
             # Execute tag
... ...
@@ -89,6 +91,7 @@ sub _build_query {
89 91
             
90 92
             # Check tag return value
91 93
             croak qq{Tag "$tag_name" must return [STRING, ARRAY_REFERENCE]}
94
+                . qq{ (DBIx::Custom::QueryBuilder::build_query)}
92 95
               unless ref $r eq 'ARRAY' && defined $r->[0] && ref $r->[1] eq 'ARRAY';
93 96
             
94 97
             # Part of SQL statement and colum names
... ...
@@ -106,6 +109,7 @@ sub _build_query {
106 109
     my $placeholder_count = $self->_placeholder_count($sql);
107 110
     my $column_count      = @$all_columns;
108 111
     croak qq{Placeholder count in "$sql" must be same as column count $column_count}
112
+        . qq{ (DBIx::Custom::QueryBuilder::build_query)}
109 113
       unless $placeholder_count eq @$all_columns;
110 114
     
111 115
     # Add semicolon
... ...
@@ -187,8 +191,9 @@ sub _parse {
187 191
                 
188 192
                 # Unexpected
189 193
                 else {
190
-                    croak qq/Parsing error. unexpected "}". / .
191
-                          qq/pos $pos of "$original"/;
194
+                    croak qq{Parsing error. unexpected "\}". }
195
+                        . qq{pos $pos of "$original"}
196
+                        . qq{ (DBIx::Custom::QueryBuilder::build_query)};
192 197
                 }
193 198
             }
194 199
             
... ...
@@ -210,8 +215,9 @@ sub _parse {
210 215
                 
211 216
                 # Unexpected
212 217
                 else {
213
-                    croak qq/Parsing error. unexpected "{". / .
214
-                          qq/pos $pos of "$original"/;
218
+                    croak qq{Parsing error. unexpected "\{". }
219
+                        . qq{pos $pos of "$original"}
220
+                        . qq{ (DBIx::Custom::QueryBuilder::build_query)};
215 221
                 }
216 222
             }
217 223
             
... ...
@@ -253,6 +259,7 @@ sub _parse {
253 259
     
254 260
     # Tag not finished
255 261
     croak qq{Tag not finished. "$original"}
262
+        . qq{ (DBIx::Custom::QueryBuilder::build_query)}
256 263
       if $state eq 'tag';
257 264
     
258 265
     # Add rest text
+4 -2
lib/DBIx/Custom/Result.pm
... ...
@@ -36,6 +36,7 @@ sub filter {
36 36
               && ref $fname ne 'CODE') 
37 37
             {
38 38
               croak qq{Filter "$fname" is not registered"}
39
+                  . qq{ (DBIx::Custom::Result::filter)}
39 40
                 unless exists $self->filters->{$fname};
40 41
               
41 42
               $filter->{$column} = $self->filters->{$fname};
... ...
@@ -73,6 +74,7 @@ sub end_filter {
73 74
               && ref $fname ne 'CODE') 
74 75
             {
75 76
               croak qq{Filter "$fname" is not registered"}
77
+                  . qq{ (DBIx::Custom::Result::end_filter)}
76 78
                 unless exists $self->filters->{$fname};
77 79
               
78 80
               $end_filter->{$column} = $self->filters->{$fname};
... ...
@@ -213,7 +215,7 @@ sub fetch_hash_multi {
213 215
     my ($self, $count) = @_;
214 216
     
215 217
     # Row count not specified
216
-    croak 'Row count must be specified'
218
+    croak 'Row count must be specified (DBIx::Custom::Result::fetch_hash_multi)'
217 219
       unless $count;
218 220
     
219 221
     # Fetch multi rows
... ...
@@ -232,7 +234,7 @@ sub fetch_multi {
232 234
     my ($self, $count) = @_;
233 235
     
234 236
     # Row count not specifed
235
-    croak 'Row count must be specified'
237
+    croak 'Row count must be specified (DBIx::Custom::Result::fetch_multi)'
236 238
       unless $count;
237 239
     
238 240
     # Fetch multi rows
+3
lib/DBIx/Custom/Tag.pm
... ...
@@ -17,6 +17,7 @@ sub in {
17 17
     
18 18
     # Check arguments
19 19
     croak qq{Column name and count of values must be specified in tag "{in }"}
20
+        . qq{ (DBIx::Custom::Tag::in) }
20 21
       unless $column && $count && $count =~ /^\d+$/;
21 22
 
22 23
     # Part of statement
... ...
@@ -60,6 +61,7 @@ sub placeholder {
60 61
     
61 62
     # Check arguments
62 63
     croak qq{Column name must be specified in tag "{? }"}
64
+        . qq{ (DBIx::Custom::Tag::placeholder)}
63 65
       unless $column;
64 66
     
65 67
     return ['?', [$column]];
... ...
@@ -81,6 +83,7 @@ sub _basic {
81 83
     
82 84
     # Check arguments
83 85
     croak qq{Column name must be specified in tag "{$name }"}
86
+        . qq{ (DBIx::Custom::Tag::_basic) }
84 87
       unless $column;
85 88
     
86 89
     return ["$column $name ?", [$column]];
+22 -5
lib/DBIx/Custom/Where.pm
... ...
@@ -19,6 +19,20 @@ __PACKAGE__->attr(
19 19
     reserved_word_quote => ''
20 20
 );
21 21
 
22
+sub new {
23
+    my $self = shift->SUPER::new(@_);
24
+    
25
+    # Check attribute names
26
+    my @attrs = keys %$self;
27
+    foreach my $attr (@attrs) {
28
+        croak qq{"$attr" is invalid attribute name}
29
+            . qq{ (DBIx::Custom::Where::new) }
30
+          unless $self->can($attr);
31
+    }
32
+    
33
+    return $self;
34
+}
35
+
22 36
 sub to_string {
23 37
     my $self = shift;
24 38
     
... ...
@@ -49,7 +63,7 @@ sub _parse {
49 63
         
50 64
         # Operation
51 65
         my $op = $clause->[0] || '';
52
-        croak qq{"$op" is invalid operation}
66
+        croak qq{"$op" is invalid operation (DBIx::Custom::Where::to_string)}
53 67
           unless $VALID_OPERATIONS{$op};
54 68
         
55 69
         # Parse internal clause
... ...
@@ -81,7 +95,8 @@ sub _parse {
81 95
             return $pushed;
82 96
         }
83 97
         elsif (@$columns != 1) {
84
-            croak qq{Each tag contains one column name: tag "$clause"}
98
+            croak qq{Each tag contains one column name: tag "$clause" }
99
+                  . "(DBIx::Custom::Where::to_string)"
85 100
         }
86 101
 
87 102
         my $column = $columns->[0];
... ...
@@ -90,7 +105,7 @@ sub _parse {
90 105
         }
91 106
         
92 107
         my $safety = $self->safety_character;
93
-        croak qq{"$column" is not safety column name}
108
+        croak qq{"$column" is not safety column name (DBIx::Custom::Where::to_string)}
94 109
           unless $column =~ /^[$safety\.]+$/;
95 110
         
96 111
         # Column count up
... ...
@@ -115,8 +130,10 @@ sub _parse {
115 130
             push @$where, $clause;
116 131
             $pushed = 1;
117 132
         }
118
-        else { croak "Parameter must be hash reference or undfined value" }
119
-        
133
+        else {
134
+            croak "Parameter must be hash reference or undfined value "
135
+                . "(DBIx::Custom::Where::to_string)"
136
+        }
120 137
         return $pushed;
121 138
     }
122 139
 }
+13 -1
t/dbix-custom-core-sqlite.t
... ...
@@ -599,7 +599,7 @@ $dbi->execute($CREATE_TABLE->{0});
599 599
 }
600 600
 
601 601
 eval{$dbi->execute('select * from table1', no_exists => 1)};
602
-like($@, qr/name/, "invald SQL");
602
+like($@, qr/wrong/, "invald SQL");
603 603
 
604 604
 $query = $dbi->create_query('select * from table1 where {= key1}');
605 605
 $dbi->dbh->disconnect;
... ...
@@ -1258,6 +1258,9 @@ $result = $dbi->select(
1258 1258
 $row = $result->fetch_hash_all;
1259 1259
 is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], 'not_exists');
1260 1260
 
1261
+eval {$dbi->where(ppp => 1) };
1262
+like($@, qr/invalid/);
1263
+
1261 1264
 test 'dbi_option default';
1262 1265
 $dbi = DBIx::Custom->new;
1263 1266
 is_deeply($dbi->dbi_option, {});
... ...
@@ -1660,6 +1663,15 @@ eval {
1660 1663
 };
1661 1664
 like($@, qr/must be/);
1662 1665
 
1666
+eval {
1667
+    $result = $dbi->select_at(
1668
+        table => 'table1',
1669
+        primary_key => ['key1', 'key2'],
1670
+        where => [1],
1671
+    );
1672
+};
1673
+like($@, qr/same/);
1674
+
1663 1675
 eval {
1664 1676
     $result = $dbi->update_at(
1665 1677
         table => 'table1',