# Postgres geometric types support

**URL:** <https://www.ruby-forum.com/t/postgres-geometric-types-support/104358>\
**Category:** Rails\
**Created:** [May 17, 2007, 4:30am UTC](https://www.ruby-forum.com/t/postgres-geometric-types-support/104358 "2007-05-17T04:30:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jon\_Smillie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ed8c4c/32.png) [@Jon\_Smillie](https://www.ruby-forum.com/u/Jon_Smillie)\
**Post date:** [May 17, 2007, 4:30am UTC](https://www.ruby-forum.com/t/postgres-geometric-types-support/104358/1 "2007-05-17T04:30:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Jon\_Smillie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ed8c4c/32.png) [@Jon\_Smillie](https://www.ruby-forum.com/u/Jon_Smillie)\
**Post date:** [May 17, 2007, 3:45pm UTC](https://www.ruby-forum.com/t/postgres-geometric-types-support/104358/2 "2007-05-17T15:45:28Z")

</div>

Placing this:

config.active\_record.schema\_format = :sql

in your environment would solve your test database problems.

Tiago M.
