Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update / insert TsVector value? #19

Open
kaj opened this issue May 11, 2020 · 3 comments
Open

Update / insert TsVector value? #19

kaj opened this issue May 11, 2020 · 3 comments

Comments

@kaj
Copy link

kaj commented May 11, 2020

Is it possible to update or insert a TsVector value? I would expect to be able to do something like:

    use crate::schema::mytable::dsl as my;
    insert_into(my::mytable)
       .values((
             my::some_text.eq(some_text),
             my::ts.eq(to_tsvector(some_text),
        ))
        .execute(db)?;

But I get the error that the method eq is not found in the column declaration. i'd say some trait is missing, but I don't (yet) know if my code is just missing some use statement or if TsVector is missing some impl statement. Maybe it needs to impl SingleValue?

@weiznich
Copy link
Member

Yes the SingleValue impl is missing. For a more idiomatic implementation I would just replace this impsl with a SqlType derive on the corresponding type definitions, as such a derive provides all of the required impls out of the box.

@dchenk
Copy link

dchenk commented Sep 3, 2021

@weiznich is the SingleValue implementation missing on purpose, or can it simply be added to support inserting rows with a TsVector column?

A related issue: Insertable cannot be derived on a TsVector because the trait bound Expression is not satisfied.

@weiznich
Copy link
Member

weiznich commented Sep 3, 2021

@dchenk Please don't ping me to just ask questions.

is the SingleValue implementation missing on purpose, or can it simply be added to support inserting rows with a TsVector column

As written above: That's something that could likely be improved. Its nothing that has priority for me as the main reason why this crate even exists is to showcase how to add support for postgres extensions as diesel extension crate. This implies that this crate is not primarily be designed to be used in production somewhere. Doing that is certainly possible, but don't expect much support here. This may change if diesels maintainer situation changes or if someone steps up to maintain this crate on their own.

A related issue: Insertable cannot be derived on a TsVector because the trait bound Expression is not satisfied.

Thats on purpose as TsVector is a zero sized type that cannot hold any value on rust side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants