@@ -667,30 +667,32 @@ async def find_many_organization_ids_by_identities(identities: list[dict]) -> li
667667 param_index = 1
668668 for idx , identity in enumerate (identities ):
669669 values_parts .append (
670- f"(${ param_index } ::int, ${ param_index + 1 } ::text,"
671- f" ${ param_index + 2 } ::boolean , ${ param_index + 3 } ::text)"
670+ f"(${ param_index } ::int, ${ param_index + 1 } ::text, $ { param_index + 2 } ::boolean, "
671+ f" ${ param_index + 3 } ::text , ${ param_index + 4 } ::text)"
672672 )
673673 params .extend (
674674 [
675675 idx ,
676676 identity ["type" ],
677677 identity .get ("verified" , True ),
678+ identity ["platform" ],
678679 identity ["value" ],
679680 ]
680681 )
681- param_index += 4
682+ param_index += 5
682683
683684 matches_by_idx : dict [int , set [str ]] = {}
684685 rows = await query (
685686 f"""
686- WITH input_identities (idx, identity_type, verified, value) AS (
687+ WITH input_identities (idx, identity_type, verified, platform, value) AS (
687688 VALUES { ", " .join (values_parts )}
688689 )
689690 SELECT i.idx, oi."organizationId"
690691 FROM input_identities i
691692 LEFT JOIN "organizationIdentities" oi
692693 ON oi.type = i.identity_type
693694 AND oi.verified = i.verified
695+ AND oi.platform = i.platform
694696 AND lower(oi.value) = lower(i.value)
695697 ORDER BY i.idx
696698 """ ,
@@ -708,6 +710,7 @@ async def find_many_organization_ids_by_identities(identities: list[dict]) -> li
708710 results .append (
709711 {
710712 "type" : identity ["type" ],
713+ "platform" : identity ["platform" ],
711714 "value" : identity ["value" ],
712715 "verified" : identity .get ("verified" , True ),
713716 "organization_id" : organization_id ,
0 commit comments