Skip to content

Commit ecf01f1

Browse files
authored
fix: bug in dashboard search query (#73)
* fix: bug in dashboard search query * updates CHANGELOG and version info * reverts unnecessary changes
1 parent 8e67f85 commit ecf01f1

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/main/java/io/supertokens/storage/postgresql/queries/GeneralQueries.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ public static AuthRecipeUserInfo[] getUsers(Start start, @NotNull Integer limit,
442442
// check if email tag is present
443443
if (dashboardSearchTags.emails != null) {
444444

445-
QUERY += " WHERE thirdPartyTable.email LIKE ? OR thirdPartyTable.email LIKE ?";
445+
QUERY += " WHERE ( thirdPartyTable.email LIKE ? OR thirdPartyTable.email LIKE ?";
446446
queryList.add(dashboardSearchTags.emails.get(0) + "%");
447447
queryList.add("%@" + dashboardSearchTags.emails.get(0) + "%");
448448

@@ -452,6 +452,8 @@ public static AuthRecipeUserInfo[] getUsers(Start start, @NotNull Integer limit,
452452
queryList.add("%@" + dashboardSearchTags.emails.get(i) + "%");
453453
}
454454

455+
QUERY += " )";
456+
455457
}
456458

457459
// check if providers tag is present
@@ -462,12 +464,14 @@ public static AuthRecipeUserInfo[] getUsers(Start start, @NotNull Integer limit,
462464
QUERY += " WHERE ";
463465
}
464466

465-
QUERY += " thirdPartyTable.third_party_id LIKE ?";
467+
QUERY += " ( thirdPartyTable.third_party_id LIKE ?";
466468
queryList.add(dashboardSearchTags.providers.get(0) + "%");
467469
for (int i = 1; i < dashboardSearchTags.providers.size(); i++) {
468470
QUERY += " OR thirdPartyTable.third_party_id LIKE ?";
469471
queryList.add(dashboardSearchTags.providers.get(i) + "%");
470472
}
473+
474+
QUERY += " )";
471475
}
472476

473477
// check if we need to append this to an existing search query
@@ -493,14 +497,16 @@ public static AuthRecipeUserInfo[] getUsers(Start start, @NotNull Integer limit,
493497
// check if email tag is present
494498
if (dashboardSearchTags.emails != null) {
495499

496-
QUERY = QUERY + " WHERE passwordlessTable.email LIKE ? OR passwordlessTable.email LIKE ?";
500+
QUERY = QUERY + " WHERE ( passwordlessTable.email LIKE ? OR passwordlessTable.email LIKE ?";
497501
queryList.add(dashboardSearchTags.emails.get(0) + "%");
498502
queryList.add("%@" + dashboardSearchTags.emails.get(0) + "%");
499503
for (int i = 1; i < dashboardSearchTags.emails.size(); i++) {
500504
QUERY += " OR passwordlessTable.email LIKE ? OR passwordlessTable.email LIKE ?";
501505
queryList.add(dashboardSearchTags.emails.get(i) + "%");
502506
queryList.add("%@" + dashboardSearchTags.emails.get(i) + "%");
503507
}
508+
509+
QUERY += " )";
504510
}
505511

506512
// check if phone tag is present
@@ -512,20 +518,14 @@ public static AuthRecipeUserInfo[] getUsers(Start start, @NotNull Integer limit,
512518
QUERY += " WHERE ";
513519
}
514520

515-
QUERY += " passwordlessTable.phone_number LIKE ?";
516-
if (dashboardSearchTags.phoneNumbers.get(0).startsWith("+")) {
517-
queryList.add(dashboardSearchTags.phoneNumbers.get(0) + "%");
518-
} else {
519-
queryList.add("+" + dashboardSearchTags.phoneNumbers.get(0) + "%");
520-
}
521+
QUERY += " ( passwordlessTable.phone_number LIKE ?";
522+
queryList.add(dashboardSearchTags.phoneNumbers.get(0) + "%");
521523
for (int i = 1; i < dashboardSearchTags.phoneNumbers.size(); i++) {
522524
QUERY += " OR passwordlessTable.phone_number LIKE ?";
523-
if (dashboardSearchTags.phoneNumbers.get(i).startsWith("+")) {
524-
queryList.add(dashboardSearchTags.phoneNumbers.get(i) + "%");
525-
} else {
526-
queryList.add("+" + dashboardSearchTags.phoneNumbers.get(i) + "%");
527-
}
525+
queryList.add(dashboardSearchTags.phoneNumbers.get(i) + "%");
528526
}
527+
528+
QUERY += " )";
529529
}
530530

531531
// check if we need to append this to an existing search query

0 commit comments

Comments
 (0)