Skip to content

Commit

Permalink
Use tablestar instead of star when no select specified
Browse files Browse the repository at this point in the history
  • Loading branch information
etienne-dldc committed Sep 1, 2024
1 parent 5f7f072 commit 9651452
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"test:run": "deno test -A --unstable-ffi",
"test:watch": "deno test -A --unstable-ffi --watch",
"bump": "deno run -A jsr:@mys/bump@1",
"update": "deno run --allow-read=. --allow-write=. --allow-net https://deno.land/x/[email protected]/main.ts *.ts deno.jsonc",
"update": "deno run -A jsr:@molt/cli deno.json",
"update:commit": "deno task -q update --commit deno.json",
"check": "deno fmt --check . && deno lint . && deno task test:run"
},
"lint": {
Expand Down
2 changes: 1 addition & 1 deletion src/Query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ function buildSelectNode(
: builder.SelectStmt.FromTable(internal.from.name),
resultColumns: state.select
? Utils.arrayToNonEmptyArray(state.select)
: [builder.ResultColumn.Star()],
: [builder.ResultColumn.TableStar(internal.from)],
where: state.where?.ast,
groupBy: state.groupBy
? {
Expand Down
4 changes: 2 additions & 2 deletions tests/advanced.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ Deno.test("Find all users with only task 1 & 2 using subquery in expression", ()
count(users_tasks.task_id) == 2
)
SELECT
*
users.*
FROM
users
WHERE
Expand Down Expand Up @@ -376,7 +376,7 @@ Deno.test("Find all users with no tasks", () => {
users_tasks.user_id
)
SELECT
*
users.*
FROM
users
WHERE
Expand Down
2 changes: 1 addition & 1 deletion tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ Deno.test("Query simple CTE", () => {
GROUP BY users.name
LIMIT 10
)
SELECT * FROM cte_id2
SELECT cte_id2.* FROM cte_id2
`);
expect(result.params).toEqual(null);
});
Expand Down
8 changes: 4 additions & 4 deletions tests/where.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Deno.test("Simple filter", () => {
const query = tasksDb.tasks.query().filterEqual({ id: "1" }).first();

expect(format(query.sql)).toEqual(sql`
SELECT *
SELECT tasks.*
FROM tasks
WHERE
tasks.id == :_id0
Expand All @@ -32,7 +32,7 @@ Deno.test("Filter twice", () => {
}).first();

expect(format(query.sql)).toEqual(sql`
SELECT *
SELECT tasks.*
FROM tasks
WHERE
tasks.id == :_id0 AND tasks.id == :_id2
Expand Down Expand Up @@ -95,7 +95,7 @@ Deno.test("Filter null value", () => {
.first();

expect(format(query.sql)).toEqual(sql`
SELECT *
SELECT users.*
FROM users
WHERE users.displayName IS NULL
`);
Expand All @@ -110,7 +110,7 @@ Deno.test("Filter multiple values", () => {
}).first();

expect(format(query.sql)).toEqual(sql`
SELECT *
SELECT users.*
FROM users
WHERE users.displayName IS NULL AND users.email == :_id0
`);
Expand Down

0 comments on commit 9651452

Please sign in to comment.