| 406 | } |
| 407 | |
| 408 | func TestQuery_CommaInUpdate(t *testing.T) { |
| 409 | // Realistic UPDATE with conditional SET fields |
| 410 | name := "Alice" |
| 411 | active := true |
| 412 | |
| 413 | set := Q() |
| 414 | if name != "" { |
| 415 | set.Comma("name = ?", name) |
| 416 | } |
| 417 | set.Comma("active = ?", active) |
| 418 | |
| 419 | q := Q().Space("UPDATE users SET ?", set). |
| 420 | Space("WHERE id = ?", 123) |
| 421 | |
| 422 | sql, args, err := q.ToSQL() |
| 423 | require.NoError(t, err) |
| 424 | require.Equal(t, "UPDATE users SET name = $1, active = $2 WHERE id = $3", sql) |
| 425 | require.Equal(t, []any{"Alice", true, 123}, args) |
| 426 | } |
| 427 | |
| 428 | func TestQuery_CommaWithNullHandling(t *testing.T) { |
| 429 | // UPDATE with NULL assignment |