Showing 5 changed files with 21 additions and 0 deletions
+1
Changes
... ...
@@ -1,4 +1,5 @@
1 1
 0.1648
2
+  add DBIx::Custom::Model columns attirbute
2 3
   add DBIx::Custom::Model foreign_key() attribute 
3 4
   add models() attribute
4 5
 0.1647
+4
lib/DBIx/Custom/Guide.pod
... ...
@@ -1042,6 +1042,10 @@ You can set primary key to model.
1042 1042
 Primary key is used by C<update_at()>, C<delete_at()>,
1043 1043
 C<select_at()>.
1044 1044
 
1045
+You can set column names
1046
+
1047
+    $model->columns(['id', 'number_id']);
1048
+
1045 1049
 =head2 Model Examples
1046 1050
 
1047 1051
 Model examples
+4
lib/DBIx/Custom/Guide/Ja.pod
... ...
@@ -1070,6 +1070,10 @@ L<DBIx::Custom>とL<DBI>のすべてのメソッドを呼び出すこともで
1070 1070
 ここで設定したプライマリーキーはC<update_at()>, C<delete_at()>,
1071 1071
 C<select_at()>で利用されます。
1072 1072
 
1073
+モデルには列名を設定することもできます。
1074
+
1075
+    $model->columns(['id', 'number_id']);
1076
+
1073 1077
 =head2 モデルのサンプル
1074 1078
 
1075 1079
 モデルのサンプルです。
+6
lib/DBIx/Custom/Model.pm
... ...
@@ -12,6 +12,7 @@ push @DBIx::Custom::CARP_NOT, __PACKAGE__;
12 12
 
13 13
 __PACKAGE__->attr(
14 14
     ['dbi', 'table'],
15
+    columns => sub { [] },
15 16
     primary_key => sub { [] }
16 17
 );
17 18
 
... ...
@@ -82,6 +83,11 @@ my $table = DBIx::Custom::Model->new(table => 'books');
82 83
 
83 84
 =head1 ATTRIBUTES
84 85
 
86
+=head2 C<(experimental) columns>
87
+
88
+    my $columns = $model->columns;
89
+    $model      = $model->columns(['id', 'number']);
90
+
85 91
 =head2 C<dbi>
86 92
 
87 93
     my $dbi = $model->dbi;
+6
t/dbix-custom-core-sqlite.t
... ...
@@ -1378,4 +1378,10 @@ $model = $dbi->model('book');
1378 1378
 $model->primary_key(['id', 'number']);
1379 1379
 is_deeply($model->primary_key, ['id', 'number']);
1380 1380
 
1381
+test 'columns';
1382
+use MyDBI1;
1383
+$dbi = MyDBI1->connect($NEW_ARGS->{0});
1384
+$model = $dbi->model('book');
1385
+$model->columns(['id', 'number']);
1386
+is_deeply($model->columns, ['id', 'number']);
1381 1387