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

オープン
#2,014 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
30/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java, postgresql
領域
databases

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Java
スター
214
フォーク
46
PR マージ指標
30日以内にマージされた PR はありません

環境構築

  • Dockerfile または Docker Compose ファイルあり
  • プルリクエストのテンプレートなし
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

lsfusion/platform のほかの issue

lsfusion/platform の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。