Revert "Make scopes available for abstract classes" #1431
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reverts #1250
I've been thinking about the problem that this change has been causing with AR relations (as pointed out by #1413 that was trying to fix this forward), and I've come to the conclusion that it is better for Tapioca to NOT support this case at all, for a few reasons.
I will explain my reasons based on the following code example (adapted from the one in the original PR #1250)
deleted
method. It is supposed to the anActiveRecord::Relation
subtype, but the actual type would depend on what it was called on. For example:deleted
call being made inside thecount_deleted
method, since depending on what model typecount_deleted
is being called on, it could be returning any of the types listed in the previous point. As a result, thedeleted
call being made inside that method is not type safe anyway, and I would really prefer if that was explicit using aT.unsafe
explicitly.Comment.count_deleted
call and seeing that it raises an error with the messageno such column: comments.deleted_at
. Since the abstract base class cannot enforce the definition of a set of columns on child models, it should not try to act like it can ensure that it can make these kinds of queries either. If applications still want to use this pattern, it is better for them to explicitly useT.unsafe
to communicate that the method could be unsafe in this respect as well.So, I think it is best to revert the original PR and disallow abstract base classes from DSL generation for scopes.