@@ -136,7 +136,9 @@ public static UserIdMapping[] getUserIdMappingWithEitherSuperTokensUserIdOrExter
136136
137137 }
138138
139- public static HashMap <String , String > getUserIdMappingWithUserIds (Start start , List <String > userIds )
139+ public static HashMap <String , String > getUserIdMappingWithUserIds (Start start ,
140+ AppIdentifier appIdentifier ,
141+ List <String > userIds )
140142 throws SQLException , StorageQueryException {
141143
142144 if (userIds .size () == 0 ) {
@@ -145,7 +147,8 @@ public static HashMap<String, String> getUserIdMappingWithUserIds(Start start, L
145147
146148 // No need to filter based on tenantId because the id list is already filtered for a tenant
147149 StringBuilder QUERY = new StringBuilder (
148- "SELECT * FROM " + Config .getConfig (start ).getUserIdMappingTable () + " WHERE supertokens_user_id IN (" );
150+ "SELECT * FROM " + Config .getConfig (start ).getUserIdMappingTable () + " WHERE app_id = ? AND " +
151+ "supertokens_user_id IN (" );
149152 for (int i = 0 ; i < userIds .size (); i ++) {
150153 QUERY .append ("?" );
151154 if (i != userIds .size () - 1 ) {
@@ -155,9 +158,10 @@ public static HashMap<String, String> getUserIdMappingWithUserIds(Start start, L
155158 }
156159 QUERY .append (")" );
157160 return execute (start , QUERY .toString (), pst -> {
161+ pst .setString (1 , appIdentifier .getAppId ());
158162 for (int i = 0 ; i < userIds .size (); i ++) {
159- // i+1 cause this starts with 1 and not 0
160- pst .setString (i + 1 , userIds .get (i ));
163+ // i+2 cause this starts with 1 and not 0, 1 is appId
164+ pst .setString (i + 2 , userIds .get (i ));
161165 }
162166 }, result -> {
163167 HashMap <String , String > userIdMappings = new HashMap <>();
@@ -169,7 +173,9 @@ public static HashMap<String, String> getUserIdMappingWithUserIds(Start start, L
169173 });
170174 }
171175
172- public static HashMap <String , String > getUserIdMappingWithUserIds_Transaction (Start start , Connection sqlCon , List <String > userIds )
176+ public static HashMap <String , String > getUserIdMappingWithUserIds_Transaction (Start start , Connection sqlCon ,
177+ AppIdentifier appIdentifier ,
178+ List <String > userIds )
173179 throws SQLException , StorageQueryException {
174180
175181 if (userIds .size () == 0 ) {
@@ -178,7 +184,8 @@ public static HashMap<String, String> getUserIdMappingWithUserIds_Transaction(St
178184
179185 // No need to filter based on tenantId because the id list is already filtered for a tenant
180186 StringBuilder QUERY = new StringBuilder (
181- "SELECT * FROM " + Config .getConfig (start ).getUserIdMappingTable () + " WHERE supertokens_user_id IN (" );
187+ "SELECT * FROM " + Config .getConfig (start ).getUserIdMappingTable () + " WHERE app_id = ? AND " +
188+ "supertokens_user_id IN (" );
182189 for (int i = 0 ; i < userIds .size (); i ++) {
183190 QUERY .append ("?" );
184191 if (i != userIds .size () - 1 ) {
@@ -188,9 +195,10 @@ public static HashMap<String, String> getUserIdMappingWithUserIds_Transaction(St
188195 }
189196 QUERY .append (")" );
190197 return execute (sqlCon , QUERY .toString (), pst -> {
198+ pst .setString (1 , appIdentifier .getAppId ());
191199 for (int i = 0 ; i < userIds .size (); i ++) {
192- // i+1 cause this starts with 1 and not 0
193- pst .setString (i + 1 , userIds .get (i ));
200+ // i+2 cause this starts with 1 and not 0, 1 is appId
201+ pst .setString (i + 2 , userIds .get (i ));
194202 }
195203 }, result -> {
196204 HashMap <String , String > userIdMappings = new HashMap <>();
0 commit comments