liveh2o / spectacles

ActiveRecord Views for PostgreSQL
MIT License
90 stars 11 forks source link

Fix postgres view dump returning unescaped double quotes #6

Closed nickmabry closed 9 years ago

nickmabry commented 9 years ago

Howdy! We were using spectacles to interface with a fairly complex Postgres view, created with a SQL string literal in a migration. When the create_view call was serialized to Rails' schema.rb, it contained unescaped double-quotes and would throw errors when restoring from schema.

We're still not sure exactly when this is the case, but Postgres can return double-quotes in its table_schema for certain view tables. Our quick fix was to patch the spectacles Postgres adapter to manually escape the returned SQL before ActiveRecord serialized it to schema.rb.

Please let me know if there's anything we can do to get this pushed upstream, or if this isn't an appropriate place for the fix. Thanks!

liveh2o commented 9 years ago

Seems fine to me. It's always odd figuring out exactly what a driver is going to do.

liveh2o commented 9 years ago

Released in v0.5.2.

nickmabry commented 9 years ago

Thanks for the crazy-fast response!

liveh2o commented 9 years ago

No problem. I know how frustrating it can be to wait on someone to merge your PR, so I try to turn things around quickly :+1: