Skip to content

Commit

Permalink
Fix ambiguity in custom SQL conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
di72nn committed Jul 7, 2020
1 parent 7b5d9a3 commit 8a768a1
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ public interface OnFragmentInteractionListener {
private static final String LIST_TYPE_PARAM = "list_type";
private static final String TAG_PARAM = "tag";

private static final String UNTAGGED_WHERE = ArticleDao.Properties.Id.columnName + " not in "
+ "(select " + ArticleTagsJoinDao.Properties.ArticleId.columnName
+ " from " + ArticleTagsJoinDao.TABLENAME + ")";

private static final int PER_PAGE_LIMIT = 30;

private int listType;
Expand Down Expand Up @@ -199,7 +195,9 @@ private QueryBuilder<Article> getQueryBuilder() {
.where(ArticleDao.Properties.ArticleId.isNotNull());

if (untagged) {
qb.where(new WhereCondition.StringCondition(UNTAGGED_WHERE));
qb.where(new WhereCondition.PropertyCondition(ArticleDao.Properties.Id, " NOT IN "
+ "(select " + ArticleTagsJoinDao.Properties.ArticleId.columnName
+ " from " + ArticleTagsJoinDao.TABLENAME + ")"));
} else if (tagIDs != null && !tagIDs.isEmpty()) {
// TODO: try subquery
qb.join(ArticleTagsJoin.class, ArticleTagsJoinDao.Properties.ArticleId)
Expand All @@ -221,7 +219,7 @@ private QueryBuilder<Article> getQueryBuilder() {
}

if (!TextUtils.isEmpty(searchQuery)) {
qb.where(new WhereCondition.StringCondition(ArticleDao.Properties.Id.columnName + " IN (" +
qb.where(new WhereCondition.PropertyCondition(ArticleDao.Properties.Id, " IN (" +
FtsDao.getQueryString() + DatabaseUtils.sqlEscapeString(searchQuery) + ")"));
}

Expand Down

0 comments on commit 8a768a1

Please sign in to comment.