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

Add support for array operations in the dsl. #1412

Open
Aaronepower opened this Issue Dec 19, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@Aaronepower

Aaronepower commented Dec 19, 2017

It'd be nice to if the dsl supported array operations such as append or remove.

Rust

struct Post {
     id: i32,
     authors: Vec<String>,
}

fn main() {
    use schema::posts::dsl::*;
    diesel::update(posts.find(&1))
      .array_append(authors, String::from("Jane Doe"));
}

SQL

UPDATE posts SET authors = authors || '{Jane Doe}' WHERE id = 1;

Checklist

  • I have already looked over the issue tracker for similar issues.

@sgrif sgrif added the enhancement label Dec 19, 2017

@sgrif

This comment has been minimized.

Member

sgrif commented Jan 8, 2018

Note that your SQL doesn't map to the operator or types you've specified. || is the "concatenate" operator, and the equivalent Rust would likely be authors.eq(authors.concat(vec!["Jane Doe"]))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment