luckyframework / luckyframework/avram
BaseModel class abstract error
Nobody has claimed this yet.
- Dominant language
- Crystal
- Stars
- 183
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
If you create your own BaseModel, but forget to make it `abstract`, you can end up with an error like this:
```crystal
class MyBaseModel < Avram::Model
macro default_columns
primary_key id : Int16
timestamps
end
end
```
```
Error in lib/avram/src/avram/model.cr:16: abstract `def Avram::Model#id()` must be implemented by Primetime::PrimetimeBaseModel
abstract def id
^~
```
The error is correct, but it doesn't make sense on why you're getting it since `primary_key id` does define a `id` method. To fix this, the `MyBaseModel` just needs to be `abstract`.
```crystal
abstract class MyBaseModel < Avram::Model
```
I'm not sure how we can fix this, but a better error message would be nice here.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the MyBaseModel example and inspect lib/avram/src/avram/model.cr around the abstract id declaration. Trace why primary_key id is not reflected in the compiler diagnostic when the model is not abstract. Done means the error clearly explains the required abstract declaration or otherwise gives actionable guidance.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- crystal
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100