0

I'm working with an open source database. I'm trying to map it to classes with DataMapper, and later I'm going to make changes in a Model driven approximation instead of a Database driven one.

But first I would like to map the open source database in an exact way. This database is a PostgreSQL one and in some tables there are some fields with a character type.

How can I map character type in DataMapper? This type it's not in its primitive types, nor in dm-types, nor in dm-types-legacy.

If it gives more information, actually I'm not writing the model by hand but I'm using dm-is-reflective, which automatically maps an existing database table. It gives me following error:

/var/lib/gems/1.9.1/gems/dm-is-reflective-1.0.0/lib/dm-is-reflective/is/adapters/data_objects_adapter.rb:141:in `reflective_lookup_primitive': bpchar not found for DataMapper::Adapters::PostgresAdapter (TypeError)

EDIT It was a problem with dm-is-reflective and not with datamapper core, which can work well with char type as a String type with a length set. I answer with the solution to the problem.

Waiting for Dev...
  • 11,486
  • 5
  • 41
  • 56
  • Can you change those fields to `varchar` or (better) `text`? In PostgreSQL, `char` is usually a bad choice for a data type. It is supported because it is in the standard, but it would be wise to avoid using it. – kgrittn May 14 '12 at 19:15
  • Thanks for your answer @kgrittn. But as I said I would like to do a mapping to the original and intact database, and from there make my changes with the models as bases... – Waiting for Dev... May 14 '12 at 19:35
  • I guess you need to find a gem which deals with this archaic data type. – kgrittn May 14 '12 at 20:35

1 Answers1

0

godfat, the man working in dm-is-reflective quickly solved this issue :) Many thanks to him!

https://github.com/godfat/dm-is-reflective/issues/3#issuecomment-5726650

Waiting for Dev...
  • 11,486
  • 5
  • 41
  • 56