Migrate -ident and -value from dbic, reorganize docs
[dbsrgits/SQL-Abstract.git] / t / 22op_value.t
diff --git a/t/22op_value.t b/t/22op_value.t
new file mode 100644 (file)
index 0000000..00cb5c5
--- /dev/null
@@ -0,0 +1,45 @@
+use strict;
+use warnings;
+
+use Test::More;
+use SQL::Abstract;
+use SQL::Abstract::Test import => [qw/is_same_sql_bind/];
+
+for my $q ('', '"') {
+for my $col_btype (0,1) {
+
+  my $sql_maker = SQL::Abstract->new(
+    quote_char => $q,
+    name_sep => $q ? '.' : '',
+    $col_btype ? (bindtype => 'columns') : (),
+  );
+
+  my ($sql, @bind) = $sql_maker->select ('artist', '*', { arr1 => { -value => [1,2] }, arr2 => { '>', { -value => [3,4] } }, field => [5,6] } );
+
+  is_same_sql_bind (
+    $sql,
+    \@bind,
+    "SELECT *
+      FROM ${q}artist${q}
+      WHERE ${q}arr1${q} = ? AND
+            ${q}arr2${q} > ? AND
+            ( ${q}field${q} = ? OR ${q}field${q} = ? )
+    ",
+    [
+      $col_btype
+        ? (
+          [ arr1 => [ 1, 2 ] ],
+          [ arr2 => [ 3, 4 ] ],
+          [ field => 5 ],
+          [ field => 6 ],
+        ) : (
+          [ 1, 2 ],
+          [ 3, 4 ],
+          5,
+          6,
+        )
+    ],
+  );
+}}
+
+done_testing;