luckyframework / luckyframework/avram

Validators and data manipulation can't go in the same before_save queue.

Open
#376 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Crystal
Stars
183
Forks
67
PR merge metrics
No merged PRs in 30d

Description

Currently, the validator for a non-nilable `belongs_to` in a model can be called _before_ any `before_save` callback requested by the save operation for that model. Which breaks things if the user expected to set that value in the `before_save` callback.

Rather than a single before_save queue, it appears to be necessary to have two, so that all of the data manipulation can take place before any of the validators are called.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the before_save callback queue and the non-nilable belongs_to validator described in the issue. Determine how callback ordering is currently handled; done means data-manipulation callbacks run before validators, with coverage for a save operation that sets the association in before_save.

Written by the indexing model from the issue text.

Assessment

Tech stack
crystal
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.