activerecord-postgis-adapter icon indicating copy to clipboard operation
activerecord-postgis-adapter copied to clipboard

Does not dump virtual / generated / stored columns correctly

Open sfcgeorge opened this issue 2 years ago • 1 comments

Whatever they're called, when using the postgis adapter with Rails 7 virtual columns don't get dumped correctly leading to an invalid schema.

- t.virtual "popularity", type: :string, as: "1", stored: true
+ t.string "popularity", default: -> { "1" }

sfcgeorge avatar Aug 01 '22 16:08 sfcgeorge

I just released version 8.0.1 which includes this PR (https://github.com/rgeo/activerecord-postgis-adapter/pull/360) that I believe resolves this issue. Let me know if it doesn't.

keithdoggett avatar Aug 01 '22 17:08 keithdoggett

Hello, I’m having some troubles specifically with virtual geometry columns in the generated schema.rb

The migration works fine with limit: "geometry, 3857"

But I get something like t.virtual "geom_web_mercator", type: :geometry, limit: {:srid=>0, :type=>"geometry"}, as: "st_transform(geom, 3857)", stored: true

So when doing a rails db:reset I have the following error:

ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR:  syntax error at or near "{"
LINE 1: ...:geography)) STORED, "geom_web_mercator" geometry({:srid=>38...

Tristramg avatar Apr 21 '23 11:04 Tristramg

Version 8.0.2 includes the fix for virtual geometry columns.

keithdoggett avatar May 16 '23 13:05 keithdoggett