tapioca icon indicating copy to clipboard operation
tapioca copied to clipboard

Handle ActiveRecord::Locking::LockingType

Open kbruccoleri opened this issue 1 year ago • 6 comments

Motivation

ActiveRecord::Locking::LockingType is used for the lock_version column to handle Optimistic Locking:

https://api.rubyonrails.org/classes/ActiveRecord/Locking/Optimistic.html

This type was falling into the else block and causing a Sorbet Error:

Expected type ::Object, got type ActiveRecord::Locking::LockingType with value #<ActiveModel::Type::Intege...ange=-2147483648...2147483648> (SorbetError)

Experiencing an issue after upgrading to latest Tapioca for Rails 7.2 compatibility.

Implementation

The column_type is really just a wrapper for a potentially nilable integer, so we make a specific exception for it.

Tried to follow the convention around it with regards to determining if particular column is nilable or not.

Tests

No existing test file for lib/tapioca/dsl/helpers/active_record_column_type_helper.rb

Shoutout to @cquinones100 for co-authoring

kbruccoleri avatar Sep 06 '24 20:09 kbruccoleri

I have signed the CLA!

kbruccoleri avatar Sep 06 '24 20:09 kbruccoleri

There's some unrelated CI failures btw. I'm working through those now.

amomchilov avatar Sep 12 '24 18:09 amomchilov

@amomchilov Thanks for the feedback and the guidance, I have accepted all of your edits and updated the co-authors.

kbruccoleri avatar Sep 12 '24 19:09 kbruccoleri

@kbruccoleri Excellent! I'll follow up on this once I've sorted out the CI issues

In the meantime, you please fix the lint failure? My hand-scribbled indentation suggestions were incorrect haha.

bundle exec rubocop --auto-correct lib/tapioca/dsl/helpers/active_record_column_type_helper.rb

amomchilov avatar Sep 12 '24 19:09 amomchilov

Hi @kbruccoleri! You can rebase on main, which should fix the CI issues. If you could also fix the linting issues, that would be much appreciated!

egiurleo avatar Sep 25 '24 19:09 egiurleo

Hi @kbruccoleri! You can rebase on main, which should fix the CI issues. If you could also fix the linting issues, that would be much appreciated!

@egiurleo Thanks for flagging - I believe I am rebased on main now and have bin/style passing.

kbruccoleri avatar Sep 26 '24 14:09 kbruccoleri

Hi there! Is there anything I can do to get this over the finish line? It seems like some checks might be failing for other reasons.

kbruccoleri avatar Dec 10 '24 18:12 kbruccoleri

@kbruccoleri I don't know what was up with those CI failures. I rebased, fixed the merge conflict, and started another CI run. I'll have a look at its result in the morning.

amomchilov avatar Dec 11 '24 22:12 amomchilov