From e5b93feb1e8e2bcecadb7c96e379252ec155c523 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Thu, 5 Sep 2019 14:44:46 -0400 Subject: [PATCH] GUACAMOLE-870: Replace POSITION with CHARINDEX for SQL Server. --- .../auth/jdbc/connection/ConnectionRecordMapper.xml | 8 ++++---- .../apache/guacamole/auth/jdbc/user/UserRecordMapper.xml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ConnectionRecordMapper.xml b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ConnectionRecordMapper.xml index 2abf1ae35..5d97b0b88 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ConnectionRecordMapper.xml +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ConnectionRecordMapper.xml @@ -113,13 +113,13 @@ [guacamole_connection_history].user_id IN ( SELECT user_id FROM [guacamole_user] - WHERE POSITION(#{term.term,jdbcType=VARCHAR} IN username) > 0 + WHERE CHARINDEX(#{term.term,jdbcType=VARCHAR}, username) > 0 ) OR [guacamole_connection_history].connection_id IN ( SELECT connection_id FROM [guacamole_connection] - WHERE POSITION(#{term.term,jdbcType=VARCHAR} IN connection_name) > 0 + WHERE CHARINDEX(#{term.term,jdbcType=VARCHAR}, connection_name) > 0 ) @@ -191,14 +191,14 @@ FROM [guacamole_user] JOIN [guacamole_entity] ON [guacamole_user].entity_id = [guacamole_entity].entity_id WHERE - POSITION(#{term.term,jdbcType=VARCHAR} IN [guacamole_entity].name) > 0 + CHARINDEX(#{term.term,jdbcType=VARCHAR}, [guacamole_entity].name) > 0 AND [guacamole_entity].type = 'USER' ) OR [guacamole_connection_history].connection_id IN ( SELECT connection_id FROM [guacamole_connection] - WHERE POSITION(#{term.term,jdbcType=VARCHAR} IN connection_name) > 0 + WHERE CHARINDEX(#{term.term,jdbcType=VARCHAR}, connection_name) > 0 ) diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/resources/org/apache/guacamole/auth/jdbc/user/UserRecordMapper.xml b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/resources/org/apache/guacamole/auth/jdbc/user/UserRecordMapper.xml index 4d4a3cc69..7cc5efabb 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/resources/org/apache/guacamole/auth/jdbc/user/UserRecordMapper.xml +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/resources/org/apache/guacamole/auth/jdbc/user/UserRecordMapper.xml @@ -114,7 +114,7 @@ FROM [guacamole_user] JOIN [guacamole_entity] ON [guacamole_user].entity_id = [guacamole_entity].entity_id WHERE - POSITION(#{term.term,jdbcType=VARCHAR} IN [guacamole_entity].name) > 0 + CHARINDEX(#{term.term,jdbcType=VARCHAR}, [guacamole_entity].name) > 0 AND [guacamole_entity].type = 'USER'), ) @@ -171,7 +171,7 @@ FROM [guacamole_user] JOIN [guacamole_entity] ON [guacamole_user].entity_id = [guacamole_entity].entity_id WHERE - POSITION(#{term.term,jdbcType=VARCHAR} IN [guacamole_entity].name) > 0 + CHARINDEX(#{term.term,jdbcType=VARCHAR}, [guacamole_entity].name) > 0 AND [guacamole_entity].type = 'USER' )