-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Handle the bytea data received to be stored correctly in the database. #35
base: main
Are you sure you want to change the base?
Fix Handle the bytea data received to be stored correctly in the database. #35
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add tests.
@@ -0,0 +1,8 @@ | |||
package net.wiringbits.spra.admin.models | |||
|
|||
trait FieldValue[T] extends Serializable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to extend Serializable? a common pattern is sealed trait FieldValue[T] extends Product with Serializable
.
Also, do we expect anyone to extend this class outside of this file? otherwise, this must be a sealed trait.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The data is received as a string. When dealing with a column of type bytea, storing the value as a string will result in incorrect information. Therefore, it is necessary to convert the string to an Array[Byte] (hence the Serializable) to store it correctly.
In the other PR, I was advised that it would be better to create a custom trait that extends Scala's Serializable to be more descriptive and specific with typing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there anything requiring us to make this Serializable? this is usually a bad idea and 99% of the times we shall prefer custom codecs.
Handle the bytea data received to be stored correctly in the database.