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

fix(sqlite): passing undefined value, fix debug #63

Merged
merged 1 commit into from
Dec 15, 2023
Merged
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
8 changes: 4 additions & 4 deletions packages/sqlite/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,10 @@ export class SQLiteDriver extends Driver {
const stmt = this.db.prepare(sql)
const result = callback(stmt)
stmt.free()
logger.debug('> %s', sql)
logger.debug('> %s', sql, params)
return result
} catch (e) {
logger.warn('> %s', sql)
logger.warn('> %s', sql, params)
throw e
}
}
Expand Down Expand Up @@ -375,7 +375,7 @@ export class SQLiteDriver extends Driver {
const assignment = updateFields.map((key) => `${escapeId(key)} = ?`).join(',')
const query = Object.fromEntries(indexFields.map(key => [key, row[key]]))
const filter = this.sql.parseQuery(query)
this.#run(`UPDATE ${escapeId(table)} SET ${assignment} WHERE ${filter}`, updateFields.map((key) => row[key]))
this.#run(`UPDATE ${escapeId(table)} SET ${assignment} WHERE ${filter}`, updateFields.map((key) => row[key] ?? null))
return 1
}

Expand All @@ -399,7 +399,7 @@ export class SQLiteDriver extends Driver {
data = this.sql.dump(model, data)
const keys = Object.keys(data)
const sql = `INSERT INTO ${escapeId(table)} (${this.#joinKeys(keys)}) VALUES (${Array(keys.length).fill('?').join(', ')})`
return this.#run(sql, keys.map(key => data[key]), () => this.#get(`SELECT last_insert_rowid() AS id`))
return this.#run(sql, keys.map(key => data[key] ?? null), () => this.#get(`SELECT last_insert_rowid() AS id`))
}

async create(sel: Selection.Mutable, data: {}) {
Expand Down