activerecord_constraints 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/activerecord_constraints.rb +10 -1
- metadata +1 -1
@@ -231,6 +231,8 @@ module ActiveRecord
|
|
231
231
|
# clauses to the sql statement.
|
232
232
|
def add_column_options_with_constraints!(sql, options)
|
233
233
|
ActiveRecord::Base.logger.debug("IN: SchemaStatements#add_column_options_with_constraints!")
|
234
|
+
# Add this in if you need the stack trace when this is called.
|
235
|
+
# ActiveRecord::Base.logger.debug("#{caller[0 .. 10].join("\n")}")
|
234
236
|
|
235
237
|
# TODO:
|
236
238
|
# This needs to dig out the database type of the connection
|
@@ -238,7 +240,14 @@ module ActiveRecord
|
|
238
240
|
extend Constraints::Postgresql
|
239
241
|
|
240
242
|
add_column_options_without_constraints!(sql, options)
|
241
|
-
|
243
|
+
if options.has_key? :column
|
244
|
+
# This is code that may never have worked.
|
245
|
+
column_name = options[:column].name
|
246
|
+
else
|
247
|
+
raise ArgumentError.new("Can't pasrse SQL #{sql} to find column name") unless
|
248
|
+
md = Regexp.new('.* add column[ "]+([^ "]+)[" ]+.*', Regexp::IGNORECASE).match(sql)
|
249
|
+
column_name = md[1]
|
250
|
+
end
|
242
251
|
sql << unique_str(column_name, options, true)
|
243
252
|
sql << reference_str(column_name, options, true)
|
244
253
|
sql << check_str(column_name, options, true)
|