rgeo/activerecord-postgis-adapter

Symbol as value in `where` has different behaviour than `postgres` adapter

Closed this issue · 2 comments

I'm currently working on a RoR 3.2 project, which is why I'm using activerecord-postgis-adapter v0.6.6. Not sure if this is no longer an issue on newer versions of the gem. We are currently trying to upgrade to RoR 4.x, but that won't be for another little while, so I need to get this working on 3.2.

With that bit of background, it seems like with the postgres adapter (from pg), the following code:

MyModel.where(status: :active)

gets converted to:

SELECT  * from my_models WHERE `my_models`.`status` = 'active'

But with the postgis adapter, it comes out as:

SELECT  * from my_models WHERE `my_models`.`status` = `my_models`.`active`

which results in an error (obviously) since the my_models table has no active column.

Is this difference in behaviour between the adapters intentional/necessary? Given that I'm switching an existing project from pg to activerecord-postgres-adapter, I would have to update every place I currently have symbols as values, and make sure that any methods that use a variable for the value to perform an explicit to_s, which will be highly error prone.

Cheers
Ruy

mjy commented

@keithdoggett likely a 'wontfix' tag?

Closing as stale.