Loco ActiveRecord::Base::normalizes version #1084
josercarmo
started this conversation in
Ideas
Replies: 1 comment
-
Since the SEA ORM is responsible for assigning, updating and querying, it would be natural for SEA to provide ways to pass normalization functions to certain columns. impl Params {
fn update(&self, item: &mut ActiveModel) {
item.name = sea_orm::ActiveValue::Set(self.name.clone());
item.star = sea_orm::ActiveValue::Set(self.star.clone());
}
}
` |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Rails 7.1 has introduced a new method in Active Record that can be used to declare normalizations for attribute values.
This can be especially useful for sanitizing user input, ensuring consistent formatting, or cleaning up data from external sources.
We should adopt this approach in Loco to streamline our model definitions and reduce boilerplate code.
Reference:
https://www.bigbinary.com/blog/rails-7-1-adds-activerecord-base-normalizes
Problems to solve: "The normalization is applied when the attribute is assigned or updated, and the normalized value will be persisted to the database. The normalization is also applied to the corresponding keyword argument of finder methods. This allows a record to be created and later queried using unnormalized values."
As part of initial research, this seems to be a better fit for SEA ORM, what do you think?
Beta Was this translation helpful? Give feedback.
All reactions