Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update select_test.go #134

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions dialect/sqlite/select_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,41 @@
),
ExpectedSQL: `SELECT id, name FROM users WHERE (("id", "employee_id") IN ((?1, ?2), (?3, ?4)))`,
ExpectedArgs: []any{100, 200, 300, 400},
},

"select with order by and limit": {

Check failure on line 81 in dialect/sqlite/select_test.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default (gci)
Query: sqlite.Select(
sm.Columns("name", "salary"),
sm.From("employees"),
sm.OrderBy("salary DESC"),
sm.Limit(10),
),
ExpectedSQL: `SELECT name, salary FROM employees ORDER BY salary DESC LIMIT 10`,
},

"select with group by and having": {
Query: sqlite.Select(
sm.Columns("department", "AVG(salary)"),
sm.From("employees"),
sm.GroupBy("department"),
sm.Having("AVG(salary) > 50000"),
),
ExpectedSQL: `SELECT department, AVG(salary) FROM employees GROUP BY department HAVING AVG(salary) > 50000`,
},

Check failure on line 100 in dialect/sqlite/select_test.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default (gci)

"select with CTE": {
Query: sqlite.Select(
sm.With("cte", "column1").As(
sqlite.Select(
sm.Columns("column1"),
sm.From("table1"),
),
),
sm.Columns("column1"),
sm.From("cte"),
),
ExpectedSQL: `WITH cte(column1) AS (SELECT column1 FROM table1) SELECT column1 FROM cte`,
},
}

Expand Down
Loading