-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Report hasn't been filed before.
- 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?
N/A
Other packages
No response
Describe the Bug
The SQL string returned from the toSQL
method does not match the return type of the query. Column aliases from the schema or defined in SELECT and RETURNING clauses are ignored. Examples:
const prices = sqliteTable('prices', {
id: int('id').primaryKey({ autoIncrement: true }),
productId: int('item_id').notNull(),
price: real('price').notNull(),
});
// Aliases from the schema are not processed
const inferred1 = db.select().from(prices)['_']['result'];
// type: { id: number; productId: number; price: number; }[]
const sql1 = db.select().from(prices).toSQL();
// returned: "select \"id\", \"item_id\", \"price\" from \"prices\""
// Explicit aliases are ignored too
const inferred2 = db.select({ productId: prices.productId }).from(prices)['_']['result'];
// type: { productId: number; }[]
const sql2 = db.select({ productId: prices.productId }).from(prices).toSQL();
// returned: "select \"item_id\" from \"prices\""
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working