Skip to content

Commit 1460a49

Browse files
committed
🐛 fix: column weights value is a string A/B/C/D
1 parent e5223d3 commit 1460a49

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "extra-sql",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "SQL is designed for managing or stream processing data in an RDBMS.",
55
"main": "index.js",
66
"module": "index.mjs",

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const OPERAND_COUNT: Map<string, number> = new Map([
4444
type ColumnTypes = {[key: string]: string};
4545

4646
/** Weights for columns in a table (for a tsvector). */
47-
type ColumnWeights = {[key: string]: number};
47+
type ColumnWeights = {[key: string]: string};
4848

4949
/** Data for a row in a table. */
5050
type RowData = {[key: string]: any};

tests/index.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,16 +157,16 @@ describe('setupTableIndex', () => {
157157

158158
test('generates SQL for tsvector index', () => {
159159
const sql = setupTableIndex('articles', {title: 'TEXT', content: 'TEXT'}, {
160-
tsvector: {title: 1, content: 2},
160+
tsvector: {title: 'A', content: 'B'},
161161
index: true,
162162
});
163163
expect(sql).toBe(
164164
'CREATE OR REPLACE VIEW "articles_tsvector" AS SELECT *, ' +
165-
'setweight(to_tsvector(\'english\', "title"), \'1\')||' +
166-
'setweight(to_tsvector(\'english\', "content"), \'2\') AS "tsvector" FROM "articles";\n' +
165+
'setweight(to_tsvector(\'english\', "title"), \'A\')||' +
166+
'setweight(to_tsvector(\'english\', "content"), \'B\') AS "tsvector" FROM "articles";\n' +
167167
'CREATE INDEX IF NOT EXISTS "articles_tsvector_idx" ON "articles" USING GIN ((' +
168-
'setweight(to_tsvector(\'english\', "title"), \'1\')||' +
169-
'setweight(to_tsvector(\'english\', "content"), \'2\')));\n' +
168+
'setweight(to_tsvector(\'english\', "title"), \'A\')||' +
169+
'setweight(to_tsvector(\'english\', "content"), \'B\')));\n' +
170170
'CREATE INDEX IF NOT EXISTS "articles_title_idx" ON "articles" ("title");\n' +
171171
'CREATE INDEX IF NOT EXISTS "articles_content_idx" ON "articles" ("content");\n'
172172
);

0 commit comments

Comments
 (0)