Skip to content

Commit

Permalink
Change les TRUE en 1 dans les requêtes SQL en dur
Browse files Browse the repository at this point in the history
* compatible avec sqlite<=3.22
* compatible avec MariaDB/MySQL
  • Loading branch information
Arnaud-D authored and Situphen committed Sep 21, 2021
1 parent ecfa438 commit 2378a7c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions zds/tutorialv2/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __get_list(self, subcategories=None, tags=None, content_type=None, with_comm
FROM tutorialv2_contentreaction,utils_comment
WHERE tutorialv2_contentreaction.related_content_id=`tutorialv2_publishablecontent`.`id`
AND utils_comment.id=tutorialv2_contentreaction.comment_ptr_id
AND utils_comment.is_visible = TRUE
AND utils_comment.is_visible = 1
"""

queryset = queryset.extra(select={"count_note": sub_query})
Expand Down Expand Up @@ -237,7 +237,7 @@ def get_last_articles(self, number=0):
:return: list of last articles expanded with 'count_note' property that prefetches number of comments
:rtype: list
"""
sub_query = "SELECT COUNT(*) FROM {} WHERE {}={} AND {}={} AND utils_comment.is_visible=TRUE".format(
sub_query = "SELECT COUNT(*) FROM {} WHERE {}={} AND {}={} AND utils_comment.is_visible=1".format(
"tutorialv2_contentreaction,utils_comment",
"tutorialv2_contentreaction.related_content_id",
"tutorialv2_publishedcontent.content_pk",
Expand Down
2 changes: 1 addition & 1 deletion zds/tutorialv2/views/lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def get_queryset(self):
:return: list of contents with the right type
:rtype: list of zds.tutorialv2.models.database.PublishedContent
"""
sub_query = "SELECT COUNT(*) FROM {} WHERE {}={} AND {}={} AND utils_comment.is_visible=TRUE".format(
sub_query = "SELECT COUNT(*) FROM {} WHERE {}={} AND {}={} AND utils_comment.is_visible=1".format(
"tutorialv2_contentreaction,utils_comment",
"tutorialv2_contentreaction.related_content_id",
"tutorialv2_publishablecontent.id",
Expand Down

0 comments on commit 2378a7c

Please sign in to comment.