drizzle-team / drizzle-team/drizzle-orm

[BUG]: missing asterisk in querybuilder select()

Open
#4,741 1 comment 0 reactions 0 assignees View on GitHub
bug db/mysql
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### Report hasn't been filed before.

- [x] I have verified that the bug I'm about to report hasn't been filed before.

### What version of `drizzle-orm` are you using?

0.44.2

### What version of `drizzle-kit` are you using?

0.31.4

### Other packages

_No response_

### Describe the Bug

What is the desired behavior?
- I want to create a complex query with drizzle querybuilder (`import { QueryBuilder } from 'drizzle-orm/mysql-core'`). This Db is not managed by drizzle.

What is the undesired behavior?
- asterisk is missing in the select. Query is incomplete.
- Example below currently return this
```
with `event` as (select 1 as `c` from events_table) select from events
```

What are the steps to reproduce it?

```typescript
import { QueryBuilder } from 'drizzle-orm/mysql-core'
import { sql } from 'drizzle-orm'

const queryBuilder = new QueryBuilder()
const subquery = queryBuilder.$with('events').as(
queryBuilder.select({
contact: sql.raw('1').as('c'),
}).from(sql.raw(`events_table`)),
)
const query = queryBuilder.with(subquery).select()
.from(sql.raw(`events`))
console.log('Correct SQL:', query.toSQL().sql === 'with `events` as (select 1 as `c` from events_table) select * from events')
console.log('Incorrect SQL:', query.toSQL().sql === 'with `events` as (select 1 as `c` from events_table) select from events')
```

What is the desired result?
- The query is not incomplete and has the asterisk after the second select

What database engine are you using? Are you using a specific cloud provider? Which one?
- idk, maybe it is only in mysql

If this is a bug related to types: What Typescript version are you using? What's the content of your tsconfig.json file?
- I do not think this has anything to do with typescript

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.