瀏覽代碼

fixes search bug not showing not shared data. this was due to a buggy use of join instead of outerjoin. look at http://stackoverflow.com/questions/448023/what-is-the-difference-between-left-right-outer-and-inner-joins for explanation

root 11 年之前
父節點
當前提交
fe3fd95766
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      pboard/pboard/lib/dbapi.py

+ 2 - 2
pboard/pboard/lib/dbapi.py 查看文件

336
     Returns a list of nodes order by type, nodes which contain at least one of the keywords
336
     Returns a list of nodes order by type, nodes which contain at least one of the keywords
337
     """
337
     """
338
     liOwnerIdList = self._getUserIdListForFiltering()
338
     liOwnerIdList = self._getUserIdListForFiltering()
339
-
339
+    print ("AGAGA, ", liOwnerIdList)
340
     loKeywordFilteringClauses = []
340
     loKeywordFilteringClauses = []
341
     for keyword in plKeywordList:
341
     for keyword in plKeywordList:
342
         loKeywordFilteringClauses.append(pbmd.PBNode.data_label.ilike('%'+keyword+'%'))
342
         loKeywordFilteringClauses.append(pbmd.PBNode.data_label.ilike('%'+keyword+'%'))
345
 
345
 
346
     loKeywordFilteringClausesAsOr = sqla.or_(*loKeywordFilteringClauses) # Combine them with or to a BooleanClauseList
346
     loKeywordFilteringClausesAsOr = sqla.or_(*loKeywordFilteringClauses) # Combine them with or to a BooleanClauseList
347
 
347
 
348
-    loResultsForSomeKeywords = pbm.DBSession.query(pbmd.PBNode).options(joinedload_all("_lAllChildren")).join(pbma.Rights).join(pbma.user_group_table, pbma.Rights.group_id==pbma.user_group_table.columns['group_id'])\
348
+    loResultsForSomeKeywords = pbm.DBSession.query(pbmd.PBNode).options(joinedload_all("_lAllChildren")).outerjoin(pbma.Rights).outerjoin(pbma.user_group_table, pbma.Rights.group_id==pbma.user_group_table.columns['group_id'])\
349
         .filter(loKeywordFilteringClausesAsOr)\
349
         .filter(loKeywordFilteringClausesAsOr)\
350
         .filter((pbmd.PBNode.owner_id.in_(liOwnerIdList)) | (pbma.user_group_table.c.user_id.in_(liOwnerIdList) & pbmd.PBNode.is_shared))\
350
         .filter((pbmd.PBNode.owner_id.in_(liOwnerIdList)) | (pbma.user_group_table.c.user_id.in_(liOwnerIdList) & pbmd.PBNode.is_shared))\
351
         .order_by(sqla.desc(pbmd.PBNode.node_type))\
351
         .order_by(sqla.desc(pbmd.PBNode.node_type))\