[Bast-commits] r6648 - in DBIx-Class/0.08/branches/run_file_against_storage: lib/DBIx/Class/Storage t

jnapiorkowski at dev.catalyst.perl.org jnapiorkowski at dev.catalyst.perl.org
Fri Jun 12 14:40:31 GMT 2009


Author: jnapiorkowski
Date: 2009-06-12 14:40:31 +0000 (Fri, 12 Jun 2009)
New Revision: 6648

Modified:
   DBIx-Class/0.08/branches/run_file_against_storage/lib/DBIx/Class/Storage/DBI.pm
   DBIx-Class/0.08/branches/run_file_against_storage/t/105-run-file-against-storage.t
Log:
more test cases for splitting lines

Modified: DBIx-Class/0.08/branches/run_file_against_storage/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- DBIx-Class/0.08/branches/run_file_against_storage/lib/DBIx/Class/Storage/DBI.pm	2009-06-12 14:27:38 UTC (rev 6647)
+++ DBIx-Class/0.08/branches/run_file_against_storage/lib/DBIx/Class/Storage/DBI.pm	2009-06-12 14:40:31 UTC (rev 6648)
@@ -2097,16 +2097,7 @@
 Given a string, returns all the individual SQL statements in that String
 as an Array.
 
-my $maybe_quoted = qr/
-"[^"]+"
-|
-'[^']+'
-|
-.+?(?=$deliminator)
-/;
 
-my @parts = ($line=~m/$maybe_quoted*?$deliminator/g);
-
 =cut
 
 sub _split_line_into_statements {
@@ -2121,6 +2112,21 @@
   return @parts;
 }
 
+sub _split_line_into_statements_new {
+  my ($self, $line) = @_;
+  my $deliminator=qr{;|$};
+  my $maybe_quoted = qr/
+    "[^"]+"
+    |
+    '[^']+'
+    |
+    .+?(?=$deliminator)
+  /;
+
+  return ($line=~m/$maybe_quoted*?$deliminator/g);
+}
+
+
 =head2 _normalize_statements_from_lines 
 
   my @statements = $storage->_normalize_statements_from_lines(@lines)

Modified: DBIx-Class/0.08/branches/run_file_against_storage/t/105-run-file-against-storage.t
===================================================================
--- DBIx-Class/0.08/branches/run_file_against_storage/t/105-run-file-against-storage.t	2009-06-12 14:27:38 UTC (rev 6647)
+++ DBIx-Class/0.08/branches/run_file_against_storage/t/105-run-file-against-storage.t	2009-06-12 14:40:31 UTC (rev 6648)
@@ -1,5 +1,5 @@
 
-use Test::More tests => 12; 
+use Test::More tests => 16; 
 use Test::Exception;
 use lib qw(t/lib);
 
@@ -122,4 +122,21 @@
 } 'executed statement';
 
 ok $schema->storage->run_file_against_storage(qw/t share simple.sql/), 'executed the simple';
-ok $schema->storage->run_file_against_storage(qw/t share killer.sql/), 'executed the killer';
\ No newline at end of file
+ok $schema->storage->run_file_against_storage(qw/t share killer.sql/), 'executed the killer';
+
+my $storage = $schema->storage;
+
+is_deeply [$storage->_split_line_into_statements("aaa;bbb;ccc")],["aaa;", "bbb;", "ccc", ""],
+ "Correctly split";
+
+is_deeply [$storage->_split_line_into_statements("aaa;'bb1;bb2';ccc")],["aaa;", "'bb1;bb2';", "ccc", ""],
+ "Correctly split";
+
+is_deeply [$storage->_split_line_into_statements(qq[aaa;"bb1;bb2";ccc])],["aaa;", '"bb1;bb2";', "ccc", ""],
+ "Correctly split";
+
+is_deeply [$storage->_split_line_into_statements("aaa;bbb;ccc;")],["aaa;", "bbb;", "ccc;", ""],
+ "Correctly split";
+
+use Data::Dump qw/dump/;
+warn dump $schema->storage->_split_line_into_statements_new("aaa;bbb;ccc");




More information about the Bast-commits mailing list