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

Solution for Text values potentially containing '\NUL' #135

Open
googleson78 opened this issue Jan 4, 2024 · 0 comments
Open

Solution for Text values potentially containing '\NUL' #135

googleson78 opened this issue Jan 4, 2024 · 0 comments

Comments

@googleson78
Copy link

Currently we allow encoding any Text value, including ones that contain '\NUL', via ToField.

This is a theoretical issue because PG actually doesn't allow strings to contain the 0 code point, meaning that we can end up having a valid Text value which is not actually storable in PG - described in the end of this section of the manual

It is also a practical issue because generating text via Arbitrary easily leads to Text with '\NUL\ in it, meaning that we can't use Arbitrary Text out of the box to run some property tests which do insertion into PG.

Is there some way to improve this situation?

There could potentially be a newtype wrapper over Text which only allows for Texts which don't contain '\NUL', but that still means users have to write their own Arbitrary, since (I assume) this library won't depend on QuickCheck and the like. This will at least solve the theoretical concern of trying to insert a Text with '\NUL' in it and seeing it fail, if the ordinary Text instance gets gradually phased out (which there's no easy way to do right now at the moment, afaik).

@googleson78 googleson78 changed the title Solution for Text potentially containing '\NUL' Solution for Text values potentially containing '\NUL' Jan 4, 2024
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

No branches or pull requests

1 participant