Skip to content

Commit

Permalink
feat(sqlite): support $random eval operation (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
ifrvn committed Apr 13, 2023
1 parent bcb6e84 commit d24c21d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/sqlite/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deepEqual, Dict, difference, isNullable, makeArray, union } from 'cosmokit'
import { Database, Driver, Eval, executeUpdate, Field, Model, Selection } from '@minatojs/core'
import { Builder, escapeId } from '@minatojs/sql-utils'
import { Builder, escapeId, transformRandom } from '@minatojs/sql-utils'
import { promises as fs } from 'fs'
import init from '@minatojs/sql.js'
import Logger from 'reggol'
Expand Down Expand Up @@ -233,6 +233,7 @@ export class SQLiteDriver extends Driver {

#exec(sql: string, params: any, callback: (stmt: init.Statement) => any) {
try {
sql = sql = transformRandom(sql, 'RANDOM()')
const stmt = this.db.prepare(sql)
const result = callback(stmt)
stmt.free()
Expand Down

0 comments on commit d24c21d

Please sign in to comment.