Fix profile load by org query

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-02-19 14:41:12 +04:00
parent c36156c18a
commit 587f59d167
2 changed files with 21 additions and 17 deletions

View File

@@ -289,22 +289,22 @@ WITH profiles AS (
AND %s AND %s
) )
SELECT SELECT
p.id, id,
p.identity_id, identity_id,
p.organization_id, organization_id,
p.email_address, email_address,
p.source, source,
p.state, state,
p.full_name, full_name,
p.kind, kind,
p.additional_email_addresses, additional_email_addresses,
p.position, position,
p.contract_start_date, contract_start_date,
p.contract_end_date, contract_end_date,
'' AS organization_name, '' AS organization_name,
p.created_at, created_at,
p.updated_at updated_at
FROM profiles p FROM profiles
WHERE WHERE
%s %s
` `
@@ -313,6 +313,8 @@ WHERE
args := pgx.NamedArgs{"organization_id": organizationID} args := pgx.NamedArgs{"organization_id": organizationID}
maps.Copy(args, scope.SQLArguments()) maps.Copy(args, scope.SQLArguments())
maps.Copy(args, filter.SQLArguments())
maps.Copy(args, cursor.SQLArguments())
rows, err := conn.Query(ctx, q, args) rows, err := conn.Query(ctx, q, args)
if err != nil { if err != nil {
@@ -385,6 +387,8 @@ WHERE
q = fmt.Sprintf(q, filter.SQLFragment(), cursor.SQLFragment()) q = fmt.Sprintf(q, filter.SQLFragment(), cursor.SQLFragment())
args := pgx.NamedArgs{"identity_id": identityID} args := pgx.NamedArgs{"identity_id": identityID}
maps.Copy(args, filter.SQLArguments())
maps.Copy(args, cursor.SQLArguments())
rows, err := conn.Query(ctx, q, args) rows, err := conn.Query(ctx, q, args)
if err != nil { if err != nil {

View File

@@ -79,8 +79,8 @@ func (f *MembershipProfileFilter) SQLFragment() string {
return ` return `
( (
CASE CASE
WHEN @filter_email::text IS NOT NULL THEN WHEN @filter_email::citext IS NOT NULL THEN
i.email_address = @filter_email::text i.email_address = @filter_email::citext
ELSE TRUE ELSE TRUE
END END
) )