Skip to content

ProgrammingError: (psycopg.errors.UndefinedFunction) function parse_websearch #154

@a1d4r

Description

@a1d4r

When I try to execute a search query, I get the following error:

ProgrammingError: (psycopg.errors.UndefinedFunction) function parse_websearch(character varying, 
character varying) does not exist
LINE 4: ...cts.active IS true AND (products.search_vector @@ parse_webs...
                                                             ^
HINT:  No function matches the given name and argument types. You might need to add explicit type 
casts.
[SQL: SELECT count(*) AS count_1 
FROM (SELECT products.name AS name, products.category AS category, products.brand AS brand, 
products.article AS article, products.ean_code AS ean_code, products.search_vector AS search_vector,
products.id AS id, products.sa_orm_sentinel AS sa_orm_sentinel, products.created_at AS created_at, 
products.updated_at AS updated_at, products.deleted_at AS deleted_at, products.active AS active, 
products.external_id AS external_id, products.import_id AS import_id, products.extra_data AS 
extra_data 
FROM products 
WHERE products.active IS true AND (products.search_vector @@ 
parse_websearch(%(parse_websearch_1)s::VARCHAR, %(parse_websearch_2)s::VARCHAR))) AS anon_1]
[parameters: {'parse_websearch_1': 'pg_catalog.english', 'parse_websearch_2': 'example'}]
(Background on this error at: https://sqlalche.me/e/20/f405)

I checked the functions defined in the database:

create function parse_websearch(config regconfig, search_query text) returns tsquery
create function parse_websearch(search_query text) returns tsquery

It seems like the first argument type (regconfig) is wrong, and the query fails.

I managed to execute the query manually, removing the cast to VARCHAR:

parse_websearch('pg_catalog.english'::VARCHAR, 'example'::VARCHAR))) AS anon_1]

to

parse_websearch('pg_catalog.english', 'example'::VARCHAR))) AS anon_1]

Am I missing something in SQLAlchemy set up? I defined the base class Base, and then run:
make_searchable(Base.metadata). After describing all SQLAlchemy models, I run: configure_mappers().
In addition, because I use alembic, and I added these command to the migration: op.execute(sql_expressions) and sync_trigger

I use:
PostgreSQL 16.0
psycopg 3.1.18
sqlalchemy 2.0.29
sqlalchemy-searchable 2.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions