Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[Squerl] format an insert statement with array

  • Loading branch information...
commit 4aa69881afae3de8c8cbf6669106d524bbc6290d 1 parent 9f3de5f
@masak authored
Showing with 11 additions and 0 deletions.
  1. +5 −0 lib/Squerl.pm
  2. +6 −0 t/squerl/02-dataset.t
View
5 lib/Squerl.pm
@@ -62,6 +62,7 @@ class Squerl::Dataset does Positional {
$value //= %_.pairs[0];
given $value {
when Int { return literal_integer($value) }
+ when Num { return literal_number($value) }
when Str { return literal_string($value) }
when Pair { return self.literal_symbol($value.key) }
}
@@ -153,6 +154,10 @@ class Squerl::Dataset does Positional {
~$value
}
+ sub literal_number($value) {
+ ~$value
+ }
+
sub literal_string($value) {
"'{$value.subst('\\', '\\\\', :g).subst("'", "''", :g)}'"
}
View
6 t/squerl/02-dataset.t
@@ -240,4 +240,10 @@ role R2 { method values { {} } }
'format an insert statement with sub-query';
}
+{
+ is $dataset.insert_sql('a', 2, 6.5),
+ q[INSERT INTO test VALUES ('a', 2, 6.5)],
+ 'format an insert statement with array';
+}
+
done_testing;
Please sign in to comment.
Something went wrong with that request. Please try again.