Skip to content

Commit baf62e5

Browse files
committed
Invert the conditionals to make easier to read
Also improve some of the code conventions
1 parent fb522a2 commit baf62e5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,10 @@ def column_exists?(table_name, column_name, type = nil, options = {})
186186
def create_table(table_name, options = {})
187187
td = create_table_definition table_name, options[:temporary], options[:options], options[:as]
188188

189-
unless options[:id] == false || options[:as]
190-
pk = options.fetch(:primary_key) {
189+
if options[:id] != false && !options[:as]
190+
pk = options.fetch(:primary_key) do
191191
Base.get_primary_key table_name.to_s.singularize
192-
}
192+
end
193193

194194
td.primary_key pk, options.fetch(:id, :primary_key), options
195195
end
@@ -201,7 +201,7 @@ def create_table(table_name, options = {})
201201
end
202202

203203
result = execute schema_creation.accept td
204-
td.indexes.each_pair { |c,o| add_index table_name, c, o } unless supports_indexes_in_create?
204+
td.indexes.each_pair { |c, o| add_index(table_name, c, o) } unless supports_indexes_in_create?
205205
result
206206
end
207207

0 commit comments

Comments
 (0)