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

Provide an easy way to "insert or replace" or conditionally insert #296

Closed
llogiq opened this Issue Apr 22, 2016 · 3 comments

Comments

Projects
None yet
2 participants
@llogiq

llogiq commented Apr 22, 2016

I'm thinking about using diesel in a project, where I get a stream of data that may contain duplicates, and I want only distinct data in my database, so an insert or replace statement would be quite helpful. I should note that I plan to use the sqlite backend. What are my options?

@sgrif

This comment has been minimized.

Member

sgrif commented Apr 22, 2016

We don't have any support for upsert at the moment, but this is something I'd like to add in the future. See #196. I'm going to bump this to the 0.7 milestone, as SQLite in particular should be extremely easy to support for this case. I'll see if I can add it today.

@sgrif sgrif closed this Apr 22, 2016

@llogiq

This comment has been minimized.

llogiq commented Apr 22, 2016

I see. No hurry, I'll need some time to finish the rest anyway. Thank you for the quick response! 👍

@sgrif

This comment has been minimized.

Member

sgrif commented Apr 22, 2016

No problem. SQLite also supports specifying that upsert should occur in the table's schema. Worst case, you could always specify the ON CONFLICT clause for the primary key (or whatever index it is that you're wanting this behavior on). Diesel generally doesn't have opinions about how you structure your schema (with exception of things that we just don't handle yet, like composite primary keys)

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