Showing 4 changed files with 35 additions and 72 deletions
+9 -7
t/common-sqlite-quote.t
... ...
@@ -10,14 +10,16 @@ use DBIx::Custom;
10 10
     no warnings 'redefine';
11 11
     has dsn => 'dbi:SQLite:dbname=:memory:';
12 12
     sub quote { '""' }
13
-    sub create_table1 { 'create table table1 (key1, key2);' }
14
-    sub create_table1_2 {'create table table1 (key1, key2, key3, key4, key5);' }
13
+    sub create_table1 { 'create table table1 (key1 varchar, key2 varchar);' }
14
+    sub create_table1_2 {'create table table1 (key1 varchar, key2 varchar, key3 varchar, key4 varchar, key5 varchar);' }
15 15
     sub create_table1_type { 'create table table1 (key1 Date, key2 datetime);' }
16
-    sub create_table1_highperformance { "create table table1 (ab, bc, ik, hi, ui, pq, dc);" }
17
-    sub create_table2 { 'create table table2 (key1, key3);' }
18
-    sub create_table2_2 { "create table table2 (key1, key2, key3)" }
19
-    sub create_table3 { "create table table3 (key1, key2, key3)" }
20
-    sub create_table_reserved { 'create table "table" ("select", "update")' }
16
+    
17
+    sub create_table1_highperformance { "create table table1 (ab varchar, bc varchar, ik varchar, hi varchar, ui varchar, pq varchar, dc varchar);" }
18
+    
19
+    sub create_table2 { 'create table table2 (key1 varchar, key3 varchar);' }
20
+    sub create_table2_2 { "create table table2 (key1 varchar, key2 varchar, key3 varchar)" }
21
+    sub create_table3 { "create table table3 (key1 varchar, key2 varchar, key3 varchar)" }
22
+    sub create_table_reserved { 'create table "table" ("select" varchar, "update" varchar)' }
21 23
 }
22 24
 
23 25
 require "$FindBin::Bin/common.t";
+7 -7
t/common-sqlite.t
... ...
@@ -9,16 +9,16 @@ use DBIx::Custom;
9 9
     package DBIx::Custom;
10 10
     no warnings 'redefine';
11 11
     has dsn => 'dbi:SQLite:dbname=:memory:';
12
-    sub create_table1 { 'create table table1 (key1, key2);' }
13
-    sub create_table1_2 {'create table table1 (key1, key2, key3, key4, key5);' }
12
+    sub create_table1 { 'create table table1 (key1 varchar, key2 varchar);' }
13
+    sub create_table1_2 {'create table table1 (key1 varchar, key2 varchar, key3 varchar, key4 varchar, key5 varchar);' }
14 14
     sub create_table1_type { 'create table table1 (key1 Date, key2 datetime);' }
15 15
     
16
-    sub create_table1_highperformance { "create table table1 (ab, bc, ik, hi, ui, pq, dc);" }
16
+    sub create_table1_highperformance { "create table table1 (ab varchar, bc varchar, ik varchar, hi varchar, ui varchar, pq varchar, dc varchar);" }
17 17
     
18
-    sub create_table2 { 'create table table2 (key1, key3);' }
19
-    sub create_table2_2 { "create table table2 (key1, key2, key3)" }
20
-    sub create_table3 { "create table table3 (key1, key2, key3)" }
21
-    sub create_table_reserved { 'create table "table" ("select", "update")' }
18
+    sub create_table2 { 'create table table2 (key1 varchar, key3 varchar);' }
19
+    sub create_table2_2 { "create table table2 (key1 varchar, key2 varchar, key3 varchar)" }
20
+    sub create_table3 { "create table table3 (key1 varchar, key2 varchar, key3 varchar)" }
21
+    sub create_table_reserved { 'create table "table" ("select" varchar, "update" varchar)' }
22 22
 }
23 23
 
24 24
 require "$FindBin::Bin/common.t";
+13
t/common.t
... ...
@@ -2993,4 +2993,17 @@ $source = "a {= {}";
2993 2993
 eval{$builder->build_query($source)};
2994 2994
 like($@, qr/unexpected "{"/, "error : 2");
2995 2995
 
2996
+test 'select() wrap option';
2997
+$dbi = DBIx::Custom->connect;
2998
+eval { $dbi->execute('drop table table1') };
2999
+$dbi->execute($create_table1);
3000
+$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
3001
+$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
3002
+$rows = $dbi->select(
3003
+    table => 'table1',
3004
+    column => 'key1',
3005
+    wrap => ['select * from (', ') as t where key1 = 1']
3006
+)->all;
3007
+is_deeply($rows, [{key1 => 1}]);
3008
+
2996 3009
 1;
+6 -58
t/sqlite.t
... ...
@@ -151,12 +151,12 @@ use MyDBI1;
151 151
 }
152 152
 
153 153
 # Constant
154
-my $create_table1 = 'create table table1 (key1 char(255), key2 char(255));';
155
-my $create_table1_2 = 'create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));';
156
-my $create_table2 = 'create table table2 (key1 char(255), key3 char(255));';
157
-my $create_table2_2 = "create table table2 (key1, key2, key3)";
158
-my $create_table3 = "create table table3 (key1, key2, key3)";
159
-my $create_table_reserved = 'create table "table" ("select", "update")';
154
+my $create_table1 = 'create table table1 (key1 varchar, key2 varchar);';
155
+my $create_table1_2 = 'create table table1 (key1 varchar, key2 varchar, key3 varchar, key4 varchar, key5 varchar);';
156
+my $create_table2 = 'create table table2 (key1 varchar, key3 varchar);';
157
+my $create_table2_2 = "create table table2 (key1 varchar, key2 varchar, key3 varchar)";
158
+my $create_table3 = "create table table3 (key1 varchar, key2 varchar, key3 varchar)";
159
+my $create_table_reserved = 'create table "table" ("select" varchar, "update" varchar)';
160 160
 
161 161
 my $q = '"';
162 162
 my $p = '"';
... ...
@@ -196,40 +196,6 @@ my $binary;
196 196
 # Prepare table
197 197
 $dbi = DBIx::Custom->connect;
198 198
 
199
-
200
-
201
-
202
-
203
-
204
-
205
-
206
-
207
-
208
-
209
-
210
-
211
-
212
-
213
-
214
-
215
-
216
-
217
-
218
-
219
-
220
-
221
-
222
-
223
-
224
-
225
-
226
-
227
-
228
-
229
-
230
-
231
-
232
-
233 199
 ### a little complex test
234 200
 test 'table_alias';
235 201
 $dbi = DBIx::Custom->connect;
... ...
@@ -1187,24 +1153,6 @@ $result = $dbi->select(table => 'table1');
1187 1153
 eval {$result->fetch_hash_multi};
1188 1154
 like($@, qr/Row count must be specified/, "Not specified row count");
1189 1155
 
1190
-
1191
-
1192
-
1193
-
1194
-
1195
-
1196
-
1197
-
1198
-
1199
-
1200
-
1201
-
1202
-
1203
-
1204
-
1205
-
1206
-
1207
-
1208 1156
 # DEPRECATED! test
1209 1157
 test 'filter __ expression';
1210 1158
 $dbi = DBIx::Custom->connect;