Which ORM is best to use with a new Rails 3 app against a legacy MySQL 5.1 database? I do not expect to ever run a migration against this database (though the schema may change from time to time), but I will certainly be writing to it.
I may be biased towards DataMapper, but I think DM is generally a good option for integrating with legacy databases.
DM allows you to map meaningful model and property names to cryptic legacy table and column naming conventions. It allows you to do so either on a per model/property, or an app wide basis.
DM supports lazy properties, that will only be fetched when actually accessed.
DM has seamless support for composite primary keys.
DM only cares about the properties (columns) you explicitly declare in your models. Other columns will never be touched or read.
DM works nice with foreign key constraints in your database and with the help of dm-constraints it also supports creating them.
There's some documentation on http://datamapper.org/docs/legacy too.
还有dm-types-legacy库(https://github.com/postmodern/dm-types-legacy),它提供了常见的DM类型,用于映射奇怪格式的数据(数字IP地址,HTML / URI编码文本,日期) /时间字符串)。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.