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(table_definition) ⇒ Object
rubocop:disable Naming/MethodName.
Instance Method Details
#adjust_nesting(nesting, token) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/active_record/postgres/constraints/schema_creation.rb', line 24 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(table_definition) ⇒ Object
rubocop:disable Naming/MethodName
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/active_record/postgres/constraints/schema_creation.rb', line 8 def visit_TableDefinition(table_definition) # rubocop:enable Naming/MethodName result = super return result unless table_definition.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] = ", #{table_definition.constraints.join(', ')})" result end |