[DBIx-Class-Devel] [dbsrgits/sql-translator] PostgreSQL parser does not allow indexes on expressions with more than one argument (#83)
Matthew Musgrove
notifications at github.com
Thu Dec 8 22:50:27 GMT 2016
You cannot add an index on an expression (aka a functional index) using a function that more than one argument like shown in the following test addition:
git diff t/47postgres-producer.t
diff --git a/t/47postgres-producer.t b/t/47postgres-producer.t
index 9c50db7..c2db844 100644
--- a/t/47postgres-producer.t
+++ b/t/47postgres-producer.t
@@ -686,6 +686,14 @@ is($view2_sql1, $view2_sql_replace, 'correct "CREATE OR REPLACE VIEW" SQL 2');
($def) = SQL::Translator::Producer::PostgreSQL::create_index($index, $quote);
is($def, 'CREATE INDEX "myindex" on "foobar" USING hash ("bar", lower(foo)) WHERE upper(foo) = \'bar\' AND bar = \'foo\'', 'index using & where created w/ quotes');
}
+
+ {
+ my $index = $table->add_index(name => 'myindex', fields => ['coalesce(foo, 0)']);
+ my ($def) = SQL::Translator::Producer::PostgreSQL::create_index($index);
+ is($def, "CREATE INDEX myindex on foobar (coalesce(foo, 0))", 'index created');
+ ($def) = SQL::Translator::Producer::PostgreSQL::create_index($index, $quote);
+ is($def, 'CREATE INDEX "myindex" on "foobar" (coalesce(foo, 0))', 'index created w/ quotes');
+ }
}
my $drop_view_opts1 = { add_drop_view => 1, no_comments => 1, postgres_version => 8.001 };
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/dbsrgits/sql-translator/issues/83
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scsys.co.uk/pipermail/dbix-class-devel/attachments/20161208/6435f328/attachment.htm>
More information about the DBIx-Class-Devel
mailing list