question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

binary type doesn't honor max length

See original GitHub issue

The binary fixed-length type doesn’t seem to honor the provided length: no error is thrown, no warning is logged, and the image isn’t even silently trimmed to the specified maximum number of bytes.

Pseudocode for table:

object Images : IntIdTable() {
    private val image: Column<ByteArray> = binary("image", 10)

    fun create(image: ByteArray): Int = transact {
        insertAndGetId { it[this.image] = image }.value
    }

    fun read(id: Int): ByteArray = transact {
        select { Images.id eq id }.first()[image]
    }
}

Pseudocode for test:

class ImagesTest : FunSpec({
    test("size") {
        val id = Images.create("wallpaper.jpg") // A file which is too large, say 400,000 bytes.
        println("Size: ${Images.read(id).size}") // Prints 400,000.
    }
})

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
apprmecommented, Sep 15, 2020

Is it expected that select queries where value in where clause exceeds column length limit throw the exception as well?

As for me throwing exception on insert is better than silently truncating the value. But throwing on select… I am not so sure.

java.lang.IllegalArgumentException: Value 'impersonate:eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJObXBRajJPNmZmZlgyblR2MW5GVFVNIiwicyI6ZmFsc2UsInQiOmZhbHNlLCJpc3MiOiJEZWxpZ2h0ZXggR21iSCIsImV4cCI6MTYwMDA4Mzg2NSwiaWF0IjoxNTk5NDc5MDY1LCJodyI6IjlJUnk5SVZKS2p5aCJ9._0O1bbWxJ8ot7JQnsqoJpqrsg1GZMzUtjNltRAms4Xc' can't be stored to database column because exceeds length (255)
    at org.jetbrains.exposed.sql.VarCharColumnType.notNullValueToDB (ColumnType.kt:541)
    at org.jetbrains.exposed.sql.IColumnType$DefaultImpls.valueToDB (ColumnType.kt:37)
    at org.jetbrains.exposed.sql.ColumnType.valueToDB (ColumnType.kt:71)
    at org.jetbrains.exposed.sql.statements.api.PreparedStatementApi$DefaultImpls.fillParameters (PreparedStatementApi.kt:13)
    at org.jetbrains.exposed.sql.statements.jdbc.JdbcPreparedStatementImpl.fillParameters (JdbcPreparedStatementImpl.kt:9)
    at org.jetbrains.exposed.sql.statements.Statement.executeIn$exposed_core (Statement.kt:53)
    at org.jetbrains.exposed.sql.Transaction.exec (Transaction.kt:129)
    at org.jetbrains.exposed.sql.Query.count (Query.kt:246)
0reactions
asule90commented, Apr 1, 2021

i still got this issue on postgresql.

Screenshot from 2021-04-01 18-19-05

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does DataAnnotation MaxLength(8192) not work?
it's also a kind of binary data type but its maximum length is about 2GB. it stores all kind of bytes like as...
Read more >
54206: Column octet length includes terminating null byte
For variable-length character or binary types, this is the maximum length in bytes. This value does not include the null terminator.
Read more >
The Difference between Binary and Integer (And Why You ...
We have a chart in our presentation on the new RPG free format declarations that contains the comment "DO NOT USE!!!" next to...
Read more >
Binary data types - Sybase Infocenter
BINARY Binary data of length length bytes. If length is omitted, the default is 1 byte. The maximum size allowed is 255 bytes....
Read more >
8, 16, 32, 64 & 128-bit Integer Limits - Video & Lesson Transcript
Learn to define integer data bit size and limits. ... What are Binary Integers (BITs)?; Integer Data Types and Sizes; 8-Bit Integer Limit ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found