diff --git a/RELEASE.md b/RELEASE.md index 3cf9dfb..5114d9b 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,5 +1,9 @@ # @teqfw/db: releases +## 0.22.1 + +* Detect `Client_BetterSQLite3` constructor. + ## 0.22.0 * Add the selection DTO for listing queries. diff --git a/doc/selection.md b/doc/selection.md deleted file mode 100644 index 2ebb518..0000000 --- a/doc/selection.md +++ /dev/null @@ -1,83 +0,0 @@ -# The structure of selection DTO - -See `TeqFw_Db_Shared_Dto_List_Selection` module. - -```js -class Dto { - /** @type {Object} */ - filter; - /** @type {TeqFw_Db_Shared_Dto_Order.Dto[]} */ - orderBy; - /** @type {number} */ - rowsLimit; - /** @type {number} */ - rowsOffset; -} -``` - -## filter - -The filter is a hierarchy of conditions and functions. - -```js -const value = '[ string | number | bool ]'; // the value is a constant used in a function -``` - -```js -const alias = 'string'; // the alias is a "column" in a list query and also used in a function -``` - -```js -const func = { - name: 'EQ', // name of the function from the acceptable functions set [ EQ | GTE | GT | LTE | LT | NEQ | LIKE | NOT_LIKE | ILIKE | NOT_ILIKE | IN | NOT_IN | ... ] - params: [{/*[alias|value|func]*/}, {/*[alias|value|func]*/}, /* ... */] // any number of arguments for the function -}; -``` - -```js -const cond = { - with: '[ OR | AND | XOR | NOT ]', // for "NOT" only one entry is acceptable in entries array - items: [/* cond or func */], -}; -``` - -```js -const filter = { /* "cond" or "func" */}; -``` - -The sample: - -```json -{ - "filter": { - "with": "AND", - "entries": [ - { - "name": "GTE", - "params": [{"alias": "user_id"}, {"value": 0}] - }, - { - "name": "LTE", - "params": [{"alias": "user_id"}, {"value": 100}] - }, - { - "with": "OR", - "entries": [ - { - "name": "EQ", - "params": [{"alias": "name"}, {"value": "user1"}] - }, - { - "name": "EQ", - "params": [{"alias": "name"}, {"value": "user2"}] - } - ] - } - ] - } -} -``` - -```sql -SELECT * FROM users WHERE (user_id >= 0) AND (user_id < 100) AND ((name = 'user1') OR (name = 'user2')); -``` \ No newline at end of file diff --git a/package.json b/package.json index c43c40e..0e5bd73 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@teqfw/db", - "version": "0.22.0", + "version": "0.22.1", "description": "TeqFW: DB connectivity.", "scripts": { "test": "./node_modules/mocha/bin/_mocha --recursive './test/mod/**/*.test.mjs'" diff --git a/src/Back/RDb/Trans.mjs b/src/Back/RDb/Trans.mjs index 9f43246..6916a35 100644 --- a/src/Back/RDb/Trans.mjs +++ b/src/Back/RDb/Trans.mjs @@ -37,7 +37,8 @@ export default class TeqFw_Db_Back_RDb_Trans { } isSqlite() { - return this.#trx?.client?.constructor?.name === 'Client_SQLite3'; + const name = this.#trx?.client?.constructor?.name; + return (name === 'Client_SQLite3') || (name === 'Client_BetterSQLite3'); } async commit() { diff --git a/test/man/Back/Mod/Selection.test.mjs b/test/man/Back/Mod/Selection.test.mjs deleted file mode 100644 index ab17c17..0000000 --- a/test/man/Back/Mod/Selection.test.mjs +++ /dev/null @@ -1,66 +0,0 @@ -/** - * The model to populate queries with clauses from selection object. - * (@see TeqFw_Db_Shared_Dto_List_Selection) - */ -import assert from 'assert'; -import {config as cfgTest, container} from '@teqfw/test'; -import {describe, it} from 'mocha'; - -// SETUP ENV - -/** @type {TeqFw_Core_Back_Config} */ -const config = await container.get('TeqFw_Core_Back_Config$'); -config.init(cfgTest.pathToRoot, 'test'); -const cfgDb = config.getLocal('@teqfw/db'); - -/** - * Framework wide RDB connection from DI. This connection is used by event listeners. - * @type {TeqFw_Db_Back_RDb_Connect} - */ -const connFw = await container.get('TeqFw_Db_Back_RDb_IConnect$'); -/** @type {TeqFw_Core_Back_Mod_App_Uuid} */ -const modBackUuid = await container.get('TeqFw_Core_Back_Mod_App_Uuid$'); -await modBackUuid.init(); - - -// GET OBJECT FROM CONTAINER AND RUN TESTS -/** @type {TeqFw_Db_Back_Mod_Selection} */ -const mod = await container.get('TeqFw_Db_Back_Mod_Selection$'); -/** @type {TeqFw_Db_Shared_Dto_List_Selection} */ -const selection = await container.get('TeqFw_Db_Shared_Dto_List_Selection$'); -/** @type {Lp_Cust_Back_Web_Api_Event_List_A_Query} */ -const meta = await container.get('Lp_Cust_Back_Web_Api_Event_List_A_Query$'); - - -describe('TeqFw_Db_Back_Mod_Selection', function () { - - it('can be instantiated', async () => { - assert(typeof mod === 'object'); - }); - - it('parses a filter', async () => { - await connFw.init(cfgDb); - const trx = await connFw.startTransaction(); - try { - const query = meta.build(trx, {bid: 2, lang: 'es'}); - const dto = selection.createDto({ - 'filter': { - 'items': [ - {'name': 'GTE', 'params': [{'alias': 'dateStart'}, {'value': '2024-05-09T08:32:02.462Z'}]}, - {'name': 'LTE', 'params': [{'alias': 'dateStart'}, {'value': '2024-05-09T08:32:02.462Z'}]} - ], 'with': 'AND' - }, - 'orderBy': [{'alias': 'dateStart', 'dir': 'desc'}] - }); - mod.populate(trx, meta, query, dto); - const sql = query.toString(); - assert(sql); - } finally { - await trx.rollback(); - await connFw.disconnect(); - } - - }); - -}); -