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

Aperta
#1,882 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@danchanka ci sta già lavorando.

Dal 16/10/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

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.

Lingua principale
Java
Stelle
214
Fork
46
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

  • Include un Dockerfile o un file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di lsfusion/platform

Tutte le issue di lsfusion/platform

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.