luckyframework / luckyframework/avram

Using the generic name T in an operation name will case after_save to fail silently

Open
#836 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
Crystal
Stars
183
Forks
67
PR merge metrics
No merged PRs in 30d

Description

The `T` generic silently clashes with the one used in `after_save`.

So this does not work:

```crystal
class SaveSomeModel(T) < SomeModel::SaveOperation
after_save do |some_model|
# use T...
end
end
```

But this does:

```crystal
class SaveSomeModel(Some) < SomeModel::SaveOperation
after_save do |some_model|
# use Some...
end
end
```

As proposed in the Discord, it would be better not never use `T` inside the framework, but use something like `LuckyT` instead.

Contributor guide

Open the contributing guide

Research direction

Start at the after_save operation path and search the Avram source for framework-level uses of the generic name T. Reproduce the issue with the SaveSomeModel(T) example and compare it with SaveSomeModel(Some). Done means the T form no longer fails silently in after_save and the relevant behavior is covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
crystal
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.