with_advisory_lock icon indicating copy to clipboard operation
with_advisory_lock copied to clipboard

Naming conflict

Open semaperepelitsa opened this issue 1 year ago • 4 comments

The private method included in ActiveRecord has a very generic name and can easily conflict. Is it possible to give it a more specific name?

ActiveRecord::Base.send(:impl_class) #=> WithAdvisoryLock::PostgreSQL

semaperepelitsa avatar Jan 03 '24 07:01 semaperepelitsa

Can you elaborate ?

seuros avatar Jan 21 '24 02:01 seuros

At the moment, ActiveRecord::Base.send(:impl_class) is reserved for your library, but the method name doesn't contain "with advisory lock", so it could be easily used by other libraries or application code. Let's say, a pagination library decides that they need their own impl_class - now there is a conflict. A better name would be something like ActiveRecord::Base.send(:with_advisory_lock_impl_class).

semaperepelitsa avatar Jan 21 '24 04:01 semaperepelitsa

Make sense.

I'm refactoring the gem to stop patching Base by default.

With the multiple database support we need to add it to the abstract record or the model that need it locking.

seuros avatar Jan 21 '24 09:01 seuros

@semaperepelitsa , i opened a PR to fix this.

seuros avatar Mar 03 '24 18:03 seuros