I am trying to implement a uniqueness constraint over a set of columns that
can include a null values, using the technique described in this
stackoverflow answer <http://stackoverflow.com/a/8289327/452769>:
Sequel.migration do
change do
create_table :test_table do
primary_key :id
String :user_id
String :menu_id
String :recipe_id
unique [:user_id, Sequel.function(:coalesce, :menu_id, "000-000"),
:recipe_id]
end
end
When I run this it executes the following sql:
CREATE TABLE "test_table" ("id" serial PRIMARY KEY, "user_id" text,
"menu_id" text, "recipe_id" text, UNIQUE ("user_id", coalesce("menu_id",
'000-000'), "recipe_id"))
and gives the following error:
Sequel::DatabaseError: PG::SyntaxError: ERROR: syntax error at or near "("
LINE 1: ...ext, "recipe_id" text, UNIQUE ("user_id", coalesce("menu_id"...
Is there something obvious I'm doing wrong here?
Versions:
$ postgres --version
postgres (PostgreSQL) 9.3.1
$ cat Gemfile.lock | grep sequel
sequel (4.31.0)
sequel-json (0.0.1)
sequel
sequel-paranoid (0.6.2)
sequel
sequel-rails (0.9.11)
sequel (>= 3.28, < 5.0)
sequel-revisions (0.2.4)
sequel (~> 4)
sequel-json (~> 0)
sequel_polymorphic
sequel_pg (1.6.13)
sequel (>= 3.39.0)
sequel_polymorphic (0.2.2)
sequel (~> 4.0)
sequel-paranoid
sequel-rails
sequel-revisions
sequel_pg
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.