Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestions/Questions #58

Open
fatkodima opened this issue Aug 26, 2022 · 0 comments
Open

Suggestions/Questions #58

fatkodima opened this issue Aug 26, 2022 · 0 comments

Comments

@fatkodima
Copy link

I had an idea for a similar gem in my TODO list, but after this week's RubyWeekly I noticed there is one already. So I will invest some effort into improving it, if you don't mind 😄

  1. Wdyt on supporting scopes as belongs_to association names:
class Answer < ActiveRecord::Base
  belongs_to :question
  acts_as_sequenced scope: :question
end

It looks more natural to me, than specifying column names and simplifies the setup when belongs_to is polymorphic.

  1. Support sharing scopes. For example, like on GitHub: both issues and pull requests are scoped to a repository.
  2. Why testing of MySQL was removed from this gem?
  3. Currently, when calculating the next sequential id, the whole table is locked (PostgreSQL only 🤔?)
    def lock_table
    if postgresql?
    record.class.connection.execute("LOCK TABLE #{record.class.table_name} IN EXCLUSIVE MODE")
    end
    end

    Whole table locks are very heavyweight and dangerous (see lock queueing in PostgreSQL) and are really not needed. I suggest locking only the parent record (if :scope is for parent record) using SELECT ... FOR UPDATE (https://api.rubyonrails.org/v5.2/classes/ActiveRecord/Locking/Pessimistic.html), this should be enough.
  4. README states that the scope option can be any attribute (not only the foreign key of an associated parent object). But what is the use case for this?

If these changes are OK, I will start implementing them one by one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant