Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

null check for all DB type in bindValuesInBulkInsert #16

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

null check for all DB type in bindValuesInBulkInsert #16

florianmski opened this issue May 23, 2013 · 1 comment

Comments

@florianmski
Copy link

Hi,

First of all, thanks for this awesome tool ;)
I think we should do a null check in bindValuesInBulkInsert for every DB type, not only String.
Because as stated in the documentation for getAsLong for instance:

Returns
the Long value, or null if the value is missing or cannot be converted

In my case, I do not set a value in every column when inserting new rows using a bulkInsert and it yield a NPE.
I think there will be a special case for the _id column. If we haven't set a value for _id we shouldn't set a default one and instead let the system auto_increment this column.
Something like:

Long longValue = values.getAsLong(Columns.ID.getName());
if(longValue != null)
    stmt.bindLong(i++, longValue);
else
    i++;

Or, more compact

Long longValue = values.getAsLong(Columns.ID.getName());
if(longValue != null)
    stmt.bindLong(i, longValue);
i++;

What do you think?

@foxykeep
Copy link
Owner

Hmm kinda make sense. need to check exactly what we should do for the ID field however.

I'll check that as soon as possible

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants