@@ -139,12 +139,16 @@ public static UserIdMapping[] getUserIdMappingWithEitherSuperTokensUserIdOrExter
139139 String userId )
140140 throws SQLException , StorageQueryException {
141141 String QUERY = "SELECT * FROM " + Config .getConfig (start ).getUserIdMappingTable ()
142- + " WHERE app_id = ? AND (supertokens_user_id = ? OR external_user_id = ?)" ;
142+ + " WHERE app_id = ? AND supertokens_user_id = ?"
143+ + " UNION ALL "
144+ + "SELECT * FROM " + Config .getConfig (start ).getUserIdMappingTable ()
145+ + " WHERE app_id = ? AND external_user_id = ?" ;
143146
144147 return execute (start , QUERY , pst -> {
145148 pst .setString (1 , appIdentifier .getAppId ());
146149 pst .setString (2 , userId );
147- pst .setString (3 , userId );
150+ pst .setString (3 , appIdentifier .getAppId ());
151+ pst .setString (4 , userId );
148152 }, result -> {
149153 ArrayList <UserIdMapping > userIdMappingArray = new ArrayList <>();
150154 while (result .next ()) {
@@ -375,12 +379,16 @@ public static UserIdMapping[] getUserIdMappingWithEitherSuperTokensUserIdOrExter
375379 String userId )
376380 throws SQLException , StorageQueryException {
377381 String QUERY = "SELECT * FROM " + Config .getConfig (start ).getUserIdMappingTable ()
378- + " WHERE app_id = ? AND (supertokens_user_id = ? OR external_user_id = ?)" ;
382+ + " WHERE app_id = ? AND supertokens_user_id = ?"
383+ + " UNION ALL "
384+ + "SELECT * FROM " + Config .getConfig (start ).getUserIdMappingTable ()
385+ + " WHERE app_id = ? AND external_user_id = ?" ;
379386
380387 return execute (sqlCon , QUERY , pst -> {
381388 pst .setString (1 , appIdentifier .getAppId ());
382389 pst .setString (2 , userId );
383- pst .setString (3 , userId );
390+ pst .setString (3 , appIdentifier .getAppId ());
391+ pst .setString (4 , userId );
384392 }, result -> {
385393 ArrayList <UserIdMapping > userIdMappingArray = new ArrayList <>();
386394 while (result .next ()) {
0 commit comments