Skip to content

Commit 1b8922f

Browse files
committed
feat: improve MySQL CONCAT function argument type handling and add an end-to-end test case.
1 parent ce83d3f commit 1b8922f

File tree

7 files changed

+151
-2
lines changed

7 files changed

+151
-2
lines changed

internal/endtoend/testdata/mysql_concat_type/mysql/db.go

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/endtoend/testdata/mysql_concat_type/mysql/models.go

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/endtoend/testdata/mysql_concat_type/mysql/query.sql.go

Lines changed: 69 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
-- name: GetTickets :many
2+
SELECT
3+
id,
4+
title,
5+
ticket_status,
6+
created_at
7+
FROM ticket
8+
WHERE (sqlc.narg(start_time) IS NULL OR created_at >= sqlc.narg(start_time))
9+
AND (sqlc.narg(title_prefix) IS NULL OR title LIKE CONCAT(sqlc.narg(title_prefix), '%'))
10+
ORDER BY id ASC;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CREATE TABLE ticket
2+
(
3+
id BIGINT AUTO_INCREMENT PRIMARY KEY,
4+
ticket_status TINYINT NOT NULL,
5+
title VARCHAR(255) NOT NULL,
6+
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
7+
);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"version": "2",
3+
"sql": [
4+
{
5+
"engine": "mysql",
6+
"queries": "query.sql",
7+
"schema": "schema.sql",
8+
"gen": {
9+
"go": {
10+
"package": "mysql_concat_type",
11+
"out": "mysql"
12+
}
13+
}
14+
}
15+
]
16+
}

internal/engine/dolphin/stdlib.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,10 +415,10 @@ func defaultSchema(name string) *catalog.Schema {
415415
Name: "CONCAT",
416416
Args: []*catalog.Argument{
417417
{
418-
Type: &ast.TypeName{Name: "any"},
418+
Type: &ast.TypeName{Name: "text"},
419419
},
420420
{
421-
Type: &ast.TypeName{Name: "any"},
421+
Type: &ast.TypeName{Name: "text"},
422422
Mode: ast.FuncParamVariadic,
423423
},
424424
},

0 commit comments

Comments
 (0)