public
Fork of fragility/spatial_adapter
Description: Miscellaneous PostgreSQL-related changes to Spatial Adapter
Home | Edit | New

Home

This is a forked repository. Have a look at
pdeffendol’s spatial_adapter wiki
for more information.

My 2 Changes

Processing non-geometry columns

The project on which I’m using this adapter also uses the open_id_authentication plugin. That plugin generated a table that defined a couple of :binary columns; bytea sql types. The original implementation handed non-geometry columns to ActiveRecord::ConnectionAdapters::Column, which is not that bad unless you have PostgreSQL-specific column types. Therefore, changing Column to ActiveRecord::ConnectionAdapters::PostgreSQLColumn allows the Spatial Adapter to pass control a class that knows how to handle PostgreSQL-specific column types; the change was made in post_gis_adapter.rb

Creating a PostGIS Test Database

The change I made depends/will depend upon the PostgresAdapter supporting the recreate_database method.

Because Rails wants to duplicate the Test Database from the Development Database I ran into a problem because my Development Database is a PostGIS database and required several addition commands after the original createdb. I am using Rails 2.0.2 and the databases.rake file issued shell commands for postgresql databases; mysql databases passed the commands to the MySQL Adapter. I needed a way to hook into, or extend, the way the Test Database was created. I modified the PostgreSQLAdapter and the databases.rake file in my Rails. I then modified the Spatial Adapter to override recreate_database to issue the additional commands. Now I can issue the Rake Test commands and my Test Database will get generated properly. This change might be difficult to apply since it requires changes to the Rails framework itself; upon investigation the changes I made have been applied to Edge Rails (I looked up the changed files here on GitHub)

Last edited by melriffe, Thu Jun 19 23:46:26 -0700 2008
Home | Edit | New
Versions: