Fix Handle the bytea data received to be stored correctly in the database.#35
Fix Handle the bytea data received to be stored correctly in the database.#35Antonio171003 wants to merge 5 commits intowiringbits:mainfrom
Conversation
| @@ -0,0 +1,8 @@ | |||
| package net.wiringbits.spra.admin.models | |||
|
|
|||
| trait FieldValue[T] extends Serializable { | |||
There was a problem hiding this comment.
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.
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.
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.