Skip to content

Commit fc80657

Browse files
authored
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`.
1 parent b9e1c5f commit fc80657

File tree

1 file changed

+8
-1
lines changed
  • store/postgres/src/relational

1 file changed

+8
-1
lines changed

store/postgres/src/relational/dsl.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,10 @@ impl<'a> Table<'a> {
267267
}
268268
};
269269

270+
// NB: Exclude full-text search columns from selection. These columns are used for indexing
271+
// and searching but are not part of the entity's data model.
272+
cols.retain(|c| !c.is_fulltext());
273+
270274
if T::WITH_INTERNAL_KEYS {
271275
match parent_type {
272276
Some(IdType::String) => cols.push(&*PARENT_STRING_COL),
@@ -346,7 +350,10 @@ impl<'a> Table<'a> {
346350
ColumnType::Int8 => add_field::<BigInt>(&mut selection, self, column),
347351
ColumnType::Timestamp => add_field::<Timestamptz>(&mut selection, self, column),
348352
ColumnType::String => add_field::<Text>(&mut selection, self, column),
349-
ColumnType::TSVector(_) => add_field::<Text>(&mut selection, self, column),
353+
ColumnType::TSVector(_) => {
354+
// Skip tsvector columns in SELECT as they are for full-text search only and not
355+
// meant to be directly queried or returned
356+
}
350357
ColumnType::Enum(_) => add_enum_field(&mut selection, self, column),
351358
};
352359
}

0 commit comments

Comments
 (0)