Avoid unnecessary double wrapping of SELECT statement when used as single function parameter.
This commit is contained in:
parent
22b2901336
commit
d197956271
16 changed files with 97 additions and 77 deletions
|
|
@ -104,18 +104,18 @@ func TestExpressionOperators(t *testing.T) {
|
|||
SELECT all_types.'integer' IS NULL AS "result.is_null",
|
||||
all_types.date_ptr IS NOT NULL AS "result.is_not_null",
|
||||
(all_types.small_int_ptr IN (?, ?)) AS "result.in",
|
||||
(all_types.small_int_ptr IN ((
|
||||
(all_types.small_int_ptr IN (
|
||||
SELECT all_types.'integer' AS "all_types.integer"
|
||||
FROM test_sample.all_types
|
||||
))) AS "result.in_select",
|
||||
)) AS "result.in_select",
|
||||
(CURRENT_USER()) AS "result.raw",
|
||||
(? + COALESCE(all_types.small_int_ptr, 0) + ?) AS "result.raw_arg",
|
||||
(? + all_types.integer + ? + ? + ? + ?) AS "result.raw_arg2",
|
||||
(all_types.small_int_ptr NOT IN (?, ?, NULL)) AS "result.not_in",
|
||||
(all_types.small_int_ptr NOT IN ((
|
||||
(all_types.small_int_ptr NOT IN (
|
||||
SELECT all_types.'integer' AS "all_types.integer"
|
||||
FROM test_sample.all_types
|
||||
))) AS "result.not_in_select"
|
||||
)) AS "result.not_in_select"
|
||||
FROM test_sample.all_types
|
||||
LIMIT ?;
|
||||
`, "'", "`", -1), int64(11), int64(22), 78, 56, 11, 22, 11, 33, 44, int64(11), int64(22), int64(2))
|
||||
|
|
|
|||
|
|
@ -278,7 +278,7 @@ ON DUPLICATE KEY UPDATE id = (id + ?),
|
|||
|
||||
err := SELECT(Link.AllColumns).
|
||||
FROM(Link).
|
||||
WHERE(Link.ID.EQ(Int(int64(randId)).ADD(Int(11)))).
|
||||
WHERE(Link.ID.EQ(Int32(randId).ADD(Int(11)))).
|
||||
Query(db, &newLinks)
|
||||
|
||||
require.NoError(t, err)
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ func TestUpdateWithModelData(t *testing.T) {
|
|||
stmt := Link.
|
||||
UPDATE(Link.AllColumns).
|
||||
MODEL(link).
|
||||
WHERE(Link.ID.EQ(Int(int64(link.ID))))
|
||||
WHERE(Link.ID.EQ(Int32(link.ID)))
|
||||
|
||||
expectedSQL := `
|
||||
UPDATE test_sample.link
|
||||
|
|
@ -131,7 +131,7 @@ SET id = ?,
|
|||
description = ?
|
||||
WHERE link.id = ?;
|
||||
`
|
||||
testutils.AssertStatementSql(t, stmt, expectedSQL, int32(201), "http://www.duckduckgo.com", "DuckDuckGo", nil, int64(201))
|
||||
testutils.AssertStatementSql(t, stmt, expectedSQL, int32(201), "http://www.duckduckgo.com", "DuckDuckGo", nil, int32(201))
|
||||
|
||||
testutils.AssertExec(t, stmt, db)
|
||||
requireLogged(t, stmt)
|
||||
|
|
@ -152,7 +152,7 @@ func TestUpdateWithModelDataAndPredefinedColumnList(t *testing.T) {
|
|||
stmt := Link.
|
||||
UPDATE(updateColumnList).
|
||||
MODEL(link).
|
||||
WHERE(Link.ID.EQ(Int(int64(link.ID))))
|
||||
WHERE(Link.ID.EQ(Int32(link.ID)))
|
||||
|
||||
var expectedSQL = `
|
||||
UPDATE test_sample.link
|
||||
|
|
@ -161,9 +161,8 @@ SET description = NULL,
|
|||
url = 'http://www.duckduckgo.com'
|
||||
WHERE link.id = 201;
|
||||
`
|
||||
//fmt.Println(stmt.DebugSql())
|
||||
|
||||
testutils.AssertDebugStatementSql(t, stmt, expectedSQL, nil, "DuckDuckGo", "http://www.duckduckgo.com", int64(201))
|
||||
testutils.AssertDebugStatementSql(t, stmt, expectedSQL, nil, "DuckDuckGo", "http://www.duckduckgo.com", int32(201))
|
||||
|
||||
testutils.AssertExec(t, stmt, db)
|
||||
requireLogged(t, stmt)
|
||||
|
|
@ -181,7 +180,7 @@ func TestUpdateWithModelDataAndMutableColumns(t *testing.T) {
|
|||
stmt := Link.
|
||||
UPDATE(Link.MutableColumns).
|
||||
MODEL(link).
|
||||
WHERE(Link.ID.EQ(Int(int64(link.ID))))
|
||||
WHERE(Link.ID.EQ(Int32(link.ID)))
|
||||
|
||||
var expectedSQL = `
|
||||
UPDATE test_sample.link
|
||||
|
|
@ -192,7 +191,7 @@ WHERE link.id = 201;
|
|||
`
|
||||
//fmt.Println(stmt.DebugSql())
|
||||
|
||||
testutils.AssertDebugStatementSql(t, stmt, expectedSQL, "http://www.duckduckgo.com", "DuckDuckGo", nil, int64(201))
|
||||
testutils.AssertDebugStatementSql(t, stmt, expectedSQL, "http://www.duckduckgo.com", "DuckDuckGo", nil, int32(201))
|
||||
testutils.AssertExec(t, stmt, db)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue