Skip to content

Commit

Permalink
Merge pull request #1011 from wallabag/fix_query
Browse files Browse the repository at this point in the history
Fix ambiguity in custom SQL conditions
  • Loading branch information
tcitworld authored Jul 8, 2020
2 parents 7b5d9a3 + 8a768a1 commit 32563cf
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 32563cf

Please sign in to comment.