Skip to content

Commit

Permalink
Handle boolean types in where arguments.
Browse files Browse the repository at this point in the history
Fixes Issue #203.
  • Loading branch information
joshuapinter committed Apr 6, 2014
1 parent 75f3562 commit 53397c4
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/com/activeandroid/query/From.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/

import android.text.TextUtils;

import com.activeandroid.Cache;
import com.activeandroid.Model;
import com.activeandroid.content.ContentProvider;
Expand All @@ -25,7 +26,6 @@
import com.activeandroid.util.SQLiteUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public final class From implements Sqlable {
Expand Down Expand Up @@ -100,13 +100,13 @@ public From where(String where) {
public From where(String where, Object... args) {
if (mWhere != null) { // Chain conditions if a previous
mWhere = mWhere + " AND " + where; // condition exists.
mArguments.addAll(Arrays.asList(args));

} else {
}
else {
mWhere = where;
mArguments.addAll(Arrays.asList(args));
}

addArguments(args);

return this;
}

Expand Down Expand Up @@ -144,7 +144,12 @@ public From offset(String offset) {
}

void addArguments(Object[] args) {
mArguments.addAll(Arrays.asList(args));
for( Object arg : args ) {
if (arg.getClass() == boolean.class || arg.getClass() == Boolean.class)
arg = ( arg.equals(true) ? 1 : 0 );

mArguments.add(arg);
}
}

@Override
Expand Down

0 comments on commit 53397c4

Please sign in to comment.