File tree Expand file tree Collapse file tree 1 file changed +11
-11
lines changed
lib/active_record/postgres/constraints/types Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,17 @@ module ActiveRecord
44 module Postgres
55 module Constraints
66 class << self
7+ def to_sql ( table , name_or_conditions , conditions = nil )
8+ if conditions
9+ name = name_or_conditions
10+ else
11+ name = "#{ table } _#{ Time . zone . now . nsec } "
12+ conditions = name_or_conditions
13+ end
14+
15+ "CONSTRAINT #{ name } CHECK (#{ normalize_conditions ( conditions ) } )"
16+ end
17+
718 def normalize_conditions ( conditions )
819 conditions = [ conditions ] unless conditions . is_a? ( Array )
920 conditions = conditions . map do |condition |
@@ -26,17 +37,6 @@ def normalize_conditions_hash(hash)
2637 end
2738 "(#{ hash . join ( ') AND (' ) } )"
2839 end
29-
30- def to_sql ( table , name_or_conditions , conditions = nil )
31- if conditions
32- name = name_or_conditions
33- else
34- name = "#{ table } _#{ Time . zone . now . nsec } "
35- conditions = name_or_conditions
36- end
37-
38- "CONSTRAINT #{ name } CHECK (#{ normalize_conditions ( conditions ) } )"
39- end
4040 end
4141 end
4242 end
You can’t perform that action at this time.
0 commit comments