Support table which contains tsvector column
See original GitHub issueI’ve attempted to query all items in a postgres table. The table contains a column of type tsvector
, which seems to be the cause of this crash.
(node:52874) UnhandledPromiseRejectionWarning: Error:
Invalid `prisma.article.findMany()` invocation in
/home/emi/Projects/prisma-playground/index.ts:5:16
1 import { PrismaClient } from '@prisma/client'
2
3 const prisma = new PrismaClient()
4
→ 5 prisma.article.findMany().then((x) =>
Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: FromSql(19), cause: Some(WrongType { postgres: TsVector, rust: "core::option::Option<alloc::string::String>" }) }) })
at PrismaClientFetcher.request (/home/emi/Projects/prisma-playground/node_modules/@prisma/client/runtime/index.js:1:47490)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:52874) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:52874) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Please note that it’s very uncommon fetch the value of tsvector
columns, it is rather used for building full text indices.
Here is the table schema, for your convenience:
CREATE TABLE public."Article" (
title text NOT NULL,
text_index tsvector NULL,
);
Version information:
$ /home/emi/Projects/prisma-playground/node_modules/.bin/prisma2 version
prisma2@2.0.0-preview024, binary version: 377df4fe30aa992f13f1ba152cf83d5770bdbc85
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Documentation: 15: 12.2. Tables and Indexes - PostgreSQL
A simple query to print the title of each row that contains the word friend in ... ALTER TABLE pgweb ADD COLUMN textsearchable_index_col...
Read more >Is there any reason to include a `tsvector` column in a ...
The idea is to augment the table with a ts_vector column and index the new column. A simple example is: CREATE TABLE articles...
Read more >Get partial match from GIN indexed TSVECTOR column
This works and return rows with tsv containing 'Available'. But if I use 'avai' (truncating '...lable') it does not find anything. Do all ......
Read more >Understanding PostgreSQL Full Text Search: 10 Critical Aspects
During a PostgreSQL Full Text search, Postgres will not include “stop ... ALTER TABLE se_details ADD COLUMN ts tsvector GENERATED ALWAYS AS ...
Read more >Tables and Views — PostgREST 9.0.0 documentation
For more complicated filters you will have to create a new view in the database, ... PostgREST supports unicode in schemas, tables, columns...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
To be honest, I would omit it in the output.
tsvector columns are interesting for filtering and ranking the results, but I would guess most use cases don’t require them in the client application.
Otherwise, according to the documentation:
And
So a good representation would be an ordered list of key-value tuples, where the key is a string and the value is a list of integers.
Closing as duplicate of https://github.com/prisma/prisma/issues/5027 - please follow that issue.