Cockroach: sql: support ActiveRecord through postgresql adapter

Created on 9 Jan 2017  路  7Comments  路  Source: cockroachdb/cockroach

These are the features needed to support ActiveRecord using its postgresql database adapter:

  • [x] #12785 support unnest built-in
  • [x] #11215 extract set-returning functions from renders to cross-joins
  • [x] #12783 support col_description built-in
  • [x] #12153: unwrap inner quotes in OID typecasts
  • [x] #12151: support format_type built-in
  • [x] #12148: current_schema{,s}() builtins should return public, not database name
  • [x] #12139: support array_in built-in
  • [x] #12976: pg_catalog.pg_collation
  • [x] #12145: ActiveRecord expects precise type names
  • [x] #13486: try_advisory_lock() (Rails 5)
  • [x] #13485: current_database() (Rails 5)
  • [x] #13567: Improved support for regfoo types
  • [ ] #10735: SAVEPOINT
A-sql-pgcompat

Most helpful comment

Once https://github.com/rails/rails/pull/27949 makes it into a release, we won't need common table expressions at all.

All 7 comments

cc @jordanlewis @nvanbenschoten

After #13429 and a workaround for #13468, we manage to successfully make it past all of ActiveRecord's type management and schema creation routines - rake db:migrate on a fairly complex example works without a hitch. Next step is working through and validating some actual CRUD operations via the ORM.

So it turns out common table expressions aren't used before Rails/ActiveRecord 5.0, which was released in June 2016. We could probably claim Rails/ActiveRecord 4.2.6 support without too much more work - notably we wouldn't need #7029 or #13156.

In addition, in order to support Rails 5.0+ without supporting correlated subqueries, we'll need to wait until https://github.com/rails/rails/pull/27743 is released in Rails 5.0.2.

Once https://github.com/rails/rails/pull/27949 makes it into a release, we won't need common table expressions at all.

Rails uses savepoints during transactions. Looks like we'll need to support them. Added #10735 to the list.

We changed strategies and now provide an adapter for CockroachDB support in ActiveRecord. See https://github.com/cockroachdb/activerecord-cockroachdb-adapter and the docs.

Was this page helpful?
0 / 5 - 0 ratings