1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

ask column if it is a pk

This commit is contained in:
Aaron Patterson 2013-03-14 23:49:00 -07:00
parent 2394d28ade
commit c1003d99b0

View file

@ -24,6 +24,10 @@ module ActiveRecord
base.type_to_sql(type.to_sym, limit, precision, scale)
end
def primary_key?
type == :primary_key
end
def to_sql
column_sql = "#{base.quote_column_name(name)} #{sql_type}"
column_options = {}
@ -299,7 +303,7 @@ module ActiveRecord
end
def primary_key_column_name
primary_key_column = columns.detect { |c| c.type == :primary_key }
primary_key_column = columns.detect { |c| c.primary_key? }
primary_key_column && primary_key_column.name
end