diff --git a/src/main/java/io/kamax/mxisd/backend/sql/synapse/SynapseQueries.java b/src/main/java/io/kamax/mxisd/backend/sql/synapse/SynapseQueries.java index 40f621f9..d13a2ed6 100644 --- a/src/main/java/io/kamax/mxisd/backend/sql/synapse/SynapseQueries.java +++ b/src/main/java/io/kamax/mxisd/backend/sql/synapse/SynapseQueries.java @@ -51,7 +51,7 @@ public static String findByDisplayName(String type, String domain) { if (StringUtils.equals("sqlite", type)) { return "select " + getUserId(type, domain) + ", displayname from profiles p where displayname like ?"; } else if (StringUtils.equals("postgresql", type)) { - return "select " + getUserId(type, domain) + ", displayname from profiles p where displayname ilike ?"; + return "SELECT u.name,p.displayname FROM users u JOIN profiles p ON u.name LIKE concat('@',p.user_id,':%') WHERE u.is_guest = 0 AND u.appservice_id IS NULL AND p.displayname LIKE ?"; } else { throw new ConfigurationException("Invalid Synapse SQL type: " + type); }