Skip to content

Commit

Permalink
[ISSUE #9414] Optimize fuzzy queries to make SQL more general (#9428)
Browse files Browse the repository at this point in the history
  • Loading branch information
liuchen6 authored Oct 31, 2022
1 parent 2596ff3 commit 0a80276
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ public void deleteRole(String role, String username) {

@Override
public List<String> findRolesLikeRoleName(String role) {
String sql = "SELECT role FROM roles WHERE role LIKE '%' ? '%'";
List<String> users = this.jt.queryForList(sql, new String[] {role}, String.class);
String sql = "SELECT role FROM roles WHERE role LIKE ?";
List<String> users = this.jt.queryForList(sql, new String[] {String.format("%%%s%%", role)}, String.class);
return users;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ public Page<User> getUsers(int pageNo, int pageSize, String username) {

@Override
public List<String> findUserLikeUsername(String username) {
String sql = "SELECT username FROM users WHERE username LIKE '%' ? '%'";
List<String> users = this.jt.queryForList(sql, new String[] {username}, String.class);
String sql = "SELECT username FROM users WHERE username LIKE ?";
List<String> users = this.jt.queryForList(sql, new String[]{String.format("%%%s%%", username)}, String.class);
return users;
}

Expand Down

0 comments on commit 0a80276

Please sign in to comment.