... | ... |
@@ -196,6 +196,7 @@ sub query_raw_sql { |
196 | 196 |
my ($self, $sql, @bind) = @_; |
197 | 197 |
|
198 | 198 |
$self->connect unless $self->connected; |
199 |
+ $sql .= ';' unless $sql =~ /;$/; |
|
199 | 200 |
my $sth = $self->dbh->prepare($sql); |
200 | 201 |
$sth->execute(@bind); |
201 | 202 |
return $sth; |
... | ... |
@@ -5,10 +5,6 @@ use warnings; |
5 | 5 |
use DBI::Custom; |
6 | 6 |
use Scalar::Util qw/blessed/; |
7 | 7 |
|
8 |
-# user password database |
|
9 |
-our ($U, $P, $D) = connect_info(); |
|
10 |
- |
|
11 |
- |
|
12 | 8 |
{ |
13 | 9 |
my $dbi = DBI::Custom->new( |
14 | 10 |
connect_info => { |
... | ... |
@@ -159,19 +155,6 @@ our ($U, $P, $D) = connect_info(); |
159 | 155 |
isa_ok($dbi, 'DBI::Custom'); |
160 | 156 |
} |
161 | 157 |
|
162 |
-{ |
|
163 |
- my $dbi = DBI::Custom->new( |
|
164 |
- connect_info => { |
|
165 |
- user => $U, |
|
166 |
- password => $P, |
|
167 |
- data_source => "dbi:mysql:$D" |
|
168 |
- } |
|
169 |
- ); |
|
170 |
- $dbi->connect; |
|
171 |
- |
|
172 |
- ok(blessed $dbi->dbh); |
|
173 |
- can_ok($dbi->dbh, qw/prepare/); |
|
174 |
-} |
|
175 | 158 |
|
176 | 159 |
{ |
177 | 160 |
my $dbi = DBI::Custom->new( |
... | ... |
@@ -264,40 +247,3 @@ our ($U, $P, $D) = connect_info(); |
264 | 247 |
is_deeply(\@bind, ['A', 'b'], 'sql template bind' ); |
265 | 248 |
} |
266 | 249 |
|
267 |
-{ |
|
268 |
- my $dbi = DBI::Custom->new( |
|
269 |
- connect_info => { |
|
270 |
- user => $U, |
|
271 |
- password => $P, |
|
272 |
- data_source => "dbi:mysql:$D" |
|
273 |
- } |
|
274 |
- ); |
|
275 |
- |
|
276 |
- $dbi->fetch_filter(sub { |
|
277 |
- my ($key, $value) = @_; |
|
278 |
- if ($key eq 'key1' && $value == 1 ) { |
|
279 |
- return $value * 3; |
|
280 |
- } |
|
281 |
- return $value; |
|
282 |
- }); |
|
283 |
- |
|
284 |
- my $result = $dbi->query("select key1, key2 from test1"); |
|
285 |
- |
|
286 |
- my $row = $result->fetchrow_arrayref; |
|
287 |
- my @values = @$row; |
|
288 |
- $result->finish; |
|
289 |
- |
|
290 |
- is_deeply(\@values, [3, 2]); |
|
291 |
-} |
|
292 |
- |
|
293 |
-sub connect_info { |
|
294 |
- my $file = 'password.tmp'; |
|
295 |
- open my $fh, '<', $file |
|
296 |
- or return; |
|
297 |
- |
|
298 |
- my ($user, $password, $database) = split(/\s/, (<$fh>)[0]); |
|
299 |
- |
|
300 |
- close $fh; |
|
301 |
- |
|
302 |
- return ($user, $password, $database); |
|
303 |
-} |