On Sunday, July 5, 2020 at 7:31:29 PM UTC-7, Aleksey Matskevich wrote: > > > In my application, a user can be identified by one of three fields - an > nickname, a phone number or mail. None of the fields are required, but at > least one must be completed. I am trying to make a check, which requires > filling one of the three fields. > In SQL, I would write something like this: > ...sql > CONSTRAINT username_email_phone_number_notnull CHECK ( > NOT (nickname IS NULL and email IS NULL and phone_number IS NULL) > ) > ``` > How to write such a restriction in sequel? >
constraint :username_email_phone_number_notnull, Sequel.~(nickname: nil, email: nil, phone_number: nil) CONSTRAINT username_email_phone_number_notnull CHECK ((nickname IS NOT NULL) OR (email IS NOT NULL) OR (phone_number IS NOT NULL)) Thanks, Jeremy -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/sequel-talk/7c79b265-79b7-48a2-be35-0db7ac6c78c8o%40googlegroups.com.
