@linked-db/linked-ql
Advanced tools
Comparing version 0.2.80 to 0.2.82
@@ -14,3 +14,3 @@ { | ||
"icon": "https://webqit.io/icon.svg", | ||
"version": "0.2.80", | ||
"version": "0.2.82", | ||
"license": "MIT", | ||
@@ -17,0 +17,0 @@ "repository": { |
@@ -141,4 +141,4 @@ # Linked QL | ||
-- Linked QL | ||
SELECT ..., author ~> role ~> name | ||
FROM books | ||
SELECT * FROM books | ||
WHERE author ~> role ~> name = 'admin' | ||
``` | ||
@@ -150,4 +150,4 @@ | ||
-- Linked QL | ||
SELECT ..., author <~ books ~> title | ||
FROM users | ||
SELECT * FROM users | ||
WHERE author <~ books ~> title = 'Beauty and the Beast' | ||
``` | ||
@@ -265,6 +265,19 @@ | ||
## TODO | ||
There's a lot here: | ||
+ Write detailed docs. | ||
+ Upgrade support for MySQL. | ||
+ Implement support for IndexedDB and in-mem. | ||
+ Write detailed tests. | ||
> Much of that could happen sooner with your support! If you'd like to help out, please consider a [sponsorship](https://github.com/sponsors/ox-harris). PRs are also always welcome. | ||
## Issues | ||
To report bugs or request features, please submit an issue to this repository. | ||
## License | ||
MIT. | ||
@@ -271,0 +284,0 @@ |
@@ -163,2 +163,3 @@ | ||
y => y.equals('id', z => z.literal(this.id)), | ||
// the following is faulty. forces unrolled back savepoints to a rolled back state | ||
y => y.and( z => z.equals('name_snapshot', z => z.literal(this.current_name) ), z => z.isNull('rollback_date') ) | ||
@@ -165,0 +166,0 @@ ) ); |
@@ -171,3 +171,2 @@ | ||
return new Promise((resolve, reject) => { | ||
console.log('..........////////', params); | ||
this.driver.query(`${ query }`, params.params || [], (err, result) => { | ||
@@ -174,0 +173,0 @@ if (err) return reject(err); |
@@ -50,8 +50,9 @@ | ||
static parse(context, expr) { | ||
const [ match, ifExists, namePart ] = /^DROP\s+DATABASE\s+(IF\s+EXISTS\s+)?(.+)$/i.exec(expr) || []; | ||
const [ match, ifExists, namePart, cascade, namePartAlt ] = /^DROP\s+DATABASE\s+(IF\s+EXISTS\s+)?(?:(.+)\s+(CASCADE)$|(.+)$)/i.exec(expr) || []; | ||
if (!match) return; | ||
const [dbName] = this.parseIdent(context, namePart.trim(), true) || []; | ||
const [dbName] = this.parseIdent(context, (namePart || namePartAlt).trim(), true) || []; | ||
if (!dbName) return; | ||
const instance = new this(context, dbName); | ||
if (ifExists) instance.withFlag('IF_EXISTS'); | ||
if (cascade) instance.withFlag('CASCADE'); | ||
return instance; | ||
@@ -58,0 +59,0 @@ } |
@@ -57,8 +57,9 @@ | ||
static parse(context, expr) { | ||
const [ match, ifExists, namePart ] = /^DROP\s+TABLE\s+(IF\s+EXISTS\s+)?([\s\S]+)$/i.exec(expr) || []; | ||
const [ match, ifExists, namePart, cascade, namePartAlt ] = /^DROP\s+TABLE\s+(IF\s+EXISTS\s+)?(?:(.+)\s+(CASCADE)$|(.+)$)/i.exec(expr) || []; | ||
if (!match) return; | ||
const [tblName, dbName] = this.parseIdent(context, namePart.trim(), true) || []; | ||
const [tblName, dbName] = this.parseIdent(context, (namePart || namePartAlt).trim(), true) || []; | ||
if (!tblName) return; | ||
const instance = new this(context, tblName, dbName); | ||
if (ifExists) instance.withFlag('IF_EXISTS'); | ||
if (cascade) instance.withFlag('CASCADE'); | ||
return instance; | ||
@@ -65,0 +66,0 @@ } |
@@ -33,2 +33,3 @@ | ||
)`, { savepointDesc: 'Created roles' })); | ||
const savepoint1 = await lqlClient.database('public').savepoint(); | ||
@@ -42,2 +43,3 @@ console.log('.....create users.....', await lqlClient.query(`CREATE TABLE users ( | ||
)`, { savepointDesc: 'Created users' })); | ||
const savepoint2 = await lqlClient.database('public').savepoint(); | ||
@@ -51,4 +53,9 @@ console.log('.....create books.....', await lqlClient.query(`CREATE TABLE books ( | ||
)`, { savepointDesc: 'Created books' })); | ||
const savepoint3 = await lqlClient.database('public').savepoint(); | ||
console.log(await (await lqlClient.database('public').savepoint()).getAssociatedSnapshots()); | ||
/* | ||
console.log('rollback 3', await savepoint3.rollback()); | ||
console.log('rollback 2', await savepoint2.rollback()); | ||
console.log('rollback 1', await savepoint1.rollback()); | ||
*/ | ||
@@ -61,3 +68,2 @@ await lqlClient.query(`INSERT INTO roles (name, created_time) VALUES ('admin', now()), ('guest', now())`); | ||
//const ww = await lqlClient.query(`SELECT name, role <~ author <~ books ~> title FROM roles`); | ||
showQuery = true; | ||
const ww = await lqlClient.query(`SELECT users.name, roles.name as role_name FROM users LEFT JOIN roles ON roles.id = users.role where roles.name = $1`, { params: ['admin'] }); | ||
@@ -64,0 +70,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
1826456
18104
285