beam icon indicating copy to clipboard operation
beam copied to clipboard

SQLite BINARY field should map to a byte array.

Open mrehayden1 opened this issue 6 years ago • 5 comments

Binary is intended for string data without a collation.

From https://www.sqlite.org/datatype3.html:

  1. Collating Sequences When SQLite compares two strings, it uses a collating sequence or collating function (two words for the same thing) to determine which string is greater or if the two strings are equal. SQLite has three built-in collating functions: BINARY, NOCASE, and RTRIM.

BINARY - Compares string data using memcmp(), regardless of text encoding. ...

mrehayden1 avatar Jan 03 '19 12:01 mrehayden1

What does it do now?

tathougies avatar Jan 06 '19 00:01 tathougies

It maps to an integer.

This actually looks like an issue in the implementation of SQL92 if it's implementing the BINARY collation on text string fields like VARCHAR. I'm not sure though.

See the note here also: http://hackage.haskell.org/package/beam-migrate-0.3.2.1/docs/src/Database.Beam.Migrate.SQL.Tables.html#binary

On Sun, 6 Jan 2019, 00:47 Travis Athougies <[email protected] wrote:

What does it do now?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tathougies/beam/issues/340#issuecomment-451705482, or mute the thread https://github.com/notifications/unsubscribe-auth/AAhbRM09uA1JuA2oKvHLh9JfHXD_sfb-ks5vAUe6gaJpZM4ZoBX3 .

mrehayden1 avatar Jan 06 '19 01:01 mrehayden1

Sorry, 92 is the wrong standard. The BINARY type in MySQL might be what has confused me.

mrehayden1 avatar Jan 06 '19 01:01 mrehayden1

binary in beam-migrate refers to the standard BINARY type. I think these should map to ByteString, not Integer.

And then, you're saying we can achieve this behavior on SQLite using the binary collation on strings?

tathougies avatar Jan 08 '19 19:01 tathougies

Consider ShortByteString or other alternative over ByteString if you don't want pinned memory.

3noch avatar Jan 08 '19 19:01 3noch