I need to get the column name containing the primary key(s) at the database level.
Model.primary_key
returns models_id
column name which is not the primary key at the database level. I cannot change migrations or modify the tables in anyway.
I can currently get it through the MySqlAdapter with ActiveRecord::Base.connection.primary_key('table_name')
but this does not work with tables that have composite primary keys. If the table contains a composite primary key it returns nil
.
Is there any way I can achieve this programatically?
Aucun commentaire:
Enregistrer un commentaire