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

Column ByteArray should not require a length #618

Closed
gertvdijk opened this issue Aug 5, 2019 · 1 comment
Closed

Column ByteArray should not require a length #618

gertvdijk opened this issue Aug 5, 2019 · 1 comment

Comments

@gertvdijk
Copy link

IIUC, the Column<ByteArray> type is mapped to PostgreSQL's bytea column type. It is variable length and does not even have a length attribute. In Exposed, however I'm required to provide a length as parameter:

val data: Column<ByteArray> = binary("data", <length-parameter>)

which is then ignored, because I can insert ByteArrays with a longer value than specified, at least in Batch Insert. This is all quite confusing for me.

Suggestions:

  • make it an optional parameter. (other dialects also don't always require you to specify a length.)
  • if specified, validate the data before passing it to the database? (not sure if this is what you want in Exposed, but it seems reasonable as it also validates the type.)
  • if specified, either
    • produce a log statement that the length specifier is not enforced/handled by this dialect. OR
    • set a CHECK constraint to enforce the maximum length in the database
@Ingwersaft
Copy link

@gertvdijk, @Tapac, @hichem-fazai: After the merge this can be closed I think :)

@Tapac Tapac closed this as completed Feb 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants