From d24c21de2139d7bf317fe448936c4dccfe8090d3 Mon Sep 17 00:00:00 2001 From: Frank Date: Thu, 13 Apr 2023 15:55:08 +0800 Subject: [PATCH] feat(sqlite): support $random eval operation (#20) --- packages/sqlite/src/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/sqlite/src/index.ts b/packages/sqlite/src/index.ts index 58130f7c..38a289ae 100644 --- a/packages/sqlite/src/index.ts +++ b/packages/sqlite/src/index.ts @@ -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' @@ -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()