From 9cc7fb49b3d5ab2c0b963a5eb6497f385378eca0 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 3 Feb 2023 04:05:47 +0300 Subject: Make new queries compatible --- src/main/java/com/juick/service/TagServiceImpl.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/main/java/com') diff --git a/src/main/java/com/juick/service/TagServiceImpl.java b/src/main/java/com/juick/service/TagServiceImpl.java index 403f05c4..9b8b4d95 100644 --- a/src/main/java/com/juick/service/TagServiceImpl.java +++ b/src/main/java/com/juick/service/TagServiceImpl.java @@ -72,8 +72,8 @@ public class TagServiceImpl extends BaseJdbcService implements TagService { public Tag getTag(int userId, int tid) { List list = namedParameterJdbcTemplate.query(""" SELECT tag_id, synonym_id, name, noindex, notop, - (EXISTS(SELECT 1 FROM bl_tags WHERE tag_id=:tagId AND user_id=:userId)) ignored, - (EXISTS(SELECT 1 FROM subscr_tags WHERE tag_id=:tagId AND suser_id=:userId)) subscribed + COALESCE((SELECT 1 FROM bl_tags WHERE tag_id=:tagId AND user_id=:userId), 0) ignored, + COALESCE((SELECT 1 FROM subscr_tags WHERE tag_id=:tagId AND suser_id=:userId), 0) subscribed FROM tags WHERE tag_id = :tagId""", new MapSqlParameterSource() .addValue("userId", userId) @@ -95,8 +95,8 @@ public class TagServiceImpl extends BaseJdbcService implements TagService { return null; List list = namedParameterJdbcTemplate.query(""" SELECT t.tag_id, t.synonym_id, t.name, t.noindex, t.notop, - (EXISTS(SELECT 1 FROM bl_tags WHERE tag_id=t.tag_id AND user_id=:userId)) ignored, - (EXISTS(SELECT 1 FROM subscr_tags WHERE tag_id=t.tag_id AND suser_id=:userId)) subscribed + COALESCE((SELECT 1 FROM bl_tags WHERE tag_id=t.tag_id AND user_id=:userId), 0) ignored, + COALESCE((SELECT 1 FROM subscr_tags WHERE tag_id=t.tag_id AND suser_id=:userId), 0) subscribed FROM (SELECT tag_id, synonym_id, name, noindex, notop FROM tags) t WHERE name = :tagName""", new MapSqlParameterSource() -- cgit v1.2.3