-ident implementation
[dbsrgits/DBIx-Class.git] / t / sqlmaker / op_ident.t
diff --git a/t/sqlmaker/op_ident.t b/t/sqlmaker/op_ident.t
new file mode 100644 (file)
index 0000000..46668a6
--- /dev/null
@@ -0,0 +1,41 @@
+use strict;
+use warnings;
+
+use Test::More;
+
+use lib qw(t/lib);
+use DBIC::SqlMakerTest;
+
+use_ok('DBICTest');
+
+my $schema = DBICTest->init_schema();
+
+my $sql_maker = $schema->storage->sql_maker;
+
+for my $q ('', '"') {
+
+  $sql_maker->quote_char($q);
+
+  is_same_sql_bind (
+    \[ $sql_maker->select ('artist', '*', { 'artist.name' => { -ident => 'artist.pseudonym' } } ) ],
+    "SELECT *
+      FROM ${q}artist${q}
+      WHERE ${q}artist${q}.${q}name${q} = ${q}artist${q}.${q}pseudonym${q}
+    ",
+    [],
+  );
+
+  is_same_sql_bind (
+    \[ $sql_maker->update ('artist',
+      { 'artist.name' => { -ident => 'artist.pseudonym' } },
+      { 'artist.name' => { '!=' => { -ident => 'artist.pseudonym' } } },
+    ) ],
+    "UPDATE ${q}artist${q}
+      SET ${q}artist${q}.${q}name${q} = ${q}artist${q}.${q}pseudonym${q}
+      WHERE ${q}artist${q}.${q}name${q} != ${q}artist${q}.${q}pseudonym${q}
+    ",
+    [],
+  );
+}
+
+done_testing;