... | ... |
@@ -1,4 +1,5 @@ |
1 | 1 |
0.1701 |
2 |
+ - added EXPERIMENTAL DBIx::Custom::Result header method |
|
2 | 3 |
- added EXPERIMENTAL last_sql attribute method |
3 | 4 |
0.1700 |
4 | 5 |
- fixed end_filter DEPRECATED warnings bug |
... | ... |
@@ -54,13 +54,15 @@ sub filter_on { |
54 | 54 |
sub fetch { |
55 | 55 |
my $self = shift; |
56 | 56 |
|
57 |
+ # Info |
|
58 |
+ my $columns = $self->{sth}->{NAME}; |
|
59 |
+ my $types = $self->{sth}->{TYPE}; |
|
60 |
+ |
|
57 | 61 |
# Fetch |
58 | 62 |
my @row = $self->{sth}->fetchrow_array; |
59 | 63 |
return unless @row; |
60 | 64 |
|
61 | 65 |
# Filtering |
62 |
- my $columns = $self->{sth}->{NAME}; |
|
63 |
- my $types = $self->{sth}->{TYPE}; |
|
64 | 66 |
my $type_rule1 = $self->type_rule->{from1} || {}; |
65 | 67 |
my $type_rule2 = $self->type_rule->{from2} || {}; |
66 | 68 |
my $filter = $self->filter; |
... | ... |
@@ -117,6 +119,10 @@ sub fetch_first { |
117 | 119 |
sub fetch_hash { |
118 | 120 |
my $self = shift; |
119 | 121 |
|
122 |
+ # Info |
|
123 |
+ my $columns = $self->{sth}->{NAME}; |
|
124 |
+ my $types = $self->{sth}->{TYPE}; |
|
125 |
+ |
|
120 | 126 |
# Fetch |
121 | 127 |
my $row = $self->{sth}->fetchrow_arrayref; |
122 | 128 |
return unless $row; |
... | ... |
@@ -125,8 +131,6 @@ sub fetch_hash { |
125 | 131 |
my $hash_row = {}; |
126 | 132 |
my $filter = $self->filter; |
127 | 133 |
my $end_filter = $self->{end_filter} || {}; |
128 |
- my $columns = $self->{sth}->{NAME}; |
|
129 |
- my $types = $self->{sth}->{TYPE}; |
|
130 | 134 |
my $type_rule1 = $self->type_rule->{from1} || {}; |
131 | 135 |
my $type_rule2 = $self->type_rule->{from2} || {}; |
132 | 136 |
for (my $i = 0; $i < @$columns; $i++) { |
... | ... |
@@ -215,6 +219,8 @@ sub fetch_multi { |
215 | 219 |
return $rows; |
216 | 220 |
} |
217 | 221 |
|
222 |
+sub header { shift->sth->{NAME} } |
|
223 |
+ |
|
218 | 224 |
*one = \&fetch_hash_first; |
219 | 225 |
|
220 | 226 |
sub type_rule { |
... | ... |
@@ -482,6 +488,12 @@ By default, filterin is on. |
482 | 488 |
Turn filtering by C<filter> method on. |
483 | 489 |
By default, filterin is on. |
484 | 490 |
|
491 |
+=head2 C<header> EXPERIMENTAL |
|
492 |
+ |
|
493 |
+ my $header = $result->header; |
|
494 |
+ |
|
495 |
+Get header column names. |
|
496 |
+ |
|
485 | 497 |
=head2 C<one> |
486 | 498 |
|
487 | 499 |
my $row = $result->one; |
... | ... |
@@ -3327,4 +3327,15 @@ test 'last_sql'; |
3327 | 3327 |
is($dbi->last_sql, 'aaa;'); |
3328 | 3328 |
|
3329 | 3329 |
} |
3330 |
+ |
|
3331 |
+test 'DBIx::Custom header'; |
|
3332 |
+{ |
|
3333 |
+ my $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:'); |
|
3334 |
+ $dbi->execute("create table table1 (key1, key2)"); |
|
3335 |
+ my $result = $dbi->execute('select key1 as h1, key2 as h2 from table1'); |
|
3336 |
+ |
|
3337 |
+ is_deeply($result->header, [qw/h1 h2/]); |
|
3338 |
+ |
|
3339 |
+} |
|
3340 |
+ |
|
3330 | 3341 |
=cut |