Skip to content

Commit

Permalink
fix(core): fix multiple ? in fulltext fields updates
Browse files Browse the repository at this point in the history
Closes #4484
  • Loading branch information
B4nan committed Jul 14, 2023
1 parent fbb6958 commit 9c9915e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/knex/src/query/QueryBuilderHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ export class QueryBuilderHelper {
if (prop.hasConvertToDatabaseValueSQL && !this.platform.isRaw(data[k])) {
const quoted = this.platform.quoteValue(data[k]);
const sql = prop.customType.convertToDatabaseValueSQL!(quoted, this.platform);
data[k] = this.knex.raw(sql.replace(/\?/, '\\?'));
data[k] = this.knex.raw(sql.replace(/\?/g, '\\?'));
}

if (!prop.customType && (Array.isArray(data[k]) || Utils.isPlainObject(data[k]))) {
Expand Down
13 changes: 13 additions & 0 deletions tests/features/fulltext/full-text-search-tsvector.postgres.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,17 @@ describe('full text search tsvector in postgres', () => {
expect(fullTextBooks).toHaveLength(3);
});

test('update entity', async () => {
const book1 = new Book('My Life on The Wall');
await orm.em.persist(book1).flush();

const newTitle = 'My Life on The ? Wall, part ? ?';
book1.title = newTitle;
await orm.em.flush();
orm.em.clear();

const reloadedBook = await orm.em.findOne(Book, { id: book1.id });
expect(reloadedBook?.title).toBe(newTitle);
});

});

0 comments on commit 9c9915e

Please sign in to comment.