Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Invert the conditionals to make easier to read

Also improve some of the code conventions
  • Loading branch information...
commit baf62e531686ee157746d239037be121f8191275 1 parent fb522a2
@rafaelfranca rafaelfranca authored
View
8 activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
@@ -186,10 +186,10 @@ def column_exists?(table_name, column_name, type = nil, options = {})
def create_table(table_name, options = {})
td = create_table_definition table_name, options[:temporary], options[:options], options[:as]
- unless options[:id] == false || options[:as]
- pk = options.fetch(:primary_key) {
+ if options[:id] != false && !options[:as]
+ pk = options.fetch(:primary_key) do
Base.get_primary_key table_name.to_s.singularize
- }
+ end
td.primary_key pk, options.fetch(:id, :primary_key), options
end
@@ -201,7 +201,7 @@ def create_table(table_name, options = {})
end
result = execute schema_creation.accept td
- td.indexes.each_pair { |c,o| add_index table_name, c, o } unless supports_indexes_in_create?
+ td.indexes.each_pair { |c, o| add_index(table_name, c, o) } unless supports_indexes_in_create?
result
end
Please sign in to comment.
Something went wrong with that request. Please try again.