mirror of
https://github.com/garrytan/gbrain.git
synced 2026-07-31 04:07:52 +00:00
fix: harden Voyage schema templating
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { describe, test, expect } from 'bun:test';
|
||||
import { getPGLiteSchema, PGLITE_SCHEMA_SQL } from '../../src/core/pglite-schema.ts';
|
||||
import { getPostgresSchema } from '../../src/core/postgres-engine.ts';
|
||||
|
||||
describe('getPGLiteSchema', () => {
|
||||
test('default produces v0.13-compatible schema (1536d + text-embedding-3-large)', () => {
|
||||
@@ -41,3 +42,19 @@ describe('getPGLiteSchema', () => {
|
||||
expect(PGLITE_SCHEMA_SQL).toBe(getPGLiteSchema());
|
||||
});
|
||||
});
|
||||
|
||||
describe('getPostgresSchema', () => {
|
||||
test('Voyage 2048d updates vector column and seeded config but skips HNSW', () => {
|
||||
const sql = getPostgresSchema(2048, 'voyage-4-large');
|
||||
expect(sql).toMatch(/vector\(2048\)/);
|
||||
expect(sql).toMatch(/\('embedding_model', 'voyage-4-large'\)/);
|
||||
expect(sql).toMatch(/\('embedding_dimensions', '2048'\)/);
|
||||
expect(sql).not.toContain('idx_chunks_embedding ON content_chunks USING hnsw');
|
||||
});
|
||||
|
||||
test('escapes configured model before inserting into schema SQL literals', () => {
|
||||
const sql = getPostgresSchema(1024, "voyage-weird'quoted");
|
||||
expect(sql).toContain("'voyage-weird''quoted'");
|
||||
expect(sql).not.toContain("'voyage-weird'quoted'");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user