... | ... |
@@ -1,82 +1,84 @@ |
1 |
+0.1659 |
|
2 |
+ - added select() all_column option |
|
1 | 3 |
0.1658 |
2 |
- - added experimental DBIx::Custom::Model column() prefix option. |
|
4 |
+ - added EXPERIMENTAL DBIx::Custom::Model column() prefix option. |
|
3 | 5 |
- fixed select_at join column invalid bug |
4 | 6 |
- added DBIx::Custom::Model column() attribute |
5 | 7 |
0.1657 |
6 |
- - remaned experimental safty_charcter to safty_name |
|
8 |
+ - remaned EXPERIMENTAL safty_charcter to safty_name |
|
7 | 9 |
- safty_charcter is changed, set only one character regex. |
8 | 10 |
0.1656 |
9 | 11 |
- fixed some select() join opition bug |
10 | 12 |
0.1655 |
11 |
- - added experimental DBIx::Custom::Model join attribute |
|
12 |
- - added experimental select() join option |
|
13 |
+ - added EXPERIMENTAL DBIx::Custom::Model join attribute |
|
14 |
+ - added EXPERIMENTAL select() join option |
|
13 | 15 |
- deprecated select() relation option |
14 |
- - added experimental update_param and insert_param |
|
15 |
- - remove experimental DBIx::Custom::Model relation |
|
16 |
+ - added EXPERIMENTAL update_param and insert_param |
|
17 |
+ - remove EXPERIMENTAL DBIx::Custom::Model relation |
|
16 | 18 |
0.1654 |
17 | 19 |
- selection can contain where clause. |
18 | 20 |
0.1653 |
19 |
- - added experimental DBIx::Custom::Result remove_filter() |
|
20 |
- - added experimental DBIx::Custom::Result remove_end_filter() |
|
21 |
- - added experimental DBIx::Custom::Model insert_at() |
|
22 |
- - added experimental insert_at() |
|
21 |
+ - added EXPERIMENTAL DBIx::Custom::Result remove_filter() |
|
22 |
+ - added EXPERIMENTAL DBIx::Custom::Result remove_end_filter() |
|
23 |
+ - added EXPERIMENTAL DBIx::Custom::Model insert_at() |
|
24 |
+ - added EXPERIMENTAL insert_at() |
|
23 | 25 |
- improved error message |
24 | 26 |
0.1652 |
25 | 27 |
- all filter can receive array reference and receiving hash reference is DEPRECATED! |
26 | 28 |
0.1651 |
27 |
- - add experimental DBIx::Custom::Model filter attribute. |
|
29 |
+ - add EXPERIMENTAL DBIx::Custom::Model filter attribute. |
|
28 | 30 |
0.1650 |
29 |
- - add experimental DBIx::Custom::Model name() attribute |
|
31 |
+ - add EXPERIMENTAL DBIx::Custom::Model name() attribute |
|
30 | 32 |
0.1649 |
31 |
- - add experimental DBIx::Custom::Model column_clause() method. |
|
33 |
+ - add EXPERIMENTAL DBIx::Custom::Model column_clause() method. |
|
32 | 34 |
- select method column option can receive string. |
33 | 35 |
- DBIx::Custom::Model select() and select_at() think about relation attirbute |
34 | 36 |
0.1648 |
35 |
- - add experimental DBIx::Custom::Model relation() attribute |
|
36 |
- - add experimental update_at(), delete_at(), select_at() |
|
37 |
- - add experimental setup_model() |
|
38 |
- - add experimental DBIx::Custom::Model columns attirbute |
|
39 |
- - add experimental DBIx::Custom::Model foreign_key() attribute |
|
40 |
- - add experimental models() attribute |
|
37 |
+ - add EXPERIMENTAL DBIx::Custom::Model relation() attribute |
|
38 |
+ - add EXPERIMENTAL update_at(), delete_at(), select_at() |
|
39 |
+ - add EXPERIMENTAL setup_model() |
|
40 |
+ - add EXPERIMENTAL DBIx::Custom::Model columns attirbute |
|
41 |
+ - add EXPERIMENTAL DBIx::Custom::Model foreign_key() attribute |
|
42 |
+ - add EXPERIMENTAL models() attribute |
|
41 | 43 |
0.1647 |
42 | 44 |
- add default_dbi_option() |
43 | 45 |
0.1646 |
44 | 46 |
- add feture. all model class in namespace is included by include_model |
45 |
- - rename experimental include_table to include_model |
|
46 |
- - rename experimental table to model |
|
47 |
- - rename experimental DBIx::Custom::Table to DBIx::Custom::Model |
|
48 |
- - remame experimental DBIx::Custom::Table::name() to DBIx::Custom::Model::table(); |
|
47 |
+ - rename EXPERIMENTAL include_table to include_model |
|
48 |
+ - rename EXPERIMENTAL table to model |
|
49 |
+ - rename EXPERIMENTAL DBIx::Custom::Table to DBIx::Custom::Model |
|
50 |
+ - remame EXPERIMENTAL DBIx::Custom::Table::name() to DBIx::Custom::Model::table(); |
|
49 | 51 |
0.1645 |
50 |
- - removed experimental base_table() for class expandability. |
|
51 |
- - experimental table() can't set table object any more. |
|
52 |
- - added experimental include_table(). |
|
52 |
+ - removed EXPERIMENTAL base_table() for class expandability. |
|
53 |
+ - EXPERIMENTAL table() can't set table object any more. |
|
54 |
+ - added EXPERIMENTAL include_table(). |
|
53 | 55 |
0.1644 |
54 | 56 |
- update pod |
55 | 57 |
0.1643 |
56 |
- - add experimental selection option to select() |
|
57 |
- - add experimental table tag |
|
58 |
+ - add EXPERIMENTAL selection option to select() |
|
59 |
+ - add EXPERIMENTAL table tag |
|
58 | 60 |
- fix bug : filter can't overwirite undef value. |
59 |
- - add experimental feature to apply_filter(). you can apply end filter. |
|
60 |
- - add experimental feature to apply_filter(). TABLE__COLUMN is filterded now. |
|
61 |
+ - add EXPERIMENTAL feature to apply_filter(). you can apply end filter. |
|
62 |
+ - add EXPERIMENTAL feature to apply_filter(). TABLE__COLUMN is filterded now. |
|
61 | 63 |
0.1642 |
62 |
- - removed experimental DBIx::Custom::Table base() method |
|
64 |
+ - removed EXPERIMENTAL DBIx::Custom::Table base() method |
|
63 | 65 |
- table created by tabled method can call base_$method correponding to base_table's one |
64 | 66 |
0.1641 |
65 | 67 |
- select() where can't receive array reference to prevend SQL injection easily(not backward compatible. sorry. use where() instead) |
66 |
- - added experimental safety_column_name attribute |
|
68 |
+ - added EXPERIMENTAL safety_column_name attribute |
|
67 | 69 |
- fix SQL injection security hole about column name |
68 | 70 |
0.1640 |
69 | 71 |
- autoload DBI method |
70 |
- - removed experimental expand |
|
72 |
+ - removed EXPERIMENTAL expand |
|
71 | 73 |
0.1639 |
72 | 74 |
- improved delete() and update() where option. you can use DBIx::Custom::Where object |
73 |
- - added experimental not_exists() |
|
75 |
+ - added EXPERIMENTAL not_exists() |
|
74 | 76 |
0.1638 |
75 | 77 |
- table object call dbi object method if not found method. |
76 |
- - added experimental base_table attribute and removed experimental table_class attribute |
|
78 |
+ - added EXPERIMENTAL base_table attribute and removed EXPERIMENTAL table_class attribute |
|
77 | 79 |
- renamed helper to method. |
78 |
- - added experimental DBIx::Custom::Result::stash() |
|
79 |
- - renamed experimental DBIx::Custom::Table helper to method |
|
80 |
+ - added EXPERIMENTAL DBIx::Custom::Result::stash() |
|
81 |
+ - renamed EXPERIMENTAL DBIx::Custom::Table helper to method |
|
80 | 82 |
0.1637 |
81 | 83 |
- renamed dbi_options to dbi_option. dbi_options is available, but deprecated. |
82 | 84 |
- renamed DBIx::Custom::TagProcessor to DBIx::Custom::Tag, and function names is cleanuped. |
... | ... |
@@ -85,7 +87,7 @@ |
85 | 87 |
- improved error message |
86 | 88 |
- build all clause if param is undefined. |
87 | 89 |
- each_column callback receive self as first argument. |
88 |
- - removed experimental txn_scope |
|
90 |
+ - removed EXPERIMENTAL txn_scope |
|
89 | 91 |
0.1636 |
90 | 92 |
- added tests and cleanup |
91 | 93 |
0.1635 |
... | ... |
@@ -96,15 +98,15 @@ |
96 | 98 |
0.1633 |
97 | 99 |
- fixed test |
98 | 100 |
0.1632 |
99 |
- - added experimental where method |
|
100 |
- - added experimental DBIx::Custom::Where. |
|
101 |
+ - added EXPERIMENTAL where method |
|
102 |
+ - added EXPERIMENTAL DBIx::Custom::Where. |
|
101 | 103 |
- removed DBIx::Custom::Or |
102 | 104 |
0.1631 |
103 |
- - added experimental DBIx::Custom::Result end_filter method |
|
104 |
- - experimental extended select method's where option |
|
105 |
+ - added EXPERIMENTAL DBIx::Custom::Result end_filter method |
|
106 |
+ - EXPERIMENTAL extended select method's where option |
|
105 | 107 |
- fix select method empty where failed bug |
106 |
- - added experimental suger method query option |
|
107 |
- - added experimental or method |
|
108 |
+ - added EXPERIMENTAL suger method query option |
|
109 |
+ - added EXPERIMENTAL or method |
|
108 | 110 |
0.1630 |
109 | 111 |
- fix test bug |
110 | 112 |
0.1629 |
... | ... |
@@ -118,15 +120,15 @@ |
118 | 120 |
- fixed connect method bug |
119 | 121 |
0.1627 |
120 | 122 |
- added insert, update, update_all, delete, delete_all, select method to DBIx::Custom::Table |
121 |
- - added experimental txn_scope |
|
123 |
+ - added EXPERIMENTAL txn_scope |
|
122 | 124 |
0.1626 |
123 | 125 |
- simplified DBIx::Custom::Model and DBIx::Custom::Table |
124 | 126 |
0.1625 |
125 |
- - added experimental DBIx::Custom::Model and DBIx::Custom::Table |
|
127 |
+ - added EXPERIMENTAL DBIx::Custom::Model and DBIx::Custom::Table |
|
126 | 128 |
0.1624 |
127 |
- - added experimental iterate_all_columns method. |
|
129 |
+ - added EXPERIMENTAL iterate_all_columns method. |
|
128 | 130 |
0.1623 |
129 |
- - added experimental auto_filter method |
|
131 |
+ - added EXPERIMENTAL auto_filter method |
|
130 | 132 |
- deprecated default_bind_filter and default_fetch_filter because these are global effect. |
131 | 133 |
- changed defautl_bind_filter and default_fetch_filter attributes to methods. |
132 | 134 |
- changed DBIx::Custom::Result default_filter attribute to method |
... | ... |
@@ -142,14 +144,14 @@ |
142 | 144 |
- updated document |
143 | 145 |
0.1619 |
144 | 146 |
- updated document |
145 |
- - added experimental expand method |
|
147 |
+ - added EXPERIMENTAL expand method |
|
146 | 148 |
0.1618 |
147 | 149 |
- added helper method |
148 | 150 |
- added begin_work, commit, and rollback method |
149 | 151 |
0.1617 |
150 | 152 |
- L<DBIx::Custom> is now stable. APIs keep backword compatible in the feature. |
151 | 153 |
0.1616 |
152 |
- - removed experimental register_method(), and methods attribute, because it is too magical |
|
154 |
+ - removed EXPERIMENTAL register_method(), and methods attribute, because it is too magical |
|
153 | 155 |
0.1615 |
154 | 156 |
- fixed DBIx::Custom::QueryBuilder build_query() bug |
155 | 157 |
- required Perl 5.008001 to use @CARP_NOT |
... | ... |
@@ -158,8 +160,8 @@ |
158 | 160 |
- enable escaping '{' and '}' in the source of SQL |
159 | 161 |
- fixed Carp Carp trust relationship |
160 | 162 |
0.1613 |
161 |
- - added experimental register_method() method |
|
162 |
- - added experimental methods attribute |
|
163 |
+ - added EXPERIMENTAL register_method() method |
|
164 |
+ - added EXPERIMENTAL methods attribute |
|
163 | 165 |
0.1612 |
164 | 166 |
- added tests |
165 | 167 |
- updated document |
... | ... |
@@ -620,19 +620,8 @@ sub register_filter { |
620 | 620 |
sub register_tag { shift->query_builder->register_tag(@_) } |
621 | 621 |
|
622 | 622 |
our %VALID_SELECT_ARGS |
623 |
- = map { $_ => 1 } qw/table column where append relation filter query selection join/; |
|
624 |
- |
|
625 |
-sub _need_tables { |
|
626 |
- my ($self, $tree, $need_tables, $tables) = @_; |
|
627 |
- |
|
628 |
- foreach my $table (@$tables) { |
|
629 |
- |
|
630 |
- if ($tree->{$table}) { |
|
631 |
- $need_tables->{$table} = 1; |
|
632 |
- $self->_need_tables($tree, $need_tables, [$tree->{$table}{parent}]) |
|
633 |
- } |
|
634 |
- } |
|
635 |
-} |
|
623 |
+ = map { $_ => 1 } qw/table column where append relation filter query |
|
624 |
+ selection join all_column/; |
|
636 | 625 |
|
637 | 626 |
sub select { |
638 | 627 |
my ($self, %args) = @_; |
... | ... |
@@ -649,7 +638,8 @@ sub select { |
649 | 638 |
: defined $table ? [$table] |
650 | 639 |
: []; |
651 | 640 |
my $columns = $args{column} || []; |
652 |
- $columns = [$columns] unless ref $columns; |
|
641 |
+ $columns = [$columns] unless ref $columns eq 'ARRAY'; |
|
642 |
+ my $all_column = $args{all_column}; |
|
653 | 643 |
my $selection = $args{selection} || ''; |
654 | 644 |
my $where = $args{where} || {}; |
655 | 645 |
my $append = $args{append}; |
... | ... |
@@ -674,19 +664,49 @@ sub select { |
674 | 664 |
unshift @$tables, @{$self->_tables($selection)}; |
675 | 665 |
} |
676 | 666 |
|
677 |
- # Column names and table name |
|
678 |
- else { |
|
679 |
- # Column names |
|
680 |
- if (@$columns) { |
|
681 |
- foreach my $column (@$columns) { |
|
682 |
- unshift @$tables, @{$self->_tables($column)}; |
|
683 |
- push @sql, ($column, ','); |
|
667 |
+ # Clumn clause, countains all columns of joined tables |
|
668 |
+ elsif ($all_column) { |
|
669 |
+ |
|
670 |
+ # Find tables |
|
671 |
+ my $main_table = $tables->[-1] || ''; |
|
672 |
+ my %tables; |
|
673 |
+ foreach my $j (@$join) { |
|
674 |
+ my $tables = $self->_tables($j); |
|
675 |
+ foreach my $table (@$tables) { |
|
676 |
+ $tables{$table} = 1; |
|
684 | 677 |
} |
685 |
- pop @sql if $sql[-1] eq ','; |
|
686 | 678 |
} |
687 |
- else { push @sql, '*' } |
|
679 |
+ delete $tables{$main_table}; |
|
680 |
+ my @column_clause; |
|
688 | 681 |
|
689 |
- # Table |
|
682 |
+ # Column clause of main table |
|
683 |
+ push @sql, $self->model($main_table)->column_clause; |
|
684 |
+ push @sql, ','; |
|
685 |
+ |
|
686 |
+ # Column cluase of other tables |
|
687 |
+ foreach my $table (keys %tables) { |
|
688 |
+ unshift @$tables, $table; |
|
689 |
+ push @sql, $self->model($table) |
|
690 |
+ ->column_clause(prefix => "${table}__"); |
|
691 |
+ push @sql, ','; |
|
692 |
+ } |
|
693 |
+ pop @sql if $sql[-1] eq ','; |
|
694 |
+ } |
|
695 |
+ |
|
696 |
+ # Column clause |
|
697 |
+ elsif (@$columns) { |
|
698 |
+ foreach my $column (@$columns) { |
|
699 |
+ unshift @$tables, @{$self->_tables($column)}; |
|
700 |
+ push @sql, ($column, ','); |
|
701 |
+ } |
|
702 |
+ pop @sql if $sql[-1] eq ','; |
|
703 |
+ } |
|
704 |
+ |
|
705 |
+ # "*" is default |
|
706 |
+ else { push @sql, '*' } |
|
707 |
+ |
|
708 |
+ # Table |
|
709 |
+ unless ($selection) { |
|
690 | 710 |
push @sql, 'from'; |
691 | 711 |
if ($args{relation}) { |
692 | 712 |
my $found = {}; |
... | ... |
@@ -752,7 +772,7 @@ sub select { |
752 | 772 |
|
753 | 773 |
our %VALID_SELECT_AT_ARGS |
754 | 774 |
= map { $_ => 1 } qw/table column where append relation filter query selection |
755 |
- param primary_key join/; |
|
775 |
+ param primary_key join all_column/; |
|
756 | 776 |
|
757 | 777 |
sub select_at { |
758 | 778 |
my ($self, %args) = @_; |
... | ... |
@@ -1125,6 +1145,18 @@ sub _croak { |
1125 | 1145 |
} |
1126 | 1146 |
} |
1127 | 1147 |
|
1148 |
+sub _need_tables { |
|
1149 |
+ my ($self, $tree, $need_tables, $tables) = @_; |
|
1150 |
+ |
|
1151 |
+ foreach my $table (@$tables) { |
|
1152 |
+ |
|
1153 |
+ if ($tree->{$table}) { |
|
1154 |
+ $need_tables->{$table} = 1; |
|
1155 |
+ $self->_need_tables($tree, $need_tables, [$tree->{$table}{parent}]) |
|
1156 |
+ } |
|
1157 |
+ } |
|
1158 |
+} |
|
1159 |
+ |
|
1128 | 1160 |
sub _tables { |
1129 | 1161 |
my ($self, $source) = @_; |
1130 | 1162 |
|
... | ... |
@@ -1438,7 +1470,7 @@ default to the following values. |
1438 | 1470 |
|
1439 | 1471 |
Filters, registered by C<register_filter()>. |
1440 | 1472 |
|
1441 |
-=head2 C<(experimental) models> |
|
1473 |
+=head2 C<models EXPERIMENTAL> |
|
1442 | 1474 |
|
1443 | 1475 |
my $models = $dbi->models; |
1444 | 1476 |
$dbi = $dbi->models(\%models); |
... | ... |
@@ -1466,7 +1498,7 @@ Query builder, default to L<DBIx::Custom::QueryBuilder> object. |
1466 | 1498 |
|
1467 | 1499 |
Result class, default to L<DBIx::Custom::Result>. |
1468 | 1500 |
|
1469 |
-=head2 C<(experimental) safety_character> |
|
1501 |
+=head2 C<safety_character EXPERIMENTAL> |
|
1470 | 1502 |
|
1471 | 1503 |
my $safety_character = $self->safety_character; |
1472 | 1504 |
$dbi = $self->safety_character($character); |
... | ... |
@@ -1487,7 +1519,7 @@ L<DBIx::Custom> inherits all methods from L<Object::Simple> |
1487 | 1519 |
and use all methods of L<DBI> |
1488 | 1520 |
and implements the following new ones. |
1489 | 1521 |
|
1490 |
-=head2 C<(experimental) apply_filter> |
|
1522 |
+=head2 C<apply_filter EXPERIMENTAL> |
|
1491 | 1523 |
|
1492 | 1524 |
$dbi->apply_filter( |
1493 | 1525 |
'book', |
... | ... |
@@ -1555,7 +1587,7 @@ C<where> is where clause. this must be hash reference. |
1555 | 1587 |
C<append> is a string added at the end of the SQL statement. |
1556 | 1588 |
C<filter> is filters when parameter binding is executed. |
1557 | 1589 |
C<query> is if you don't execute sql and get L<DBIx::Custom::Query> object as return value. |
1558 |
-default to 0. This is experimental. |
|
1590 |
+default to 0. This is EXPERIMENTAL. |
|
1559 | 1591 |
Return value of C<delete()> is the count of affected rows. |
1560 | 1592 |
|
1561 | 1593 |
=head2 C<delete_all> |
... | ... |
@@ -1567,7 +1599,7 @@ Arguments is same as C<delete> method, |
1567 | 1599 |
except that C<delete_all> don't have C<where> argument. |
1568 | 1600 |
Return value of C<delete_all()> is the count of affected rows. |
1569 | 1601 |
|
1570 |
-=head3 C<(experimental) delete_at()> |
|
1602 |
+=head3 C<delete_at() EXPERIMENTAL> |
|
1571 | 1603 |
|
1572 | 1604 |
To delete row by using primary key, use C<delete_at()> |
1573 | 1605 |
|
... | ... |
@@ -1604,11 +1636,11 @@ C<param> is the pairs of column name value. this must be hash reference. |
1604 | 1636 |
C<append> is a string added at the end of the SQL statement. |
1605 | 1637 |
C<filter> is filters when parameter binding is executed. |
1606 | 1638 |
C<query> is if you don't execute sql and get L<DBIx::Custom::Query> object as return value. |
1607 |
-default to 0. This is experimental. |
|
1639 |
+default to 0. This is EXPERIMENTAL. |
|
1608 | 1640 |
This is overwrites C<default_bind_filter>. |
1609 | 1641 |
Return value of C<insert()> is the count of affected rows. |
1610 | 1642 |
|
1611 |
-=head3 C<(experimental) insert_at()> |
|
1643 |
+=head3 C<insert_at() EXPERIMENTAL> |
|
1612 | 1644 |
|
1613 | 1645 |
To insert row by using primary key, use C<insert_at()> |
1614 | 1646 |
|
... | ... |
@@ -1624,7 +1656,7 @@ NOTE that you must pass array reference as C<where>. |
1624 | 1656 |
If C<param> contains primary key, |
1625 | 1657 |
the key and value is delete from C<param>. |
1626 | 1658 |
|
1627 |
-=head2 C<(experimental) insert_param> |
|
1659 |
+=head2 C<insert_param EXPERIMENTAL> |
|
1628 | 1660 |
|
1629 | 1661 |
my $insert_param = $dbi->insert_param({title => 'a', age => 2}); |
1630 | 1662 |
|
... | ... |
@@ -1632,7 +1664,7 @@ Create insert parameter tag. |
1632 | 1664 |
|
1633 | 1665 |
{title => 'a', age => 2} -> {insert_param title age} |
1634 | 1666 |
|
1635 |
-=head2 C<(experimental) each_column> |
|
1667 |
+=head2 C<each_column EXPERIMENTAL> |
|
1636 | 1668 |
|
1637 | 1669 |
$dbi->each_column( |
1638 | 1670 |
sub { |
... | ... |
@@ -1651,7 +1683,7 @@ You can do anything in callback. |
1651 | 1683 |
Callback receive four arguments, dbi object, table name, |
1652 | 1684 |
column name and column information. |
1653 | 1685 |
|
1654 |
-=head2 C<(experimental) include_model> |
|
1686 |
+=head2 C<include_model EXPERIMENTAL> |
|
1655 | 1687 |
|
1656 | 1688 |
$dbi->include_model( |
1657 | 1689 |
'MyModel' => [ |
... | ... |
@@ -1694,7 +1726,7 @@ you can do like this. |
1694 | 1726 |
] |
1695 | 1727 |
); |
1696 | 1728 |
|
1697 |
-=head2 C<(experimental) method> |
|
1729 |
+=head2 C<method EXPERIMENTAL> |
|
1698 | 1730 |
|
1699 | 1731 |
$dbi->method( |
1700 | 1732 |
update_or_insert => sub { |
... | ... |
@@ -1719,7 +1751,7 @@ Register method. These method is called from L<DBIx::Custom> object directory. |
1719 | 1751 |
|
1720 | 1752 |
Create a new L<DBIx::Custom> object. |
1721 | 1753 |
|
1722 |
-=head2 C<(experimental) not_exists> |
|
1754 |
+=head2 C<not_exists EXPERIMENTAL> |
|
1723 | 1755 |
|
1724 | 1756 |
my $not_exists = $dbi->not_exists; |
1725 | 1757 |
|
... | ... |
@@ -1773,30 +1805,80 @@ Rollback transaction. |
1773 | 1805 |
This is same as L<DBI>'s C<rollback>. |
1774 | 1806 |
|
1775 | 1807 |
=head2 C<select> |
1776 |
- |
|
1808 |
+ |
|
1777 | 1809 |
my $result = $dbi->select( |
1778 |
- table => $table, |
|
1779 |
- column => [@column], |
|
1780 |
- where => \%where, |
|
1781 |
- append => $append, |
|
1782 |
- relation => \%relation, |
|
1783 |
- join => ['left outer join company on book.company_id = company.id'] |
|
1784 |
- filter => \%filter, |
|
1785 |
- query => 1, |
|
1786 |
- selection => $selection |
|
1810 |
+ table => 'book', |
|
1811 |
+ column => ['author', 'title'], |
|
1812 |
+ where => {author => 'Ken'}, |
|
1787 | 1813 |
); |
1788 |
- |
|
1814 |
+ |
|
1789 | 1815 |
Execute select statement. |
1790 |
-C<select> method have C<table>, C<column>, C<where>, C<append>, |
|
1791 |
-C<relation> and C<filter> arguments. |
|
1792 |
-C<table> is a table name. |
|
1793 |
-C<column> is column names. this is array reference or string. |
|
1816 |
+ |
|
1817 |
+The following opitons are currently available. |
|
1818 |
+ |
|
1819 |
+=over 4 |
|
1820 |
+ |
|
1821 |
+=item C<table> |
|
1822 |
+ |
|
1823 |
+Table name. |
|
1824 |
+ |
|
1825 |
+ $dbi->select(table => 'book', ...); |
|
1826 |
+ |
|
1827 |
+=item C<column> |
|
1828 |
+ |
|
1829 |
+Column clause. This is array reference or constant value. |
|
1830 |
+ |
|
1831 |
+ # Hash refernce |
|
1832 |
+ $dbi->select(column => ['author', 'title']); |
|
1833 |
+ |
|
1834 |
+ # Constant value |
|
1835 |
+ $dbi->select(column => 'author'); |
|
1836 |
+ |
|
1837 |
+Default is '*' unless C<column> is specified. |
|
1838 |
+ |
|
1839 |
+ # Default |
|
1840 |
+ $dbi->select(column => '*'); |
|
1841 |
+ |
|
1842 |
+=item C<all_column EXPERIMENTAL> |
|
1843 |
+ |
|
1844 |
+Colum clause, contains all columns. This is true or false value |
|
1845 |
+ |
|
1846 |
+ $dbi->select(all_column => 1, ...); |
|
1847 |
+ |
|
1848 |
+If main table is C<book> and joined table is C<company>, |
|
1849 |
+This create the following column clause. |
|
1850 |
+ |
|
1851 |
+ book.author as author |
|
1852 |
+ book.company_id as company_id |
|
1853 |
+ company.id as company__id |
|
1854 |
+ company.name as company__name |
|
1855 |
+ |
|
1856 |
+Columns of main table is consist of only column name, |
|
1857 |
+Columns of joined table is consist of table and column name joined C<__>. |
|
1858 |
+ |
|
1859 |
+=item C<where> |
|
1860 |
+ |
|
1861 |
+Where clause. This is hash reference or L<DBIx::Custom::Where> object. |
|
1862 |
+ |
|
1863 |
+ # Hash reference |
|
1864 |
+ $dbi->select(where => {author => 'Ken', 'title' => 'Perl'}, ...); |
|
1865 |
+ |
|
1866 |
+ # Where clause |
|
1867 |
+ my $where = $dbi->where( |
|
1868 |
+ clause => ['and', '{= author}', '{like title}'], |
|
1869 |
+ param => {author => 'Ken', title => '%Perl%'} |
|
1870 |
+ ); |
|
1871 |
+ $dbi->select(where => $where, ...); |
|
1872 |
+ |
|
1873 |
+=back |
|
1874 |
+ |
|
1875 |
+C<filter> arguments. |
|
1794 | 1876 |
C<where> is where clause. this is normally hash reference. |
1795 | 1877 |
C<append> is a string added at the end of the SQL statement. |
1796 | 1878 |
C<filter> is filters when parameter binding is executed. |
1797 | 1879 |
C<query> is if you don't execute sql and get L<DBIx::Custom::Query> object as return value. |
1798 |
-default to 0. This is experimental. |
|
1799 |
-C<selection> is string of column name and tables. This is experimental |
|
1880 |
+default to 0. This is EXPERIMENTAL. |
|
1881 |
+C<selection> is string of column name and tables. This is EXPERIMENTAL |
|
1800 | 1882 |
|
1801 | 1883 |
selection => 'name, location.name as location_name ' . |
1802 | 1884 |
'from company inner join location' |
... | ... |
@@ -1806,9 +1888,9 @@ such as "{= title} or {like author}". |
1806 | 1888 |
Second element is paramters. |
1807 | 1889 |
|
1808 | 1890 |
C<join> is join clause after from clause. |
1809 |
-This is experimental. |
|
1891 |
+This is EXPERIMENTAL. |
|
1810 | 1892 |
|
1811 |
-=head3 C<(experimental) select_at()> |
|
1893 |
+=head3 C<select_at() EXPERIMENTAL> |
|
1812 | 1894 |
|
1813 | 1895 |
To select row by using primary key, use C<select_at()>. |
1814 | 1896 |
|
... | ... |
@@ -1835,11 +1917,11 @@ C<where> is where clause. this must be hash reference. |
1835 | 1917 |
C<append> is a string added at the end of the SQL statement. |
1836 | 1918 |
C<filter> is filters when parameter binding is executed. |
1837 | 1919 |
C<query> is if you don't execute sql and get L<DBIx::Custom::Query> object as return value. |
1838 |
-default to 0. This is experimental. |
|
1920 |
+default to 0. This is EXPERIMENTAL. |
|
1839 | 1921 |
This is overwrites C<default_bind_filter>. |
1840 | 1922 |
Return value of C<update()> is the count of affected rows. |
1841 | 1923 |
|
1842 |
-=head2 C<(experimental) update_param> |
|
1924 |
+=head2 C<update_param EXPERIMENTAL> |
|
1843 | 1925 |
|
1844 | 1926 |
my $update_param = $dbi->update_param({title => 'a', age => 2}); |
1845 | 1927 |
|
... | ... |
@@ -1847,7 +1929,7 @@ Create update parameter tag. |
1847 | 1929 |
|
1848 | 1930 |
{title => 'a', age => 2} -> {update_param title age} |
1849 | 1931 |
|
1850 |
-=head2 C<(experimental) model> |
|
1932 |
+=head2 C<model EXPERIMENTAL> |
|
1851 | 1933 |
|
1852 | 1934 |
$dbi->model('book')->method( |
1853 | 1935 |
insert => sub { ... }, |
... | ... |
@@ -1858,7 +1940,7 @@ Create update parameter tag. |
1858 | 1940 |
|
1859 | 1941 |
Set and get a L<DBIx::Custom::Model> object, |
1860 | 1942 |
|
1861 |
-=head2 C<(experimental) setup_model> |
|
1943 |
+=head2 C<setup_model EXPERIMENTAL> |
|
1862 | 1944 |
|
1863 | 1945 |
$dbi->setup_model; |
1864 | 1946 |
|
... | ... |
@@ -1877,7 +1959,7 @@ Arguments is same as C<update> method, |
1877 | 1959 |
except that C<update_all> don't have C<where> argument. |
1878 | 1960 |
Return value of C<update_all()> is the count of affected rows. |
1879 | 1961 |
|
1880 |
-=head3 C<(experimental) update_at()> |
|
1962 |
+=head3 C<update_at() EXPERIMENTAL> |
|
1881 | 1963 |
|
1882 | 1964 |
To update row by using primary key, use C<update_at()> |
1883 | 1965 |
|
... | ... |
@@ -1893,7 +1975,7 @@ NOTE that you must pass array reference as C<where>. |
1893 | 1975 |
If C<param> contains primary key, |
1894 | 1976 |
the key and value is delete from C<param>. |
1895 | 1977 |
|
1896 |
-=head2 C<(experimental) where> |
|
1978 |
+=head2 C<where EXPERIMENTAL> |
|
1897 | 1979 |
|
1898 | 1980 |
my $where = $dbi->where( |
1899 | 1981 |
clause => ['and', '{= title}', '{= author}'], |
... | ... |
@@ -1913,7 +1995,7 @@ Method to set and get caches. |
1913 | 1995 |
|
1914 | 1996 |
The following tags is available. |
1915 | 1997 |
|
1916 |
-=head2 C<(experimental) table> |
|
1998 |
+=head2 C<table EXPERIMENTAL> |
|
1917 | 1999 |
|
1918 | 2000 |
Table tag |
1919 | 2001 |
|
... | ... |
@@ -1990,7 +2072,7 @@ Updata parameter tag. |
1990 | 2072 |
=head1 STABILITY |
1991 | 2073 |
|
1992 | 2074 |
L<DBIx::Custom> is stable. APIs keep backword compatible |
1993 |
-except experimental one in the feature. |
|
2075 |
+except EXPERIMENTAL one in the feature. |
|
1994 | 2076 |
|
1995 | 2077 |
=head1 BUGS |
1996 | 2078 |
|
... | ... |
@@ -6,9 +6,9 @@ DBIx::Custom::Guide - DBIx::Custom Guide |
6 | 6 |
|
7 | 7 |
=head1 GUIDE |
8 | 8 |
|
9 |
-(This module contain many experimental featrues. |
|
10 |
- in each pod of module, experimental marked method |
|
11 |
- is maybe changed without warnings) |
|
9 |
+(This guide will be completed nearly future and contains EXPERIMENTAL features |
|
10 |
+The features marked EXPERIMENTAL in POD of L<DBIx::Custom> is |
|
11 |
+EXPERIMENTAL ones) |
|
12 | 12 |
|
13 | 13 |
L<DBIx::Custom> is the class to make easy to execute SQL. |
14 | 14 |
This is L<DBI> wrapper class like L<DBIx::Class> or L<DBIx::Simple>. |
... | ... |
@@ -6,9 +6,9 @@ DBIx::Custom::Guide::Ja - DBIx::Customのガイドブック |
6 | 6 |
|
7 | 7 |
=head1 ガイド |
8 | 8 |
|
9 |
-(このモジュールはまだ実験的な機能を多く含んでいます |
|
10 |
-モジュールのドキュメントにexperimentalがついているものは、 |
|
11 |
-予告なしに変更されることがあります。) |
|
9 |
+(このガイドは将来的なもので実験的な機能についても記述されています。 |
|
10 |
+L<DBIx::Custom>のPODにEXPERIMENTALとマークされている |
|
11 |
+ものは実験的な機能です。) |
|
12 | 12 |
|
13 | 13 |
L<DBIx::Custom>はSQLの実行を簡単に行うためのクラスです。 |
14 | 14 |
L<DBIx::Class>やL<DBIx::Simple>と同じように |
... | ... |
@@ -1786,7 +1786,7 @@ $rows = $dbi->select( |
1786 | 1786 |
is_deeply($rows, [{table1__key1 => 1}]); |
1787 | 1787 |
|
1788 | 1788 |
|
1789 |
-test 'column_clause'; |
|
1789 |
+test 'model join and column attribute and all_column option'; |
|
1790 | 1790 |
{ |
1791 | 1791 |
package MyDBI8; |
1792 | 1792 |
|
... | ... |
@@ -1810,3 +1810,8 @@ $model = $dbi->model('table1'); |
1810 | 1810 |
$result = $model->select_at(where => 1); |
1811 | 1811 |
is_deeply($result->fetch_hash_first, |
1812 | 1812 |
{key1 => 1, key2 => 2, table2__key1 => 1, table2__key3 => 3}); |
1813 |
+$model->column(undef); |
|
1814 |
+$result = $model->select(all_column => 1); |
|
1815 |
+is_deeply($result->fetch_hash_first, |
|
1816 |
+ {key1 => 1, key2 => 2, table2__key1 => 1, table2__key3 => 3}); |
|
1817 |
+ |