Postgres geometric types support

I’ve been trying to get rails to work successfully with the native
geometric
types in postgres (point, box, etc), but out of the box rails dumbs
these down
to string types. This means that when rake creates my test database, it
converts
geometric typed columns to string types, meaning tests which utilise
geometric
functions blow up as they are now dealing with strings in the underlying
database.

I managed to get around this with two changes in the ruby postgres
adapter, and
one in the active record schema_definitions file:

In postgresql_adapter.rb I added definitions for the geometric types to
“native_database_types”, and I uncommented the line which handles these
types (interesting
that it was there) in “translate_field_type”.

In the active record file schema_definitions.rb I added clauses to
handle these
types to “simplified_type”.

I don;t know if these was a better or nicer way I should have done this


Jon Smillie
ANU Supercomputer Facility

Placing this:

config.active_record.schema_format = :sql

in your environment would solve your test database problems.

Tiago M.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs