From leo.soto at gmail.com Tue May 6 15:51:26 2008 From: leo.soto at gmail.com (Leo Soto M.) Date: Tue, 6 May 2008 15:51:26 -0400 Subject: [Georuby-devel] Compatibility with Rails 1.2.x? Message-ID: <5a8cc9e00805061251r1842a873t575d6e78128fcb2c@mail.gmail.com> Hi all, I'm testing the Spatial Adapter plugin, but it didn't worked inside a project that uses Rails 1.2.3. Here is what I get with almost every rake command after importing the plugin: rake aborted! undefined method `disable_referential_integrity' for class `ActiveRecord::ConnectionAdapters::PostgreSQLAdapter' [...]/vendor/plugins/spatial_adapter/lib/post_gis_adapter.rb:241 AFAICS, the PostGIS adapter is aliasing and redefining the disable_referential_integrity method. But that method was introduced on a more recent Rails version (I'd say 2.0). Looking at the adapter source, seems like the intention is to remain compatible with multiple Rails versions. I'd be happy to submit a patch to conditionally apply the aliasing only if the method exists on PostgreSQLAdapter. But I prefer to confirm first if that this is intended behavior. -- Leo Soto M. http://blog.leosoto.com From guilhem.vellut at gmail.com Tue May 6 18:38:53 2008 From: guilhem.vellut at gmail.com (Guilhem Vellut) Date: Wed, 7 May 2008 00:38:53 +0200 Subject: [Georuby-devel] Compatibility with Rails 1.2.x? In-Reply-To: <5a8cc9e00805061251r1842a873t575d6e78128fcb2c@mail.gmail.com> References: <5a8cc9e00805061251r1842a873t575d6e78128fcb2c@mail.gmail.com> Message-ID: <43f4b6ee0805061538y3b8bb544x56f27b5bb8781e34@mail.gmail.com> Hello, you're right. the intention is to remain compatible with previous rails version, although I must say the testing I do takes place only in the most recent versions. So if you have a patch to make the spatial adapter work on rails 1.2, i will happily integrate it. guilhem On Tue, May 6, 2008 at 9:51 PM, Leo Soto M. wrote: > Hi all, > > I'm testing the Spatial Adapter plugin, but it didn't worked inside a > project that uses Rails 1.2.3. Here is what I get with almost every > rake command after importing the plugin: > > rake aborted! > undefined method `disable_referential_integrity' for class > `ActiveRecord::ConnectionAdapters::PostgreSQLAdapter' > [...]/vendor/plugins/spatial_adapter/lib/post_gis_adapter.rb:241 > > AFAICS, the PostGIS adapter is aliasing and redefining the > disable_referential_integrity method. But that method was introduced > on a more recent Rails version (I'd say 2.0). Looking at the adapter > source, seems like the intention is to remain compatible with multiple > Rails versions. > > I'd be happy to submit a patch to conditionally apply the aliasing > only if the method exists on PostgreSQLAdapter. But I prefer to > confirm first if that this is intended behavior. > > -- > Leo Soto M. > http://blog.leosoto.com > _______________________________________________ > Georuby-devel mailing list > Georuby-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/georuby-devel > From leo.soto at gmail.com Fri May 9 16:28:41 2008 From: leo.soto at gmail.com (Leo Soto M.) Date: Fri, 9 May 2008 16:28:41 -0400 Subject: [Georuby-devel] Compatibility with Rails 1.2.x? In-Reply-To: <43f4b6ee0805061538y3b8bb544x56f27b5bb8781e34@mail.gmail.com> References: <5a8cc9e00805061251r1842a873t575d6e78128fcb2c@mail.gmail.com> <43f4b6ee0805061538y3b8bb544x56f27b5bb8781e34@mail.gmail.com> Message-ID: <5a8cc9e00805091328g7fd0ff7bpd2042385134edb77@mail.gmail.com> On Tue, May 6, 2008 at 6:38 PM, Guilhem Vellut wrote: > Hello, > you're right. the intention is to remain compatible with previous > rails version, although I must say the testing I do takes place only > in the most recent versions. So if you have a patch to make the > spatial adapter work on rails 1.2, i will happily integrate it. > guilhem OK. Should I submit it using the rubyforge tracker? Or is it OK to attach the patch here? -- Leo Soto M. http://blog.leosoto.com From leo.soto at gmail.com Fri May 9 16:33:53 2008 From: leo.soto at gmail.com (Leo Soto M.) Date: Fri, 9 May 2008 16:33:53 -0400 Subject: [Georuby-devel] Compatibility with Rails 1.2.x? In-Reply-To: <5a8cc9e00805091328g7fd0ff7bpd2042385134edb77@mail.gmail.com> References: <5a8cc9e00805061251r1842a873t575d6e78128fcb2c@mail.gmail.com> <43f4b6ee0805061538y3b8bb544x56f27b5bb8781e34@mail.gmail.com> <5a8cc9e00805091328g7fd0ff7bpd2042385134edb77@mail.gmail.com> Message-ID: <5a8cc9e00805091333t216b9b64hb342acdc0fd57acc@mail.gmail.com> On Fri, May 9, 2008 at 4:28 PM, Leo Soto M. wrote: [...] > OK. Should I submit it using the rubyforge tracker? Or is it OK to > attach the patch here? Well, the patch is fairly trivial, so I'm attaching it here. If that's not OK, I can register on rubyforge later and submit it using the tracker... -- Leo Soto M. http://blog.leosoto.com -------------- next part -------------- A non-text attachment was scrubbed... Name: post_gis_adapter_r115_rails_1.2.x_compat.patch Type: text/x-diff Size: 775 bytes Desc: not available URL: From leo.soto at gmail.com Tue May 13 16:16:56 2008 From: leo.soto at gmail.com (Leo Soto M.) Date: Tue, 13 May 2008 16:16:56 -0400 Subject: [Georuby-devel] SpatialAdapter Migrations: Providing an option to not use AddGeometryColumn? Message-ID: <5a8cc9e00805131316r799719fbt1cb26a47c18bb6a5@mail.gmail.com> Hi, I have been continuing integrating GeoRuby and the Spatial Adapter into an pre-existing project (with a pre-existent database), and, until now, it seems to work fine. But now I want to run a migration to create a new table which will include a geometry column. Even before using the Spatial Adapter, the following worked: t.add_column :foo, :geometry, :null => false But, as ActiveRecord didn't recognized the datatype, passed it to the database "as is". So I had to manually add a check constraint for the ndims(foo). Now that SpatialAdapter is installed, it reconizes :geometry, and adds the ndimsconstraint automatically, as a result of using AddGeometryColumn to create the foo column. Sadly, it also adds the columns to geometry_columns and adds a srid constraint. I don't want that, because this particular column won't have a fixed SRID. I see the following options: 1. Use raw SQL instead of add_column. Ugly, but should work. 2. Use add_column and later raw SQL to delete the column from geometry_columns and drop the srid constraint. Even ugliest. 3. Hack SpatialAdapter to recognize this scenario. What do you think about the third option? -- Leo Soto M. http://blog.leosoto.com From leo.soto at gmail.com Mon May 19 11:57:45 2008 From: leo.soto at gmail.com (Leo Soto M.) Date: Mon, 19 May 2008 11:57:45 -0400 Subject: [Georuby-devel] SpatialAdapter Migrations: Providing an option to not use AddGeometryColumn? In-Reply-To: <43f4b6ee0805170638v3b274c40oca4c487c0a628aaf@mail.gmail.com> References: <5a8cc9e00805131316r799719fbt1cb26a47c18bb6a5@mail.gmail.com> <43f4b6ee0805170638v3b274c40oca4c487c0a628aaf@mail.gmail.com> Message-ID: <5a8cc9e00805190857x4fad124em755c1023f784b869@mail.gmail.com> On Sat, May 17, 2008 at 9:38 AM, Guilhem Vellut wrote: > Hello, > Thanks for the patch for 1.2.x (it was from some time ago...). I just > committed it. Thanks *you*. GeoRuby and the Spatial Adapter looks like a great piece of software. [...] > The better thing would be a modification to the code > adding a column, in order to have an option to indicate the user > doesn't want to add a column through select AddGeometriColumn(...) but > use the usual standard rails way. Agreed. > By a quick look at the spatial > adapter, adding some processing to the > PostgreSQLTableDefinition#column method and the > PostgreSQLColumnDefintiion class should be enough. I managed to do it without modifying PostgreSQLColumnDefintion, but that was because I modified ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#add_column. I don't know too much about ActiveRecord, so that may be a wrong way to do it. I also think that remove_column should be patched in a similar way. > I will try to add > that in the coming days (probably end of next week) but if you have a > patch before then, i will include it. I'd happy to write it. I'm just uncertain of the name of the option to keep the "old way" to create the column. Here are some options: t.column :foo, :geometry, :enforce_srid => false t.column :foo, :geometry, :create_using_addgeometrycolumn => false t.column :foo, :geometry, :opengis => false I don't like the first, because it is misleading: what I'm implementing doesn't only removes the enforcement of srid; it also ignores dimensions, and doesn't register the column on the geometry_column table. The second one is very tied to the implementation and a bit large, but very clear. The third tries to be more concise, but may raise questions to people looking at the code. So I'm leaning towards the second option (even after using the third one when I prototyped it). But you have the last word on it. -- Leo Soto M. http://blog.leosoto.com From guilhem.vellut at gmail.com Mon May 19 13:50:37 2008 From: guilhem.vellut at gmail.com (Guilhem Vellut) Date: Mon, 19 May 2008 19:50:37 +0200 Subject: [Georuby-devel] SpatialAdapter Migrations: Providing an option to not use AddGeometryColumn? In-Reply-To: <5a8cc9e00805190857x4fad124em755c1023f784b869@mail.gmail.com> References: <5a8cc9e00805131316r799719fbt1cb26a47c18bb6a5@mail.gmail.com> <43f4b6ee0805170638v3b274c40oca4c487c0a628aaf@mail.gmail.com> <5a8cc9e00805190857x4fad124em755c1023f784b869@mail.gmail.com> Message-ID: <43f4b6ee0805191050k74474c65vcb16b41defd0b8ca@mail.gmail.com> On Mon, May 19, 2008 at 5:57 PM, Leo Soto M. wrote: > I managed to do it without modifying PostgreSQLColumnDefintion, but > that was because I modified > ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#add_column. I > don't know too much about ActiveRecord, so that may be a wrong way to > do it. > > I also think that remove_column should be patched in a similar way. > OK. Sounds fine. > So I'm leaning towards the second option (even after using the third > one when I prototyped it). But you have the last word on it. I like the second one as well. I don't think it will be an extremely common option (when true by default) so length is not a big problem. It is self-documenting too. Thank you for your work. guilhem From leo.soto at gmail.com Mon May 26 10:29:54 2008 From: leo.soto at gmail.com (Leo Soto M.) Date: Mon, 26 May 2008 10:29:54 -0400 Subject: [Georuby-devel] SpatialAdapter Migrations: Providing an option to not use AddGeometryColumn? In-Reply-To: <43f4b6ee0805191050k74474c65vcb16b41defd0b8ca@mail.gmail.com> References: <5a8cc9e00805131316r799719fbt1cb26a47c18bb6a5@mail.gmail.com> <43f4b6ee0805170638v3b274c40oca4c487c0a628aaf@mail.gmail.com> <5a8cc9e00805190857x4fad124em755c1023f784b869@mail.gmail.com> <43f4b6ee0805191050k74474c65vcb16b41defd0b8ca@mail.gmail.com> Message-ID: <5a8cc9e00805260729h3d395688p30fd61b2c8fefd89@mail.gmail.com> On Mon, May 19, 2008 at 1:50 PM, Guilhem Vellut wrote: [...] > I like the second one as well. I don't think it will be an extremely > common option (when true by default) so length is not a big problem. > It is self-documenting too. > Thank you for your work. OK, Here is the patch. I also added the :remove_using_dropgeometrycolumn option to remove_column, which when set removes it as if it were a normal column. Pretty self-documenting too. -- Leo Soto M. http://blog.leosoto.com -------------- next part -------------- A non-text attachment was scrubbed... Name: spatial_adapter_option_for_not_using_addgeometrycolumn.patch Type: text/x-diff Size: 1857 bytes Desc: not available URL: