activerecord_constraints 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/activerecord_constraints.rb +10 -1
  2. 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
- column_name = options[:column].name
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord_constraints
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: