datamapper / dm-migrations

DataMapper plugin for writing and speccing migrations
http://datamapper.org/
MIT License
66 stars 42 forks source link

Inherit DB field type from superclass #54

Closed tillsc closed 8 years ago

tillsc commented 9 years ago

Problem: All custom DataMapper::Properties (e.g. in dm-types) have database field types based upon their Ruby primitives. Especially Properties inheriting from DataMapper::Property::Text like DataMapper::Property::JSON have some problems with that behavior (since they will result in VARCARs instead of LOBs).

This commit adds logic to try to find a database field type based upon the superclasses of the (custom) property. Only if no superclass has a direkt mapping from Property.class to field type the fallback to the Ruby primitive (returned by dump_as) will take place.

tillsc commented 9 years ago

I'm sorry for the old school style while loops. But I tried not to change the class signatures.

tpitale commented 8 years ago

@tillsc Would love to merge this. Can you take a look when you get a chance?

tillsc commented 8 years ago

I did a whole new approach in #57. I decided to make a new branch to keep the history a bit cleaner. The failing specs I added in this approach where ported to the new approach. Everything else is new (and tested with mysql and postgres).