File tree Expand file tree Collapse file tree 3 files changed +11
-4
lines changed
connection_adapters/abstract Expand file tree Collapse file tree 3 files changed +11
-4
lines changed Original file line number Diff line number Diff line change 1
1
*SVN*
2
2
3
+ * Migrations: create_table supports primary_key_prefix_type. #10314 [student, thechrisoshow]
4
+
3
5
* Ensure that ActiveRecord::Calculations disambiguates field names with the table name. #11027 [cavalle]
4
6
5
7
* Ensure that modifying has_and_belongs_to_many actions clear the query cache. Closes #10840 [john.andrews]
Original file line number Diff line number Diff line change @@ -966,14 +966,19 @@ def primary_key
966
966
end
967
967
968
968
def reset_primary_key #:nodoc:
969
+ key = get_primary_key ( base_class . name )
970
+ set_primary_key ( key )
971
+ key
972
+ end
973
+
974
+ def get_primary_key ( base_name ) #:nodoc:
969
975
key = 'id'
970
976
case primary_key_prefix_type
971
977
when :table_name
972
- key = Inflector . foreign_key ( base_class . name , false )
978
+ key = Inflector . foreign_key ( base_name , false )
973
979
when :table_name_with_underscore
974
- key = Inflector . foreign_key ( base_class . name )
980
+ key = Inflector . foreign_key ( base_name )
975
981
end
976
- set_primary_key ( key )
977
982
key
978
983
end
979
984
Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ def columns(table_name, name = nil) end
89
89
# See also TableDefinition#column for details on how to create columns.
90
90
def create_table ( table_name , options = { } )
91
91
table_definition = TableDefinition . new ( self )
92
- table_definition . primary_key ( options [ :primary_key ] || "id" ) unless options [ :id ] == false
92
+ table_definition . primary_key ( options [ :primary_key ] || Base . get_primary_key ( table_name ) ) unless options [ :id ] == false
93
93
94
94
yield table_definition
95
95
You can’t perform that action at this time.
0 commit comments