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

Đang mở
#2,014 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
30/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java, postgresql
Lĩnh vực
databases

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Java
Star
214
Fork
46
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

  • Có Dockerfile hoặc tệp Docker Compose
  • Không có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của lsfusion/platform

Tất cả issue của lsfusion/platform

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.