@m1212e/rumble 0.16.15 → 0.16.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/index.cjs +6 -2
- package/out/index.cjs.map +1 -1
- package/out/index.mjs +6 -2
- package/out/index.mjs.map +1 -1
- package/package.json +1 -1
package/out/index.mjs
CHANGED
|
@@ -917,6 +917,10 @@ async function initSearchIfApplicable(input) {
|
|
|
917
917
|
const dbName = (await input.db.execute(sql`SELECT current_database()`)).rows[0].current_database;
|
|
918
918
|
await input.db.execute(sql.raw(`ALTER DATABASE ${dbName} SET pg_trgm.similarity_threshold = ${threshold};`));
|
|
919
919
|
}
|
|
920
|
+
if (input.search?.cpu_operator_cost) {
|
|
921
|
+
if (typeof input.search.cpu_operator_cost !== "number") throw new Error(`CPU operator cost must be a number`);
|
|
922
|
+
if (input.search.cpu_operator_cost <= 0) throw new Error(`CPU operator cost must be a positive number`);
|
|
923
|
+
}
|
|
920
924
|
}
|
|
921
925
|
/**
|
|
922
926
|
* Performs adjustments to the query args to issue a full text search in case the
|
|
@@ -1242,8 +1246,8 @@ const createQueryImplementer = ({ db, schemaBuilder, search, whereArgImplementer
|
|
|
1242
1246
|
if (mappedArgs.orderBy) filter.orderBy = mappedArgs.orderBy;
|
|
1243
1247
|
const queryInstance = query(filter);
|
|
1244
1248
|
if (filter.columns) queryInstance.columns = filter.columns;
|
|
1245
|
-
if (search?.cpu_operator_cost) return db.transaction(async (tx) => {
|
|
1246
|
-
if (isPostgresDB(tx)) await tx.execute(sql`SET
|
|
1249
|
+
if (search?.enabled && args.search && args.search.length > 0 && search?.cpu_operator_cost) return db.transaction(async (tx) => {
|
|
1250
|
+
if (isPostgresDB(tx)) await tx.execute(sql.raw(`SET cpu_operator_cost = ${search.cpu_operator_cost};`));
|
|
1247
1251
|
else console.info("Database dialect is not postgresql, cannot set cpu_operator_cost.");
|
|
1248
1252
|
return tx.query[table].findMany(queryInstance);
|
|
1249
1253
|
});
|