question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support table which contains tsvector column

See original GitHub issue

I’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:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
ejoebstlcommented, Apr 14, 2020

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:

A tsvector value is a sorted list of distinct lexemes, which are words that have been normalized to merge different variants of the same word.

And

Optionally, integer positions can be attached to lexemes.

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.

0reactions
janpiocommented, May 29, 2021

Closing as duplicate of https://github.com/prisma/prisma/issues/5027 - please follow that issue.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found