Hi, just started to use your active record - very handy library.
It's early days for my app, and I'm changing the DB schema frequently. I forgot
to update the database schema number, so insert failed. But it did it silently
- no exception was thrown.
In ActiveRecordBase.insert() I'd recommend it throws an exception if the id
returned in -1 at the end of the method. See below.
What do you think?
Cheers,
James
public long insert() throws ActiveRecordException {
List<Field> columns = _id > 0 ? getColumnFields()
: getColumnFieldsWithoutID();
ContentValues values = new ContentValues(columns.size());
for (Field column : columns) {
try {
if (column.getType().getSuperclass() == ActiveRecordBase.class)
values.put(
CamelNotationHelper.toSQLName(column.getName()),
column.get(this) != null ? String
.valueOf(((ActiveRecordBase) column
.get(this))._id) : "0");
else
values.put(CamelNotationHelper.toSQLName(column.getName()),
String.valueOf(column.get(this)));
} catch (IllegalAccessException e) {
throw new ActiveRecordException(e.getLocalizedMessage());
}
}
_id = m_Database.insert(getTableName(), values);
if (-1 != _id)
m_NeedsInsert = false;
return _id;
}
Original issue reported on code.google.com by vod...@gmail.com on 3 Jan 2011 at 7:44
Original issue reported on code.google.com by
vod...@gmail.com
on 3 Jan 2011 at 7:44