Skip to content

Commit

Permalink
Merge pull request codinguser#261 from fefe982/fix-escape
Browse files Browse the repository at this point in the history
Correct escape strrings.
  • Loading branch information
codinguser committed Nov 12, 2014
2 parents 62eab82 + f4624ee commit bc84003
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 2 additions & 6 deletions app/src/org/gnucash/android/db/TransactionsDbAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -546,14 +546,10 @@ public Cursor fetchRecord(long rowId) {
* @return Cursor to the data set containing all matching transactions
*/
public Cursor fetchTransactionsStartingWith(String prefix){
StringBuffer stringBuffer = new StringBuffer(TransactionEntry.COLUMN_DESCRIPTION)
.append(" LIKE '").append(prefix).append("%'");
String selection = stringBuffer.toString();

return mDb.query(TransactionEntry.TABLE_NAME,
new String[]{TransactionEntry._ID, TransactionEntry.COLUMN_DESCRIPTION},
selection,
null, null, null,
TransactionEntry.COLUMN_DESCRIPTION + " LIKE ?",
new String[]{prefix+"%"}, null, null,
TransactionEntry.COLUMN_DESCRIPTION + " ASC");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ public CharSequence convertToString(Cursor cursor) {
adapter.setFilterQueryProvider(new FilterQueryProvider() {
@Override
public Cursor runQuery(CharSequence name) {
return mTransactionsDbAdapter.fetchTransactionsStartingWith(name.toString());
return mTransactionsDbAdapter.fetchTransactionsStartingWith(name==null?"":name.toString());
}
});

Expand Down

0 comments on commit bc84003

Please sign in to comment.