https://kotlinlang.org logo
#exposed
Title
# exposed
e

exidnus

02/09/2020, 4:39 PM
Hello. I use h2, have varchar column and want update column: concatenate current value and additional value. For example, current value of column ",1,2," and I want add "3," and get finally ",1,2,3,". I try to use code like this from documentation (but in documentation it's integer column).
Copy code
Lessons.update(where = { Lessons.id eq lessonId }) {
            with(SqlExpressionBuilder) {
                it.update(column, column + "$entityId$ELEM_COLLECTION_SEPARATOR")
            }
        }
But it throws exception
Copy code
Caused by: org.h2.jdbc.JdbcSQLFeatureNotSupportedException: Feature not supported: "VARCHAR +"; SQL statement:
UPDATE LESSONS SET CAME_STUDENTS=LESSONS.CAME_STUDENTS+? WHERE LESSONS.ID = ?
Exposed version 0.20.3. Oh, sorry to bother, I understood, that I should just use SqlExpressionBuilder.concat(column, stringLiteral("$entityId$ELEM_COLLECTION_SEPARATOR"))
t

tapac

02/10/2020, 11:17 AM
Please use
concat
function like:
Copy code
it[column] = concat(column, Lessons.id, stringLiteral(ELEM_COLLECTION_SEPARATOR))
33 Views