DBFlow icon indicating copy to clipboard operation
DBFlow copied to clipboard

Autoincrement Field is Ignored for Inserts

Open brwskitime opened this issue 9 years ago • 5 comments

DBFlow Version: 4.0.5

Issue Kind (Bug, Question, Feature): bug

Not using instant run.

Description:

For an empty table mytable with an auto increment field id and a text field v1:

Expected: 
    sql:    insert into `mytable` (id,v1) values(50,"foo")
    result: 50 | foo

    sql:    insert into table (v1) values("bar")
    result: 51 | bar

Starting with an empty table, in code:

MyTable myTable = new MyTable();
myTable.setId(50);
myTable.setV1("foo");
myTable.save();

result: myTable.id == 1 (valid id was stomped on)

brwskitime avatar Jul 20 '17 20:07 brwskitime

it was intended. But what I can do for 4.1.0, is provide an AutoIncrementModelSaver which will do what you want. It will apply automatically for any autoincrementing table.

agrosner avatar Jul 20 '17 20:07 agrosner

That could work. Thanks!

brwskitime avatar Jul 20 '17 20:07 brwskitime

in develop. if you get time to try it out, I recommend it.

agrosner avatar Jul 21 '17 13:07 agrosner

replace dbflow version with a3f1f776f3, and try it out.

agrosner avatar Jul 21 '17 13:07 agrosner

Where do I insert this? My tables extend BaseProviderModel.

brwskitime avatar Jul 27 '17 15:07 brwskitime