Florin Asăvoaie
Florin Asăvoaie

Reputation: 918

Complex constraints in Sequel

I have the following constraint in a Sequel migratin:

constraint(:date_is_1_feb_or_1_aug, 'EXTRACT(MONTH FROM date)::INT IN (2,8) AND EXTRACT(DAY FROM date)::INT = 1')

Is there any way to simplify this and use the DSL?

Upvotes: 0

Views: 160

Answers (1)

Jeremy Evans
Jeremy Evans

Reputation: 12139

constraint(:date_is_1_feb_or_1_aug,
   Sequel.extract(:month, :date).cast(Integer)=>[2,8],
   Sequel.extract(:day, :date).cast(Integer)=>1)

Upvotes: 1

Related Questions