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

on conflict replace vs on conflict ignore #148

Open
cheneveld opened this issue May 23, 2013 · 1 comment
Open

on conflict replace vs on conflict ignore #148

cheneveld opened this issue May 23, 2013 · 1 comment

Comments

@cheneveld
Copy link

I am not sure if the problem I had was do to a misunderstanding of android's sql-lite integration or a mechanoid bug.

I had to following table definition (I have simplified in hope you can reproduce):

create table mytable (
    _id integer primary key autoincrement,
    id integer,
    mystring text,
    unique (id) on conflict ignore    
);

My processes did something like:

final MyTable.Builder builder =  MyTable.newBuilder()
                                .setId(parsedVariable.id)
                                .setMyString(parsedVariable.myString);

batch.add(builder.toInsertOperationBuilder().build());

resolver.applyBatch(Contract.CONTENT_AUTHORITY, batch);

I had serval tables with this pattern and ran into first time insert errors and insert errors from conflicts.

I submitted a StackOverflow thread to try to get more information about the failing insert -> http://stackoverflow.com/questions/16705083/debugging-a-operationapplicationexception-insert-failed

I was able to fix everything by updating the schema to this

create table mytable (
    _id integer primary key autoincrement,
    id integer,
    mystring text,
    unique (id) on conflict replace   
);

Using replace instead of ignore.

I thought I would share my findings and see if maybe there is a bug or something else is going on.

Thanks for this fantastic tool!

Cheers!

@fluxtah
Copy link
Contributor

fluxtah commented May 25, 2013

Cheers, will look into it, I have not used ignore yet but I assume it should not throw an exception but ignore your inserts.

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

2 participants