From b9cde74174880f91f740a090b8d33af75705c965 Mon Sep 17 00:00:00 2001 From: Rene Saarsoo Date: Thu, 19 Dec 2024 12:40:32 +0200 Subject: [PATCH] Support pgvector operators in PostgreSQL Fixes #807 --- src/languages/postgresql/postgresql.formatter.ts | 7 +++++++ test/postgresql.test.ts | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/src/languages/postgresql/postgresql.formatter.ts b/src/languages/postgresql/postgresql.formatter.ts index b00014fcd..1f41f2c49 100644 --- a/src/languages/postgresql/postgresql.formatter.ts +++ b/src/languages/postgresql/postgresql.formatter.ts @@ -367,6 +367,13 @@ export const postgresql: DialectOptions = { // Type cast '::', ':', + // Custom operators defined by pgvector extension + // https://github.com/pgvector/pgvector#querying + '<#>', + '<=>', + '<+>', + '<~>', + '<%>', ], operatorKeyword: true, }, diff --git a/test/postgresql.test.ts b/test/postgresql.test.ts index 51d9e388d..c46418a65 100644 --- a/test/postgresql.test.ts +++ b/test/postgresql.test.ts @@ -146,6 +146,12 @@ describe('PostgreSqlFormatter', () => { '<->>', '<<<->', '<->>>', + // Custom operators: from pgvector extension + '<#>', + '<=>', + '<+>', + '<~>', + '<%>', ], { any: true } );