@kernl-sdk/pg 0.1.24 → 0.1.26
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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +19 -0
- package/dist/__tests__/memory-integration.test.js +1 -1
- package/dist/pgvector/__tests__/handle.test.js +13 -13
- package/dist/pgvector/__tests__/integration/document.integration.test.js +21 -21
- package/dist/pgvector/__tests__/integration/edge.integration.test.js +32 -32
- package/dist/pgvector/__tests__/integration/filters.integration.test.js +5 -5
- package/dist/pgvector/__tests__/integration/lifecycle.integration.test.js +12 -12
- package/dist/pgvector/__tests__/integration/query.integration.test.d.ts +1 -1
- package/dist/pgvector/__tests__/integration/query.integration.test.js +51 -51
- package/dist/pgvector/__tests__/search.test.js +1 -1
- package/dist/pgvector/sql/__tests__/limit.test.js +20 -20
- package/dist/pgvector/sql/__tests__/query.test.js +17 -17
- package/dist/pgvector/sql/limit.js +2 -2
- package/dist/pgvector/sql/query.d.ts +1 -1
- package/dist/pgvector/sql/query.d.ts.map +1 -1
- package/dist/pgvector/sql/query.js +1 -1
- package/package.json +7 -7
- package/src/__tests__/memory-integration.test.ts +1 -1
- package/src/pgvector/__tests__/handle.test.ts +13 -13
- package/src/pgvector/__tests__/integration/document.integration.test.ts +21 -21
- package/src/pgvector/__tests__/integration/edge.integration.test.ts +32 -32
- package/src/pgvector/__tests__/integration/filters.integration.test.ts +5 -5
- package/src/pgvector/__tests__/integration/lifecycle.integration.test.ts +12 -12
- package/src/pgvector/__tests__/integration/query.integration.test.ts +51 -51
- package/src/pgvector/__tests__/search.test.ts +1 -1
- package/src/pgvector/sql/__tests__/limit.test.ts +20 -20
- package/src/pgvector/sql/__tests__/query.test.ts +17 -17
- package/src/pgvector/sql/limit.ts +2 -2
- package/src/pgvector/sql/query.ts +2 -2
|
@@ -22,7 +22,7 @@ describe("sqlize", () => {
|
|
|
22
22
|
schema: "public",
|
|
23
23
|
table: "docs",
|
|
24
24
|
});
|
|
25
|
-
expect(result.limit).toEqual({
|
|
25
|
+
expect(result.limit).toEqual({ limit: 10, offset: 0 });
|
|
26
26
|
});
|
|
27
27
|
it("throws on multi-signal fusion (not supported by pgvector)", () => {
|
|
28
28
|
expect(() => sqlize({
|
|
@@ -55,14 +55,14 @@ describe("sqlize", () => {
|
|
|
55
55
|
it("converts query with pagination", () => {
|
|
56
56
|
const result = sqlize({
|
|
57
57
|
query: [{ embedding: [0.1, 0.2] }],
|
|
58
|
-
|
|
58
|
+
limit: 25,
|
|
59
59
|
offset: 50,
|
|
60
60
|
}, { pkey: "id", schema: "public", table: "docs" });
|
|
61
|
-
expect(result.limit).toEqual({
|
|
61
|
+
expect(result.limit).toEqual({ limit: 25, offset: 50 });
|
|
62
62
|
});
|
|
63
63
|
it("uses default pagination values", () => {
|
|
64
64
|
const result = sqlize({ query: [{ embedding: [0.1, 0.2] }] }, { pkey: "id", schema: "public", table: "docs" });
|
|
65
|
-
expect(result.limit).toEqual({
|
|
65
|
+
expect(result.limit).toEqual({ limit: 10, offset: 0 });
|
|
66
66
|
});
|
|
67
67
|
it("passes binding through to all inputs", () => {
|
|
68
68
|
const binding = {
|
|
@@ -90,7 +90,7 @@ describe("sqlize", () => {
|
|
|
90
90
|
const result = sqlize({
|
|
91
91
|
filter: { status: "active" },
|
|
92
92
|
orderBy: { field: "created_at", direction: "desc" },
|
|
93
|
-
|
|
93
|
+
limit: 100,
|
|
94
94
|
}, { pkey: "id", schema: "public", table: "docs" });
|
|
95
95
|
expect(result.select.signals).toEqual([]);
|
|
96
96
|
expect(result.order.signals).toEqual([]);
|
|
@@ -132,7 +132,7 @@ describe("sqlize", () => {
|
|
|
132
132
|
},
|
|
133
133
|
},
|
|
134
134
|
};
|
|
135
|
-
const result = sqlize({ filter: { status: "active" },
|
|
135
|
+
const result = sqlize({ filter: { status: "active" }, limit: 50 }, { pkey: "id", schema: "public", table: "docs", binding });
|
|
136
136
|
expect(result.select.binding).toBe(binding);
|
|
137
137
|
expect(result.order.binding).toBe(binding);
|
|
138
138
|
expect(result.select.signals).toEqual([]);
|
|
@@ -142,7 +142,7 @@ describe("sqlize", () => {
|
|
|
142
142
|
it("handles orderBy without query signals", () => {
|
|
143
143
|
const result = sqlize({
|
|
144
144
|
orderBy: { field: "created_at", direction: "asc" },
|
|
145
|
-
|
|
145
|
+
limit: 20,
|
|
146
146
|
}, { pkey: "id", schema: "public", table: "docs" });
|
|
147
147
|
expect(result.select.signals).toEqual([]);
|
|
148
148
|
expect(result.order.signals).toEqual([]);
|
|
@@ -150,7 +150,7 @@ describe("sqlize", () => {
|
|
|
150
150
|
field: "created_at",
|
|
151
151
|
direction: "asc",
|
|
152
152
|
});
|
|
153
|
-
expect(result.limit).toEqual({
|
|
153
|
+
expect(result.limit).toEqual({ limit: 20, offset: 0 });
|
|
154
154
|
});
|
|
155
155
|
});
|
|
156
156
|
describe("edge cases", () => {
|
|
@@ -177,7 +177,7 @@ describe("sqlize", () => {
|
|
|
177
177
|
query: [{ embedding: [0.1, 0.2, 0.3] }],
|
|
178
178
|
filter: { status: "active", views: { $gt: 100 } },
|
|
179
179
|
orderBy: { field: "created_at", direction: "desc" },
|
|
180
|
-
|
|
180
|
+
limit: 50,
|
|
181
181
|
offset: 25,
|
|
182
182
|
}, { pkey: "doc_id", schema: "public", table: "documents", binding });
|
|
183
183
|
expect(result.select.pkey).toBe("doc_id");
|
|
@@ -192,7 +192,7 @@ describe("sqlize", () => {
|
|
|
192
192
|
direction: "desc",
|
|
193
193
|
});
|
|
194
194
|
expect(result.order.binding).toBe(binding);
|
|
195
|
-
expect(result.limit).toEqual({
|
|
195
|
+
expect(result.limit).toEqual({ limit: 50, offset: 25 });
|
|
196
196
|
});
|
|
197
197
|
it("handles undefined filter", () => {
|
|
198
198
|
const result = sqlize({ query: [{ embedding: [0.1, 0.2] }] }, { pkey: "id", schema: "public", table: "docs" });
|
|
@@ -228,7 +228,7 @@ describe("full pipeline integration", () => {
|
|
|
228
228
|
const query = sqlize({
|
|
229
229
|
query: [{ embedding: vector }],
|
|
230
230
|
filter: { status: "active", views: { $gt: 100 } },
|
|
231
|
-
|
|
231
|
+
limit: 25,
|
|
232
232
|
offset: 50,
|
|
233
233
|
}, { pkey: "doc_id", schema: "public", table: "documents", binding });
|
|
234
234
|
// Step 2: encode each clause (include: false to exclude extra columns)
|
|
@@ -266,7 +266,7 @@ describe("full pipeline integration", () => {
|
|
|
266
266
|
$or: [{ featured: true }, { views: { $gte: 1000 } }],
|
|
267
267
|
},
|
|
268
268
|
orderBy: { field: "created_at", direction: "desc" },
|
|
269
|
-
|
|
269
|
+
limit: 10,
|
|
270
270
|
}, { pkey: "id", schema: "public", table: "docs" });
|
|
271
271
|
const select = SQL_SELECT.encode(query.select);
|
|
272
272
|
const whereStartIdx = 1 + select.params.length;
|
|
@@ -302,7 +302,7 @@ describe("full pipeline integration", () => {
|
|
|
302
302
|
],
|
|
303
303
|
deleted_at: null,
|
|
304
304
|
},
|
|
305
|
-
|
|
305
|
+
limit: 5,
|
|
306
306
|
}, { pkey: "id", schema: "public", table: "docs" });
|
|
307
307
|
const select = SQL_SELECT.encode(query.select);
|
|
308
308
|
const whereStartIdx = 1 + select.params.length;
|
|
@@ -333,7 +333,7 @@ describe("full pipeline integration", () => {
|
|
|
333
333
|
},
|
|
334
334
|
},
|
|
335
335
|
};
|
|
336
|
-
const query = sqlize({ query: [{ embedding: vector }],
|
|
336
|
+
const query = sqlize({ query: [{ embedding: vector }], limit: 10 }, { pkey: "id", schema: "public", table: "docs", binding });
|
|
337
337
|
const select = SQL_SELECT.encode({ ...query.select, include: false });
|
|
338
338
|
const order = SQL_ORDER.encode(query.order);
|
|
339
339
|
// Euclidean uses <-> operator
|
|
@@ -355,7 +355,7 @@ describe("full pipeline integration", () => {
|
|
|
355
355
|
},
|
|
356
356
|
},
|
|
357
357
|
};
|
|
358
|
-
const query = sqlize({ query: [{ embedding: vector }],
|
|
358
|
+
const query = sqlize({ query: [{ embedding: vector }], limit: 10 }, { pkey: "id", schema: "public", table: "docs", binding });
|
|
359
359
|
const select = SQL_SELECT.encode({ ...query.select, include: false });
|
|
360
360
|
const order = SQL_ORDER.encode(query.order);
|
|
361
361
|
// Dot product uses <#> operator
|
|
@@ -368,7 +368,7 @@ describe("full pipeline integration", () => {
|
|
|
368
368
|
const query = sqlize({
|
|
369
369
|
query: [{ embedding: [0.1, 0.2] }],
|
|
370
370
|
filter: { a: 1, b: 2, c: 3 },
|
|
371
|
-
|
|
371
|
+
limit: 10,
|
|
372
372
|
offset: 20,
|
|
373
373
|
}, { pkey: "id", schema: "public", table: "docs" });
|
|
374
374
|
const select = SQL_SELECT.encode(query.select);
|
|
@@ -379,7 +379,7 @@ describe("full pipeline integration", () => {
|
|
|
379
379
|
// Verify no gaps in indices
|
|
380
380
|
// SELECT: $1 (vector)
|
|
381
381
|
// WHERE: $2, $3, $4 (a, b, c)
|
|
382
|
-
// LIMIT: $5, $6 (
|
|
382
|
+
// LIMIT: $5, $6 (limit, offset)
|
|
383
383
|
expect(select.params).toHaveLength(1); // $1
|
|
384
384
|
expect(whereStartIdx).toBe(2);
|
|
385
385
|
expect(where.params).toHaveLength(3); // $2, $3, $4
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* Codec for building sql LIMIT clause.
|
|
3
3
|
*/
|
|
4
4
|
export const SQL_LIMIT = {
|
|
5
|
-
encode({
|
|
5
|
+
encode({ limit, offset, startIdx }) {
|
|
6
6
|
const parts = [];
|
|
7
7
|
const params = [];
|
|
8
8
|
let idx = startIdx;
|
|
9
9
|
parts.push(`LIMIT $${idx++}`);
|
|
10
|
-
params.push(
|
|
10
|
+
params.push(limit);
|
|
11
11
|
if (offset > 0) {
|
|
12
12
|
parts.push(`OFFSET $${idx++}`);
|
|
13
13
|
params.push(offset);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/pgvector/sql/query.ts"],"names":[],"mappings":"AAAA,OAAO,K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,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kernl-sdk/pg",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.26",
|
|
4
4
|
"description": "PostgreSQL storage adapter for kernl",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"kernl",
|
|
@@ -35,15 +35,15 @@
|
|
|
35
35
|
"tsc-alias": "^1.8.10",
|
|
36
36
|
"typescript": "5.9.2",
|
|
37
37
|
"vitest": "^4.0.8",
|
|
38
|
-
"@kernl-sdk/ai": "^0.3.
|
|
39
|
-
"@kernl-sdk/protocol": "^0.
|
|
38
|
+
"@kernl-sdk/ai": "^0.3.3",
|
|
39
|
+
"@kernl-sdk/protocol": "^0.4.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"pg": "^8.16.3",
|
|
43
|
-
"kernl": "^0.
|
|
44
|
-
"@kernl-sdk/retrieval": "^0.1.
|
|
45
|
-
"@kernl-sdk/shared": "^0.3.
|
|
46
|
-
"@kernl-sdk/storage": "0.1.
|
|
43
|
+
"kernl": "^0.10.0",
|
|
44
|
+
"@kernl-sdk/retrieval": "^0.1.6",
|
|
45
|
+
"@kernl-sdk/shared": "^0.3.1",
|
|
46
|
+
"@kernl-sdk/storage": "0.1.26"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"clean": "rm -rf dist",
|
|
@@ -120,7 +120,7 @@ describe.sequential("PGIndexHandle", () => {
|
|
|
120
120
|
const handle = search.index("docs");
|
|
121
121
|
const results = await handle.query({
|
|
122
122
|
query: [{ embedding: [0.1, 0.2, 0.3] }],
|
|
123
|
-
|
|
123
|
+
limit: 2,
|
|
124
124
|
});
|
|
125
125
|
|
|
126
126
|
expect(results).toHaveLength(2);
|
|
@@ -136,7 +136,7 @@ describe.sequential("PGIndexHandle", () => {
|
|
|
136
136
|
const results = await handle.query({
|
|
137
137
|
query: [{ embedding: [0.1, 0.2, 0.3] }],
|
|
138
138
|
filter: { status: "active" },
|
|
139
|
-
|
|
139
|
+
limit: 10,
|
|
140
140
|
});
|
|
141
141
|
|
|
142
142
|
expect(results).toHaveLength(2);
|
|
@@ -152,7 +152,7 @@ describe.sequential("PGIndexHandle", () => {
|
|
|
152
152
|
const results = await handle.query({
|
|
153
153
|
query: [{ embedding: [0.1, 0.2, 0.3] }],
|
|
154
154
|
filter: { views: { $gte: 100 } },
|
|
155
|
-
|
|
155
|
+
limit: 10,
|
|
156
156
|
});
|
|
157
157
|
|
|
158
158
|
expect(results.length).toBeGreaterThanOrEqual(2);
|
|
@@ -170,7 +170,7 @@ describe.sequential("PGIndexHandle", () => {
|
|
|
170
170
|
filter: {
|
|
171
171
|
$or: [{ status: "draft" }, { status: "archived" }],
|
|
172
172
|
},
|
|
173
|
-
|
|
173
|
+
limit: 10,
|
|
174
174
|
});
|
|
175
175
|
|
|
176
176
|
expect(results).toHaveLength(2);
|
|
@@ -186,19 +186,19 @@ describe.sequential("PGIndexHandle", () => {
|
|
|
186
186
|
const results = await handle.query({
|
|
187
187
|
query: [{ embedding: [0.1, 0.2, 0.3] }],
|
|
188
188
|
filter: { status: { $in: ["active", "draft"] } },
|
|
189
|
-
|
|
189
|
+
limit: 10,
|
|
190
190
|
});
|
|
191
191
|
|
|
192
192
|
expect(results).toHaveLength(3);
|
|
193
193
|
});
|
|
194
194
|
|
|
195
|
-
it("respects
|
|
195
|
+
it("respects limit", async () => {
|
|
196
196
|
await insertDocs();
|
|
197
197
|
|
|
198
198
|
const handle = search.index("docs");
|
|
199
199
|
const results = await handle.query({
|
|
200
200
|
query: [{ embedding: [0.5, 0.5, 0.5] }],
|
|
201
|
-
|
|
201
|
+
limit: 2,
|
|
202
202
|
});
|
|
203
203
|
|
|
204
204
|
expect(results).toHaveLength(2);
|
|
@@ -212,14 +212,14 @@ describe.sequential("PGIndexHandle", () => {
|
|
|
212
212
|
// Get first 2
|
|
213
213
|
const page1 = await handle.query({
|
|
214
214
|
query: [{ embedding: [0.5, 0.5, 0.5] }],
|
|
215
|
-
|
|
215
|
+
limit: 2,
|
|
216
216
|
offset: 0,
|
|
217
217
|
});
|
|
218
218
|
|
|
219
219
|
// Get next 2
|
|
220
220
|
const page2 = await handle.query({
|
|
221
221
|
query: [{ embedding: [0.5, 0.5, 0.5] }],
|
|
222
|
-
|
|
222
|
+
limit: 2,
|
|
223
223
|
offset: 2,
|
|
224
224
|
});
|
|
225
225
|
|
|
@@ -235,7 +235,7 @@ describe.sequential("PGIndexHandle", () => {
|
|
|
235
235
|
const results = await handle.query({
|
|
236
236
|
filter: { status: "active" },
|
|
237
237
|
orderBy: { field: "views", direction: "desc" },
|
|
238
|
-
|
|
238
|
+
limit: 10,
|
|
239
239
|
});
|
|
240
240
|
|
|
241
241
|
expect(results).toHaveLength(2);
|
|
@@ -249,7 +249,7 @@ describe.sequential("PGIndexHandle", () => {
|
|
|
249
249
|
const handle = search.index("docs");
|
|
250
250
|
const results = await handle.query({
|
|
251
251
|
query: [{ embedding: [0.1, 0.2, 0.3] }],
|
|
252
|
-
|
|
252
|
+
limit: 1,
|
|
253
253
|
});
|
|
254
254
|
|
|
255
255
|
expect(results[0].document).toHaveProperty("title");
|
|
@@ -266,7 +266,7 @@ describe.sequential("PGIndexHandle", () => {
|
|
|
266
266
|
const results = await handle.query({
|
|
267
267
|
query: [{ embedding: [0.1, 0.2, 0.3] }],
|
|
268
268
|
filter: { status: "nonexistent" },
|
|
269
|
-
|
|
269
|
+
limit: 10,
|
|
270
270
|
});
|
|
271
271
|
|
|
272
272
|
expect(results).toEqual([]);
|
|
@@ -311,7 +311,7 @@ describe.sequential("PGIndexHandle", () => {
|
|
|
311
311
|
const handle = search.index<DocFields>("typed-docs");
|
|
312
312
|
const results = await handle.query({
|
|
313
313
|
query: [{ embedding: [0.1, 0.2, 0.3] }],
|
|
314
|
-
|
|
314
|
+
limit: 1,
|
|
315
315
|
});
|
|
316
316
|
|
|
317
317
|
// TypeScript should allow these without errors
|
|
@@ -93,7 +93,7 @@ describe.sequential("pgvector document operations integration tests", () => {
|
|
|
93
93
|
// Verify document was inserted
|
|
94
94
|
const hits = await handle.query({
|
|
95
95
|
query: [{ embedding: [0.1, 0.2, 0.3, 0.4] }],
|
|
96
|
-
|
|
96
|
+
limit: 1,
|
|
97
97
|
});
|
|
98
98
|
|
|
99
99
|
expect(hits).toHaveLength(1);
|
|
@@ -162,7 +162,7 @@ describe.sequential("pgvector document operations integration tests", () => {
|
|
|
162
162
|
// Verify update
|
|
163
163
|
const hits = await handle.query({
|
|
164
164
|
filter: { id: "doc-1" },
|
|
165
|
-
|
|
165
|
+
limit: 1,
|
|
166
166
|
});
|
|
167
167
|
|
|
168
168
|
expect(hits[0].document?.title).toBe("Updated Title");
|
|
@@ -244,7 +244,7 @@ describe.sequential("pgvector document operations integration tests", () => {
|
|
|
244
244
|
// Verify count
|
|
245
245
|
const hits = await handle.query({
|
|
246
246
|
query: [{ embedding: [0.5, 0.5, 0.5, 0.5] }],
|
|
247
|
-
|
|
247
|
+
limit: 1000,
|
|
248
248
|
});
|
|
249
249
|
|
|
250
250
|
expect(hits).toHaveLength(100);
|
|
@@ -264,7 +264,7 @@ describe.sequential("pgvector document operations integration tests", () => {
|
|
|
264
264
|
|
|
265
265
|
const hits = await handle.query({
|
|
266
266
|
filter: { id: "vec-test" },
|
|
267
|
-
|
|
267
|
+
limit: 1,
|
|
268
268
|
});
|
|
269
269
|
|
|
270
270
|
// Vector values should be preserved (within floating point precision)
|
|
@@ -298,7 +298,7 @@ describe.sequential("pgvector document operations integration tests", () => {
|
|
|
298
298
|
|
|
299
299
|
const hits = await nullHandle.query({
|
|
300
300
|
filter: { id: "doc-null" },
|
|
301
|
-
|
|
301
|
+
limit: 1,
|
|
302
302
|
});
|
|
303
303
|
|
|
304
304
|
expect(hits[0].document?.title).toBe("Has Title");
|
|
@@ -343,7 +343,7 @@ describe.sequential("pgvector document operations integration tests", () => {
|
|
|
343
343
|
|
|
344
344
|
const hits = await handle.query({
|
|
345
345
|
filter: { id: "patch-1" },
|
|
346
|
-
|
|
346
|
+
limit: 1,
|
|
347
347
|
});
|
|
348
348
|
|
|
349
349
|
expect(hits[0].document?.title).toBe("Updated Title");
|
|
@@ -363,7 +363,7 @@ describe.sequential("pgvector document operations integration tests", () => {
|
|
|
363
363
|
|
|
364
364
|
const hits = await handle.query({
|
|
365
365
|
filter: { id: "patch-1" },
|
|
366
|
-
|
|
366
|
+
limit: 1,
|
|
367
367
|
});
|
|
368
368
|
|
|
369
369
|
expect(hits[0].document?.title).toBe("New Title");
|
|
@@ -382,7 +382,7 @@ describe.sequential("pgvector document operations integration tests", () => {
|
|
|
382
382
|
|
|
383
383
|
const hits = await handle.query({
|
|
384
384
|
filter: { id: "patch-1" },
|
|
385
|
-
|
|
385
|
+
limit: 1,
|
|
386
386
|
});
|
|
387
387
|
|
|
388
388
|
const stored = hits[0].document?.embedding;
|
|
@@ -399,7 +399,7 @@ describe.sequential("pgvector document operations integration tests", () => {
|
|
|
399
399
|
|
|
400
400
|
const hits = await handle.query({
|
|
401
401
|
query: [{ embedding: [0.5, 0.5, 0.5, 0.5] }],
|
|
402
|
-
|
|
402
|
+
limit: 10,
|
|
403
403
|
});
|
|
404
404
|
|
|
405
405
|
const doc1 = hits.find((h) => h.id === "patch-1");
|
|
@@ -438,7 +438,7 @@ describe.sequential("pgvector document operations integration tests", () => {
|
|
|
438
438
|
|
|
439
439
|
const hits = await nullHandle.query({
|
|
440
440
|
filter: { id: "doc-1" },
|
|
441
|
-
|
|
441
|
+
limit: 1,
|
|
442
442
|
});
|
|
443
443
|
|
|
444
444
|
expect(hits[0].document?.subtitle).toBeNull();
|
|
@@ -467,7 +467,7 @@ describe.sequential("pgvector document operations integration tests", () => {
|
|
|
467
467
|
|
|
468
468
|
const hits = await handle.query({
|
|
469
469
|
filter: { id: "patch-1" },
|
|
470
|
-
|
|
470
|
+
limit: 1,
|
|
471
471
|
});
|
|
472
472
|
|
|
473
473
|
expect(hits[0].document?.title).toBe("Updated");
|
|
@@ -527,7 +527,7 @@ describe.sequential("pgvector document operations integration tests", () => {
|
|
|
527
527
|
// Verify deletion
|
|
528
528
|
const hits = await handle.query({
|
|
529
529
|
filter: { id: "del-1" },
|
|
530
|
-
|
|
530
|
+
limit: 1,
|
|
531
531
|
});
|
|
532
532
|
|
|
533
533
|
expect(hits).toHaveLength(0);
|
|
@@ -541,7 +541,7 @@ describe.sequential("pgvector document operations integration tests", () => {
|
|
|
541
541
|
// Verify only del-3 remains
|
|
542
542
|
const hits = await handle.query({
|
|
543
543
|
query: [{ embedding: [0.5, 0.5, 0.5, 0.5] }],
|
|
544
|
-
|
|
544
|
+
limit: 10,
|
|
545
545
|
});
|
|
546
546
|
|
|
547
547
|
expect(hits).toHaveLength(1);
|
|
@@ -570,7 +570,7 @@ describe.sequential("pgvector document operations integration tests", () => {
|
|
|
570
570
|
|
|
571
571
|
const hits = await handle.query({
|
|
572
572
|
query: [{ embedding: [0.5, 0.5, 0.5, 0.5] }],
|
|
573
|
-
|
|
573
|
+
limit: 10,
|
|
574
574
|
});
|
|
575
575
|
|
|
576
576
|
expect(hits).toHaveLength(0);
|
|
@@ -594,7 +594,7 @@ describe.sequential("pgvector document operations integration tests", () => {
|
|
|
594
594
|
|
|
595
595
|
const hits = await handle.query({
|
|
596
596
|
filter: { views: 0 },
|
|
597
|
-
|
|
597
|
+
limit: 1,
|
|
598
598
|
});
|
|
599
599
|
|
|
600
600
|
expect(hits).toHaveLength(1);
|
|
@@ -613,7 +613,7 @@ describe.sequential("pgvector document operations integration tests", () => {
|
|
|
613
613
|
|
|
614
614
|
const hits = await handle.query({
|
|
615
615
|
filter: { views: -50 },
|
|
616
|
-
|
|
616
|
+
limit: 1,
|
|
617
617
|
});
|
|
618
618
|
|
|
619
619
|
expect(hits).toHaveLength(1);
|
|
@@ -642,12 +642,12 @@ describe.sequential("pgvector document operations integration tests", () => {
|
|
|
642
642
|
|
|
643
643
|
const trueHits = await handle.query({
|
|
644
644
|
filter: { published: true },
|
|
645
|
-
|
|
645
|
+
limit: 10,
|
|
646
646
|
});
|
|
647
647
|
|
|
648
648
|
const falseHits = await handle.query({
|
|
649
649
|
filter: { published: false },
|
|
650
|
-
|
|
650
|
+
limit: 10,
|
|
651
651
|
});
|
|
652
652
|
|
|
653
653
|
expect(trueHits).toHaveLength(1);
|
|
@@ -668,7 +668,7 @@ describe.sequential("pgvector document operations integration tests", () => {
|
|
|
668
668
|
|
|
669
669
|
const hits = await handle.query({
|
|
670
670
|
filter: { title: "" },
|
|
671
|
-
|
|
671
|
+
limit: 1,
|
|
672
672
|
});
|
|
673
673
|
|
|
674
674
|
expect(hits).toHaveLength(1);
|
|
@@ -687,7 +687,7 @@ describe.sequential("pgvector document operations integration tests", () => {
|
|
|
687
687
|
|
|
688
688
|
const hits = await handle.query({
|
|
689
689
|
filter: { id: "unicode-test" },
|
|
690
|
-
|
|
690
|
+
limit: 1,
|
|
691
691
|
});
|
|
692
692
|
|
|
693
693
|
expect(hits[0].document?.title).toBe("Hello 世界 🌍");
|
|
@@ -708,7 +708,7 @@ describe.sequential("pgvector document operations integration tests", () => {
|
|
|
708
708
|
|
|
709
709
|
const hits = await handle.query({
|
|
710
710
|
filter: { id: "long-string" },
|
|
711
|
-
|
|
711
|
+
limit: 1,
|
|
712
712
|
});
|
|
713
713
|
|
|
714
714
|
expect(hits[0].document?.content).toBe(longString);
|