Module: ActiveRecord::Postgres::Constraints::SchemaCreation
- Defined in:
- lib/active_record/postgres/constraints/schema_creation.rb
Instance Method Summary collapse
- #adjust_nesting(nesting, token) ⇒ Object
-
#visit_TableDefinition(o) ⇒ Object
rubocop:disable Style/MethodName.
Instance Method Details
#adjust_nesting(nesting, token) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/active_record/postgres/constraints/schema_creation.rb', line 22 def adjust_nesting(nesting, token) nesting_was = nesting nesting += 1 if '(' == token nesting -= 1 if ')' == token [nesting, (1 == nesting_was && nesting.zero?)] end |
#visit_TableDefinition(o) ⇒ Object
rubocop:disable Style/MethodName
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/active_record/postgres/constraints/schema_creation.rb', line 7 def visit_TableDefinition(o) # rubocop:enable Style/MethodName result = super return result unless o.check_constraints nesting = 0 # Find the closing paren of the "CREATE TABLE ( ... )" clause index = result.length.times do |i| token = result[i] nesting, should_break = adjust_nesting(nesting, token) break i if should_break end result[index] = ", #{o.check_constraints.join(', ')})" result end |