aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/service/UserServiceImpl.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2023-01-28 19:21:17 +0300
committerGravatar Vitaly Takmazov2023-01-28 19:54:12 +0300
commit4b1ff0806def1d7e632852f209bfda9c29093524 (patch)
tree67b1ca5b20cc1ac3b750d8d5fc9987281613a3a0 /src/main/java/com/juick/service/UserServiceImpl.java
parent556d10c400add4b69d8832a40fb704fda4333080 (diff)
Update recursive CTEs
Diffstat (limited to 'src/main/java/com/juick/service/UserServiceImpl.java')
-rw-r--r--src/main/java/com/juick/service/UserServiceImpl.java4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/main/java/com/juick/service/UserServiceImpl.java b/src/main/java/com/juick/service/UserServiceImpl.java
index ca63c322..77fb2e72 100644
--- a/src/main/java/com/juick/service/UserServiceImpl.java
+++ b/src/main/java/com/juick/service/UserServiceImpl.java
@@ -51,6 +51,8 @@ public class UserServiceImpl extends BaseJdbcService implements UserService {
@Value("${juick.admin_users:}")
List<String> adminUsers;
+ @Value("#{new Boolean('${spring.sql.init.platform}' == 'sqlserver')}")
+ private boolean omitRecursiveKeyword;
private static class UserMapper implements RowMapper<User> {
@Override
@@ -392,7 +394,7 @@ public class UserServiceImpl extends BaseJdbcService implements UserService {
@Transactional(readOnly = true)
@Override
public boolean isReplyToBL(final User user, final Message reply) {
- var replies = getNamedParameterJdbcTemplate().queryForList("WITH RECURSIVE banned(reply_id, user_id) AS (" +
+ var replies = getNamedParameterJdbcTemplate().queryForList((omitRecursiveKeyword ? "WITH " : "WITH RECURSIVE ") + "banned(reply_id, user_id) AS (" +
"SELECT reply_id, user_id FROM replies " +
"WHERE replies.message_id = :mid " +
"AND EXISTS (SELECT 1 FROM bl_users b WHERE b.user_id = :uid AND b.bl_user_id = replies.user_id) " +