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
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)
-use Test::More tests => 12;
+use Test::More tests => 16;
use Test::Exception;
use lib qw(t/lib);
} '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");