We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
DBFlow Version: 4.1.1 Issue Kind (Bug, Question, Feature): Bug
Description: When I set a value to autoincrement column and try to save the model an exception occurs. I created sample that simulates the error:
@Table(database = TestDb.class) public class TestModel extends BaseModel { @PrimaryKey(autoincrement = true) private int modelId; @Column private String name; public int getModelId() { return modelId; } public void setModelId(int modelId) { this.modelId = modelId; } public String getName() { return name; } public void setName(String name) { this.name = name; } }
@Test public void testDb() { TestModel testModel = new TestModel(); testModel.setModelId(1); testModel.setName("name"); testModel.save(); assertEquals(1, SQLite.select().from(TestModel.class).queryList().size()); }
java.lang.IllegalArgumentException: Cannot bind argument at index 2 because the index is out of range. The statement has 1 parameters.
The text was updated successfully, but these errors were encountered:
I think the problem is in AutoIncrementModelSaver:
@Override public synchronized long insert(@NonNull TModel model, @NonNull DatabaseStatement insertStatement, @NonNull DatabaseWrapper wrapper) { if (getModelAdapter().hasAutoIncrement(model)) { getModelAdapter().bindToStatement(insertStatement, model); } else { getModelAdapter().bindToInsertStatement(insertStatement, model); } long id = insertStatement.executeInsert(); if (id > INSERT_FAILED) { getModelAdapter().updateAutoIncrement(model, id); NotifyDistributor.get().notifyModelChanged(model, getModelAdapter(), BaseModel.Action.INSERT); } return id; }
the insertStatement does not contain modelId column, but the adapter tries to bind it. my fix proposal is:
insertStatement
modelId
@Override public synchronized long insert(@NonNull TModel model, @NonNull DatabaseStatement insertStatement, @NonNull DatabaseWrapper wrapper) { return insert(model, wrapper); }
Sorry, something went wrong.
[modal] autoincrement model saver causes illegalargumentexception sin…
a949d89
…ce it uses wrong insert statement. #1447
fixed for 4.1.2.
4.1.2
agrosner
No branches or pull requests
DBFlow Version: 4.1.1
Issue Kind (Bug, Question, Feature): Bug
Description:
When I set a value to autoincrement column and try to save the model an exception occurs.
I created sample that simulates the error:
java.lang.IllegalArgumentException: Cannot bind argument at index 2 because the index is out of range. The statement has 1 parameters.
The text was updated successfully, but these errors were encountered: