Skip to content

Commit fcfebc6

Browse files
committed
Merge branch 'master' of github.com:atelier-saulx/selva
2 parents d115adb + 3f7a44d commit fcfebc6

File tree

8 files changed

+775
-672
lines changed

8 files changed

+775
-672
lines changed

client/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@saulx/selva",
3-
"version": "21.2.2",
3+
"version": "21.2.3",
44
"license": "MIT",
55
"main": "dist/src/index.js",
66
"scripts": {
@@ -51,7 +51,7 @@
5151
},
5252
"devDependencies": {
5353
"@types/pg": "^8.6.1",
54-
"@saulx/selva-server": "21.2.2",
54+
"@saulx/selva-server": "21.2.3",
5555
"before-exit": "1.0.0",
5656
"async-exec": "^1.1.0",
5757
"@sindresorhus/fnv1a": "^2.0.1",
@@ -73,7 +73,7 @@
7373
"pg-native": "3.0.0",
7474
"squel": "^5.13.0",
7575
"data-record": "^1.0.0",
76-
"@saulx/selva-query-ast-parser": "^4.2.0",
76+
"@saulx/selva-query-ast-parser": "^4.0.2",
7777
"@types/uuid": "^8.3.0",
7878
"chalk": "^4.1.0",
7979
"@saulx/redis-client": "^1.0.0",

client/src/get/executeGetOperations/indexing.ts

-24
Original file line numberDiff line numberDiff line change
@@ -35,30 +35,6 @@ function ast2inlineRpn(schema: Schema, f: FilterAST | null): string | null {
3535
const num = Number(f.$value)
3636
return Number.isNaN(num) ? null : `"${f.$field}" g #${num} F`
3737
}
38-
case 'has':
39-
if (['ancestors', 'children', 'descendants', 'parents'].includes(f.$field)) {
40-
return null
41-
}
42-
43-
if (typeof f.$value === 'string') {
44-
return `"${f.$value}" "${f.$field}" a`
45-
} else if (typeof f.$value === 'number') {
46-
return `#${f.$value} "${f.$field}" a`
47-
} else if (Array.isArray(f.$value)) {
48-
if (typeof f.$value[0] === 'string') {
49-
if (f.$value.some((v: string) => v.includes('"'))) {
50-
// We can't inline quotes at the moment
51-
return null
52-
}
53-
54-
const a = `{${f.$value.map((v) => `"${v}"`).join(',')}}`
55-
return `"${f.$field}" ${a} l`
56-
} else if (typeof f.$value[0] === 'number') {
57-
const a = `{${f.$value.map((v) => `#${v}`).join(',')}}`
58-
return `"${f.$field}" ${a} l`
59-
}
60-
return null
61-
}
6238
case 'exists':
6339
return `"${f.$field}" h`
6440
case 'notExists':

client/test/alias.ts

+127
Original file line numberDiff line numberDiff line change
@@ -740,3 +740,130 @@ test.serial('set alias, get it, remove it, get it again', async (t) => {
740740
await client.delete('root')
741741
await client.destroy()
742742
})
743+
744+
test.serial('should not cache $alias with get', async (t) => {
745+
const client = connect({ port }, { loglevel: 'info' })
746+
747+
const alias = 'this_is_an_alias'
748+
749+
t.deepEqualIgnoreOrder(
750+
await client.get({
751+
$language: 'en',
752+
$alias: alias,
753+
id: true,
754+
title: true,
755+
aliases: true,
756+
}),
757+
{
758+
$isNull: true,
759+
}
760+
)
761+
762+
const id = await client.set({
763+
aliases: [alias],
764+
type: 'match',
765+
title: { en: 'yesh' },
766+
})
767+
768+
const result = await client.get({
769+
$language: 'en',
770+
$alias: alias,
771+
id: true,
772+
title: true,
773+
aliases: true,
774+
})
775+
776+
t.deepEqualIgnoreOrder(result, {
777+
id,
778+
title: 'yesh',
779+
aliases: [alias],
780+
})
781+
782+
await client.delete('root')
783+
await client.destroy()
784+
})
785+
786+
// This is known behaviour. We will deal with this in the new database
787+
test.serial.failing('should not cache $alias with observe', async (t) => {
788+
const client = connect({ port }, { loglevel: 'info' })
789+
790+
const alias = 'this_is_an_alias'
791+
792+
const query = {
793+
$language: 'en',
794+
$alias: alias,
795+
id: true,
796+
title: true,
797+
aliases: true,
798+
}
799+
800+
const result1 = await new Promise((resolve) => {
801+
client.observe(query).subscribe(resolve)
802+
})
803+
804+
t.deepEqualIgnoreOrder(result1, {
805+
$isNull: true,
806+
})
807+
808+
await client.set({
809+
aliases: [alias],
810+
type: 'match',
811+
title: { en: 'yesh' },
812+
})
813+
814+
const result2 = await new Promise((resolve) => {
815+
client.observe(query).subscribe(resolve)
816+
})
817+
818+
t.deepEqualIgnoreOrder(result2, {
819+
title: 'yesh',
820+
aliases: [alias],
821+
})
822+
823+
await client.delete('root')
824+
await client.destroy()
825+
})
826+
827+
// This is known behaviour. We will deal with this in the new database
828+
test.serial.failing('subscribing to alias', async (t) => {
829+
t.timeout(3000)
830+
const client = connect({ port }, { loglevel: 'info' })
831+
832+
const alias = 'this_is_an_alias'
833+
834+
const query = {
835+
$language: 'en',
836+
$alias: alias,
837+
id: true,
838+
title: true,
839+
aliases: true,
840+
}
841+
842+
let cnt = 0
843+
await new Promise((resolve) => {
844+
client.observe(query).subscribe((data, checksum) => {
845+
cnt++
846+
console.log(cnt, data, checksum)
847+
if (cnt === 1) {
848+
t.deepEqualIgnoreOrder(data, {
849+
$isNull: true,
850+
})
851+
console.log('counting')
852+
client.set({
853+
aliases: [alias],
854+
type: 'match',
855+
title: { en: 'yesh' },
856+
})
857+
} else if (cnt === 2) {
858+
t.deepEqualIgnoreOrder(data, {
859+
title: 'yesh',
860+
aliases: [alias],
861+
})
862+
resolve
863+
}
864+
})
865+
})
866+
867+
await client.delete('root')
868+
await client.destroy()
869+
})
-43.3 KB
Binary file not shown.
0 Bytes
Binary file not shown.

server/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@saulx/selva-server",
3-
"version": "21.2.1",
3+
"version": "21.2.3",
44
"license": "MIT",
55
"main": "./dist/index.js",
66
"scripts": {
@@ -60,7 +60,7 @@
6060
"dependencies": {
6161
"@saulx/hash": "^1.0.1",
6262
"@saulx/diff": "^1.1.3",
63-
"@saulx/selva": "21.2.1",
63+
"@saulx/selva": "21.2.3",
6464
"aws-sdk": "^2.841.0",
6565
"before-exit": "^1.0.0",
6666
"body-parser": "^1.19.0",

tools/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
{
22
"name": "tools",
33
"private": true,
4-
"version": "21.2.2",
4+
"version": "21.2.3",
55
"license": "MIT",
66
"bin": {
77
"watch": "index.js"
88
},
99
"devDependencies": {
1010
"@types/lodash": "^4.14.168",
11-
"@saulx/selva-server": "21.2.2"
11+
"@saulx/selva-server": "21.2.3"
1212
},
1313
"dependencies": {
1414
"chokidar": "^3.5.1",
1515
"execa": "^5.0.0",
1616
"lodash.chunk": "^4.2.0",
17-
"@saulx/selva": "21.2.2"
17+
"@saulx/selva": "21.2.3"
1818
}
1919
}

0 commit comments

Comments
 (0)