Module: ActiveRecord::ConnectionAdapters::SchemaStatements
- Defined in:
- lib/activerecord_constraints.rb
Instance Method Summary collapse
-
#add_column_options_with_constraints!(sql, options) ⇒ Object
When base.add_column_options_with_constraints! is called by ColumnDefinition#add_column_options_with_constraints! it ends up calling SchemaStatements#add_column_options_with_constraints!.
Instance Method Details
#add_column_options_with_constraints!(sql, options) ⇒ Object
When base.add_column_options_with_constraints! is called by ColumnDefinition#add_column_options_with_constraints! it ends up calling SchemaStatements#add_column_options_with_constraints!. We capture that call as well so that we can append the constraint clauses to the sql statement.
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
# File 'lib/activerecord_constraints.rb', line 232 def (sql, ) ActiveRecord::Base.logger.debug("IN: SchemaStatements#add_column_options_with_constraints!") # Add this in if you need the stack trace when this is called. # ActiveRecord::Base.logger.debug("#{caller[0 .. 10].join("\n")}") # TODO: # This needs to dig out the database type of the connection # and then extend the database specific set of Constraints extend Constraints::Postgresql (sql, ) if .has_key? :column # This is code that may never have worked. column_name = [:column].name else raise ArgumentError.new("Can't pasrse SQL #{sql} to find column name") unless md = Regexp.new('.* add column[ "]+([^ "]+)[" ]+.*', Regexp::IGNORECASE).match(sql) column_name = md[1] end sql << unique_str(column_name, , true) sql << reference_str(column_name, , true) sql << check_str(column_name, , true) sql << suffix_str() end |