Skip to content

\NUL values not allowed in the middle of Sqlite texts #921

@NorfairKing

Description

@NorfairKing

I got this test failure in one of my own projects that uses persistent-sqlite:

    -   expected: "h\910325\NULL\1073793\562934"
        but got: "h\910325"

Given that something goes wrong with a null byte, I figured that there was probably something involving C code going wrong.

The tests in persistent:test:test don't test for text values with nulls:

arbText :: Gen Text
arbText =
T.pack
. filter ((`notElem` forbidden) . generalCategory)
. filter (<= '\xFFFF') -- only BMP
. filter (/= '\0') -- no nulls
. T.unpack
<$> arbitrary
where forbidden = [NotAssigned, PrivateUse]

This was supposedly fixed in #310 but when
but when I comment out that line (line 192 in persistent-test/src/Init.hs), I get this test failure in persistent-sqlite:test:test:

       expected: ("text","@\NUL7")
        but got: ("text","@")

While fixing this problem, would it be possible to also remove the other filters for arbText:

before:

arbText :: Gen Text                                                                                                   
arbText =                                                                                                             
     T.pack                                                                                                           
  .  filter ((`notElem` forbidden) . generalCategory)                                                                 
  .  filter (<= '\xFFFF') -- only BMP                                                                                 
  .  filter (/= '\0')     -- no nulls                                                                              
  .  T.unpack                                                                                                         
  <$> arbitrary                                                                                                       
  where forbidden = [NotAssigned, PrivateUse]    

after:

arbText :: Gen Text
arbText = arbitrary

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions