Skip to content

Commit

Permalink
Fixing forgotten comma
Browse files Browse the repository at this point in the history
  • Loading branch information
acrodrig committed Apr 13, 2024
1 parent 81843a4 commit ece24a3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ddl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class DDL {
const pad = "".padEnd(padWidth);

table = table.toLowerCase();
const wrapper = (columns: string[], s = ",", w = false) => columns.map((c) => w ? "COALESCE(" + c + "'')" : c).join(s);
const wrapper = (columns: string[], s = ",", w = false) => columns.map((c) => w ? "COALESCE(" + c + ",'')" : c).join(s);
if (dbType === DB.Provider.MYSQL) return `${pad}CREATE FULLTEXT INDEX ${table}_${name} ON ${table} (${wrapper(columns, ",")});\n`;
if (dbType === DB.Provider.POSTGRES) return `${pad}CREATE INDEX ${table}_${name} ON ${table} USING GIN (TO_TSVECTOR('english', ${wrapper(columns, "||' '||", true)}));`;

Expand Down
2 changes: 1 addition & 1 deletion src/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ export class Repository<T extends Identifiable> extends EventTarget {
tree.push(fullTextColumns?.length ? value[key] + (DB.type === DB.Provider.POSTGRES ? "" : "*") : "%" + value[key] + "%");

// Regardless of what we are looking for, MySQL wants us to enter every column here
const wrapper = (columns: string[], s = ",", w = false) => columns.map((c) => w ? "COALESCE(" + c + "'')" : c).join(s);
const wrapper = (columns: string[], s = ",", w = false) => columns.map((c) => w ? "COALESCE(" + c + ",'')" : c).join(s);
if (fullTextColumns?.length) {
if (DB.type === DB.Provider.MYSQL) expressions.push("MATCH (" + wrapper(fullTextColumns) + ") AGAINST (? IN BOOLEAN MODE)");
if (DB.type === DB.Provider.POSTGRES) expressions.push("TO_TSVECTOR('english', " + wrapper(fullTextColumns) + ") @@ TO_TSQUERY(?)");
Expand Down

0 comments on commit ece24a3

Please sign in to comment.