Writing a string longer than STRING[n] into a data property: a single value is silently cut, a set-based write fails with a raw PostgreSQL "value too long" error

Open
#1,882 0 comments 0 reactions 1 assignee View on GitHub

@danchanka is already working on this.

Since Oct 16, 2026.

Assessment

This issue has not been assessed yet.

Description

bug
Description

A string value longer than the length of the target STRING[n] / ISTRING[n] data property is handled differently depending on how it is written:

  • a single value — a parameterless property, or one object given as a value — is cut to n characters without any message;
  • a write over a set of objects — an assignment with parameters, a FOR merged into one change, or one constant written WHERE to several objects — is not cut. It fails with the PostgreSQL error value too long for type character varying(n): at the assignment when the value is computed per row, or later at APPLY when one constant is written to several objects (the session keeps the uncut value until then).

The explicit conversion STRING[n](...) cuts the value to n characters.

Reproducer (platform 7.0-SNAPSHOT, PostgreSQL 18, run through /eval):

s5 = DATA LOCAL STRING[5] ();
s5k = DATA LOCAL STRING[5] (INTEGER);
p = DATA LOCAL STRING[4] (INTEGER);
q = DATA LOCAL STRING[4] (INTEGER);

run() {
    s5() <- 'abcdefgh';                                   // 'abcde' - cut
    s5k(1) <- 'abcdefgh';                                 // 'abcde' - cut
    s5k(INTEGER i) <- 'abcdefgh' WHERE iterate(i, 1, 3);  // s5k(1) reads back as 'abcdefgh' - 8 characters kept in the session
    p(INTEGER i) <- 'abcd' WHERE iterate(i, 1, 3);
    q(INTEGER i) <- 'efgh' WHERE iterate(i, 1, 3);
    s5k(INTEGER i) <- p(i) + q(i) WHERE iterate(i, 1, 3); // ERROR: value too long for type character varying(5)
    EXPORT FROM a = s5(), b = s5k(1);
}

With a stored property (name = DATA ISTRING[100] (Item)):

probeNew = DATA LOCAL BOOLEAN (Item);
run() {
    NEWSESSION {
        NEW a = Item { probeNew(a) <- TRUE; }
        NEW b = Item { probeNew(b) <- TRUE; }
        name(Item i) <- '<101 characters>' WHERE probeNew(i); // passes: the session reads the name back with length 101
        APPLY;                                                // ERROR: value too long for type character varying(100)
    }
}

and name(Item i) <- '<101 characters>' + STRING(i) WHERE probeNew(i); fails already at the assignment with the same error.

Expected: one rule for every write, independent of whether the value goes to one object or to a set — either the value is cut to n the way the explicit conversion cuts it, or the write is rejected with a platform error that names the property and the length instead of a database error.

Fix

Either apply the conversion to the declared string class in the set-based write path (session table and apply), the way it is applied to a single value and by the conversion operator, or check the length in both paths and raise a platform error naming the property.

Reason

A single value is read into memory and converted to the property's class before it is stored; a set-based change is written by a database query into a session table — and at apply into the stored table — whose column has the declared length, without any conversion, so the database rejects the row. The two paths were never aligned, and the error that reaches the developer is the raw database message.

Dominant language
Java
Stars
214
Forks
46
PR merge metrics
No merged PRs in 30d

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from lsfusion/platform

All issues in lsfusion/platform

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.