shoulda-matchers icon indicating copy to clipboard operation
shoulda-matchers copied to clipboard

Introduce support for the Attributes API typing

Open bsimpson opened this issue 6 years ago • 3 comments

The column type itself is only a uuid in certain database implementations like PostgreSQL

MySQL uuids are supportable using the Rails 5 Attributes API and registering a new :uuid type. The column type is not a :uuid, but the registered attribute type is a :uuid

e.g.

module ActiveRecord
  module Type
    class Uuid < ActiveRecord::Type::Binary
      def type
        :uuid
      end

      ...
    end
  end
end

ActiveRecord::Type.register(:uuid, ActiveRecord::Type::Uuid, adapter: :mysql2)

class Model < ApplicationRecord
  attribute :id, :uuid
end

Model.attribute_types[:id].type # => :uuid

Example gem making using of the Attributes API for uuids in MySQL: https://github.com/mathieujobin/activerecord-mysql-uuid-column

This is related to a closed issue "Support UUID columns that end in 'f'": https://github.com/thoughtbot/shoulda-matchers/commit/81034eaf3d0f19f0863eccdc0d10856f6a4610c1 . This fix did not identify the Rails 5 attributes API types however.

bsimpson avatar Dec 14 '18 22:12 bsimpson

Hey folks. In an effort to lighten our load as maintainers and be able to serve you better in the future, the shoulda-matchers team is working on cleaning out the cobwebs in this repo by pruning the backlog. As there are few of us, there are a lot of items that will simply never earn our attention in a reasonable time frame, and rather than giving you an empty promise, we think it makes more sense to focus on more recent issues. That means, unfortunately, that we must close this PR.

Don't take this the wrong way: our aim is not to diminish the effort people have made or dismiss problems that have been raised. If you feel that we should reopen this PR, then please let us know so that we can reprioritize it. Thanks!

mcmire avatar May 06 '20 07:05 mcmire

@mcmire This is a useful contribution. I nominate it as a candidate for reopening and triage. Thanks!

nilbus avatar May 06 '20 11:05 nilbus

Ok! I've reopened it.

mcmire avatar May 06 '20 15:05 mcmire