- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1k
 
Open
Description
I was running
new Update(Table.class).set("columnName = ?", false);
new Select().from(Table.class).where("columnName = ?", false);
The select returns 0 results. The issue is that Where actually looks at the parameter type and converts it correctly, whereas Set simply runs .toString() on all arguments, which results in booleans being stored in the db as true and false instead of 1 and 0.
This is from Set.java:
public String[] getArguments() {
    final int setSize = mSetArguments.size();
    final int whereSize = mWhereArguments.size();
    final String[] args = new String[setSize + whereSize];
    for (int i = 0; i < setSize; i++) {
        args[i] = mSetArguments.get(i).toString();
    }
    for (int i = 0; i < whereSize; i++) {
        args[i + setSize] = mWhereArguments.get(i).toString();
    }
    return args;
}
This is from From.java:
void addArguments(Object[] args) {
    for(Object arg : args) {
        if (arg.getClass() == boolean.class || arg.getClass() == Boolean.class) {
            arg = (arg.equals(true) ? 1 : 0);
        }
        mArguments.add(arg);
    }
}
Set needs to handle booleans like Where, otherwise you end up with a table that looks like this:

Metadata
Metadata
Assignees
Labels
No labels