Skip to content
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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Antonio171003
Copy link
Contributor

Handle the bytea data received to be stored correctly in the database.

Copy link
Contributor

@AlexITC AlexITC left a 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 {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants