Skip to content

Commit c6c4147

Browse files
author
James Cor
committed
use max precision decimal for comparison
1 parent d8ccade commit c6c4147

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

enginetest/queries/script_queries.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,26 @@ FROM task_instance INNER JOIN job ON job.id = task_instance.queued_by_job_id INN
616616
Query: "SELECT '123.456' in (123.456);",
617617
Expected: []sql.Row{{true}},
618618
},
619+
{
620+
Query: "SELECT 123.456 in (123.456);",
621+
Expected: []sql.Row{{true}},
622+
},
623+
{
624+
Query: "SELECT 123.45 in (123.4);",
625+
Expected: []sql.Row{{false}},
626+
},
627+
{
628+
Query: "SELECT 123.45 in (123.5);",
629+
Expected: []sql.Row{{false}},
630+
},
631+
{
632+
Query: "SELECT '123.45a' in (123.5);",
633+
Expected: []sql.Row{{false}},
634+
},
635+
{
636+
Query: "SELECT '123.45a' in (123.4);",
637+
Expected: []sql.Row{{false}},
638+
},
619639
{
620640
SkipResultCheckOnServerEngine: true, // TODO: warnings do not make it to server engine
621641
Query: "SELECT '123.456ABC' in (123.456);",

sql/types/utils.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,8 @@ func GetCompareType(left, right sql.Type) sql.Type {
3838
return LongBlob
3939
}
4040
if IsNumber(left) || IsNumber(right) {
41-
if IsDecimal(left) {
42-
return left
43-
}
44-
if IsDecimal(right) {
45-
return right
41+
if IsDecimal(left) || IsDecimal(right) {
42+
return InternalDecimalType
4643
}
4744
if IsFloat(left) || IsFloat(right) {
4845
return Float64

0 commit comments

Comments
 (0)