Showing 8 changed files with 72 additions and 41 deletions
+2
Changes
... ...
@@ -1,3 +1,5 @@
1
+0.27 (2012-09-17)
2
+  - fixed documentation miss about execute method's table_alias option.
1 3
 0.26
2 4
   - fixed bug that when id option's value is object, don't work.
3 5
 0.25
+28 -29
lib/DBIx/Custom.pm
... ...
@@ -2,7 +2,7 @@ use 5.008007;
2 2
 package DBIx::Custom;
3 3
 use Object::Simple -base;
4 4
 
5
-our $VERSION = '0.26';
5
+our $VERSION = '0.27';
6 6
 
7 7
 use Carp 'croak';
8 8
 use DBI;
... ...
@@ -2185,33 +2185,38 @@ DBIx::Custom - DBI extension to execute insert, update, delete, and select easil
2185 2185
   $dbi->delete(table  => 'book', where => {author => 'Ken'});
2186 2186
 
2187 2187
   # Select
2188
-  my $result = $dbi->select(table  => 'book',
2189
-    column => ['title', 'author'], where  => {author => 'Ken'});
2188
+  #   select title, author from book where author = ?
2189
+  my $result = $dbi->select(
2190
+    ['title', 'author'],
2191
+    table  => 'book',
2192
+    where  => {author => 'Ken'}
2193
+  );
2190 2194
 
2191 2195
   # Select, more complex
2196
+  #   select book.title as book.title,
2197
+  #     book.author as book.author,
2198
+  #     comnapy.name as company.name
2199
+  #   form book
2200
+  #     left outer join company on book.company_id = company.id
2201
+  #   where book.author = ?
2202
+  #   order by id limit 0, 5
2192 2203
   my $result = $dbi->select(
2193
-    table  => 'book',
2194
-    column => [
2204
+    [
2195 2205
       {book => [qw/title author/]},
2196 2206
       {company => ['name']}
2197 2207
     ],
2208
+    table  => 'book',
2198 2209
     where  => {'book.author' => 'Ken'},
2199 2210
     join => ['left outer join company on book.company_id = company.id'],
2200
-    append => 'order by id limit 5'
2211
+    append => 'order by id limit 0, 5'
2201 2212
   );
2202 2213
   
2203
-  # Fetch
2204
-  while (my $row = $result->fetch) {
2205
-      
2206
-  }
2207
-  
2208
-  # Fetch as hash
2209
-  while (my $row = $result->fetch_hash) {
2210
-      
2211
-  }
2214
+  # Get all rows or only one row
2215
+  my $rows = $result->all;
2216
+  my $row = $result->one;
2212 2217
   
2213
-  # Execute SQL with parameter.
2214
-  $dbi->execute(
2218
+  # Execute SQL.
2219
+  my $result = $dbi->execute(
2215 2220
     "select id from book where author = :author and title like :title",
2216 2221
     {author => 'ken', title => '%Perl%'}
2217 2222
   );
... ...
@@ -2259,19 +2264,13 @@ Create C<order by> clause flexibly
2259 2264
 
2260 2265
 =back
2261 2266
 
2262
-=head1 DOCUMENTATION
2267
+=head1 DOCUMENTS
2263 2268
 
2264
-L<DBIx::Custom::Guide> - How to use L<DBIx::Custom>
2269
+L<DBIx::Custom Documents|https://github.com/yuki-kimoto/DBIx-Custom/wiki/DBIx::Custom-Documents>
2265 2270
 
2266
-L<DBIx::Custom Wiki|https://github.com/yuki-kimoto/DBIx-Custom/wiki>
2267
-- Theare are various examples.
2271
+L<DBIx::Custom API reference|http://search.cpan.org/~kimoto/DBIx-Custom/>
2268 2272
 
2269
-Module documentations - 
2270
-L<DBIx::Custom::Result>,
2271
-L<DBIx::Custom::Query>,
2272
-L<DBIx::Custom::Where>,
2273
-L<DBIx::Custom::Model>,
2274
-L<DBIx::Custom::Order>
2273
+L<DBIx::Custom Examples|Wiki|https://github.com/yuki-kimoto/DBIx-Custom/wiki>
2275 2274
 
2276 2275
 =head1 ATTRIBUTES
2277 2276
 
... ...
@@ -2939,9 +2938,9 @@ You must set C<table> option.
2939 2938
 
2940 2939
 =item C<table_alias>
2941 2940
 
2942
-  table_alias => {user => 'worker'}
2941
+  table_alias => {worker => 'user'} # {ALIAS => TABLE}
2943 2942
 
2944
-Table alias. Key is real table name, value is alias table name.
2943
+Table alias. Key is alias table name, value is real table name, .
2945 2944
 If you set C<table_alias>, you can enable C<into1> and C<into2> type rule
2946 2945
 on alias table name.
2947 2946
 
-9
lib/DBIx/Custom/Guide.pod
... ...
@@ -1,9 +0,0 @@
1
-=head1 NAME
2
-
3
-DBIx::Custom::Guide - DBIx::Custom Guide
4
-
5
-=head1 LINK
6
-
7
-Guide is moved to the following page.
8
-
9
-L<https://github.com/yuki-kimoto/DBIx-Custom/wiki/DBIx%3A%3ACustom-Guide>
+1 -1
lib/DBIx/Custom/Model.pm
... ...
@@ -171,7 +171,7 @@ sub method {
171 171
 
172 172
 =head1 NAME
173 173
 
174
-DBIx::Custom::Model - Model
174
+DBIx::Custom::Model - Model object
175 175
 
176 176
 =head1 SYNOPSIS
177 177
 
+1 -1
lib/DBIx/Custom/NotExists.pm
... ...
@@ -9,7 +9,7 @@ sub singleton { $not_exists }
9 9
 
10 10
 =head1 NAME
11 11
 
12
-DBIx::Custom::NotExists
12
+DBIx::Custom::NotExists - Not exsits object
13 13
 
14 14
 =head1 SYNOPSYS
15 15
 
+1 -1
lib/DBIx/Custom/Order.pm
... ...
@@ -51,7 +51,7 @@ sub to_string {
51 51
 
52 52
 =head1 NAME
53 53
 
54
-DBIx::Custom::Order - Order by
54
+DBIx::Custom::Order - Order by clause
55 55
 
56 56
 =head1 SYNOPSIS
57 57
 
+4
t/_run/common-oracle.run
... ...
@@ -55,4 +55,8 @@ XE =
55 55
     )
56 56
   )
57 57
 
58
+If "the password will expire within 7 days" is displayed on test,
59
+please change password
60
+
61
+  PASSWORD
58 62
 
+35
t/common.t
... ...
@@ -4989,4 +4989,39 @@ $model->insert({$key1 => 1, $key3 => 3});
4989 4989
 is($model->count(id => 1), 1);
4990 4990
 is($model->count(where => {"$table2.$key3" => 3}), 1);
4991 4991
 
4992
+test 'table_alias option';
4993
+$dbi = DBIx::Custom->connect;
4994
+eval { $dbi->execute("drop table $table1") };
4995
+$dbi->execute($create_table1_type);
4996
+$dbi->insert({$key1 => '2010-01-01'}, table => $table1);
4997
+$dbi->user_column_info($user_column_info);
4998
+$dbi->type_rule(
4999
+  into1 => {
5000
+    $date_typename => sub { '2010-' . $_[0] }
5001
+  }
5002
+);
5003
+$result = $dbi->execute(
5004
+  "select * from $table1 TABLE1_ALIAS where :TABLE1_ALIAS.${key1}{=}",
5005
+  {"TABLE1_ALIAS.${key1}" => '01-01'},
5006
+  table_alias => {TABLE1_ALIAS => $table1}
5007
+);
5008
+like($result->one->{$key1}, qr/^2010-01-01/);
5009
+
5010
+$dbi = DBIx::Custom->connect;
5011
+eval { $dbi->execute("drop table $table1") };
5012
+$dbi->execute($create_table1_type);
5013
+$dbi->insert({$key1 => '2010-01-01'}, table => $table1);
5014
+$dbi->user_column_info($user_column_info);
5015
+$dbi->type_rule(
5016
+  into2 => {
5017
+    $date_typename => sub { '2010-' . $_[0] }
5018
+  }
5019
+);
5020
+$result = $dbi->execute(
5021
+  "select * from $table1 TABLE1_ALIAS where :TABLE1_ALIAS.${key1}{=}",
5022
+  {"TABLE1_ALIAS.${key1}" => '01-01'},
5023
+  table_alias => {TABLE1_ALIAS => $table1}
5024
+);
5025
+like($result->one->{$key1}, qr/^2010-01-01/);
5026
+
4992 5027
 1;