From fc8065746b79dc94514d26e77cfe83c3d668d368 Mon Sep 17 00:00:00 2001 From: encalypto Date: Mon, 4 Nov 2024 16:08:41 -0500 Subject: [PATCH] Exclude full-text search columns from entity queries (#5693) - Remove `tsvector` columns from `SELECT` clauses in entity queries - Filter out full-text search columns from the list of selected columns Full-text search columns (`tsvector` type) are used for indexing and efficient text searching, but they are not part of the entity's data model and are not meant to be directly queried or returned. This fixes a bug where trying to load a tsvector column fails, as diesel does not natively have tsvector support, and we don't explicitly handle the type in `relational::value::OidValue::from_sql`. --- store/postgres/src/relational/dsl.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/store/postgres/src/relational/dsl.rs b/store/postgres/src/relational/dsl.rs index b11b0858a5d..df2e4afdab9 100644 --- a/store/postgres/src/relational/dsl.rs +++ b/store/postgres/src/relational/dsl.rs @@ -267,6 +267,10 @@ impl<'a> Table<'a> { } }; + // NB: Exclude full-text search columns from selection. These columns are used for indexing + // and searching but are not part of the entity's data model. + cols.retain(|c| !c.is_fulltext()); + if T::WITH_INTERNAL_KEYS { match parent_type { Some(IdType::String) => cols.push(&*PARENT_STRING_COL), @@ -346,7 +350,10 @@ impl<'a> Table<'a> { ColumnType::Int8 => add_field::(&mut selection, self, column), ColumnType::Timestamp => add_field::(&mut selection, self, column), ColumnType::String => add_field::(&mut selection, self, column), - ColumnType::TSVector(_) => add_field::(&mut selection, self, column), + ColumnType::TSVector(_) => { + // Skip tsvector columns in SELECT as they are for full-text search only and not + // meant to be directly queried or returned + } ColumnType::Enum(_) => add_enum_field(&mut selection, self, column), }; }