Keep the whole text when a non-string value is concatenated with a string (`+`, `CONCAT`)

Aperta
#2,014 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
30/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
java, postgresql
Ambito
databases

Direzione di ricerca

No file is named, so start where + and CONCAT are translated into PostgreSQL SQL and where the width of a string result is derived from its operands' classes (NUMERIC[p,s], DOUBLE, COLOR, INTERVAL); that width computation is what truncates the text. Reproduce with the lsf script from the report posted to /eval and compare against the table of failing expressions. Done means all listed cases return the full text, an unrepresentable value such as the GROUP SUM case raises an error instead of being cut, and a regression test covers the cases.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug
Description

On PostgreSQL, + and CONCAT can silently discard the end of their result when an operand is not a string. For the bounded results shown here, NUMERIC[p,s] contributes p characters to the width of the result, DOUBLE contributes 20, and COLOR and INTERVAL contribute 8 each. With a literal separator, CONCAT also counts its width between the operands. A decimal point or a minus sign can take a numeric value beyond its share of the width, and a DOUBLE can take more than 20 characters. When the combined text exceeds the width of the result, the excess is cut without an error or a warning. The lost characters can belong to the value or to the text that follows it, and a chain of + can lose them at an intermediate step.

This self-contained script is sent to /eval:

price = DATA LOCAL NUMERIC[5,2] ();
run() {
    price() <- 123.45;
    EXPORT FROM
        rate = 'rate: ' + 1.5,
        price = 'price: ' + price(),
        negative = 'negative: ' + (-price()),
        line = (CONCAT ' | ', price(), price(), 'end'),
        explicit = 'price: ' + STRING(price());
}

Response (7.0-SNAPSHOT master and 6.3-SNAPSHOT, PostgreSQL 18):

{"rate":"rate: 1.","price":"price: 123.4","negative":"negative: -123.","line":"123.45 | 123.45 | e","explicit":"price: 123.45"}

Expected: rate: 1.5, price: 123.45, negative: -123.45, 123.45 | 123.45 | end.

More results of the same kind:

Expression Result Expected
'r=' + 0.25 r=0.2 r=0.25
'r=' + (-0.25) r=-0. r=-0.25
1.5 + ' end' 1.5 en 1.5 end
'sum=' + (GROUP SUM price(i)), the class of the sum is NUMERIC[5,2], the total is 1234.50 sum=1234. sum=1234.50
'd=' + value() + '!', value is a DOUBLE property holding 1.2345678901234568e-05 d=1.2345678901234568e-! d=1.2345678901234568e-05!
'c=' + RGB(0, 0, 0) + '!' c=-1677721! c=-16777216!
'i=' + interval(2026_01_05, 2026_01_10) + '!' i=17675712! i=1767571200000.1768003200000!

MESSAGE shows the cut text: MESSAGE CONCAT '|', price(), price(), price(), price(), 'end'; shows 123.45|123.45|123.45|123.45, with no sign that |end is missing.

A wider string operand leaves room for the value: STRING[10]('r=') + 0.25 is r=0.25. In the probes 'price: ' + STRING(price()), a CONCAT with a TEXT operand and 'price: ${price()}' kept the whole value. Converting a result that is already cut to STRING or TEXT does not bring its end back.

Reason

The value in the result is wrong, not just shorter: 123.4 and -123. are valid numbers, so nothing tells the reader that a digit is missing, and in a CONCAT of several values the lost end reads as "there was nothing more". In the reported case, the last lines of a diagnostic message disappeared.

Fix

Preserve the complete text of numbers and of the other non-string values, the separators and the surrounding text. If a value that does not fit its class (the GROUP SUM case) cannot be represented, report an error instead of returning a part of it.

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.