From de3b6bc6d9c0fbbd23197ae7dd2a6f5b544f7415 Mon Sep 17 00:00:00 2001 From: tsmethurst Date: Thu, 3 Jun 2021 21:13:13 +0200 Subject: [PATCH] Select accounts where empty string --- internal/db/pg/pg.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/db/pg/pg.go b/internal/db/pg/pg.go index 5c6720a..d4f8d10 100644 --- a/internal/db/pg/pg.go +++ b/internal/db/pg/pg.go @@ -464,10 +464,18 @@ func (ps *postgresService) GetFollowersByAccountID(accountID string, followers * q := ps.conn.Model(followers) if localOnly { + // for local accounts let's get where domain is null OR where domain is an empty string, just to be safe + whereGroup := func(q *pg.Query) (*pg.Query, error) { + q = q. + WhereOr("? IS NULL", pg.Ident("a.domain")). + WhereOr("a.domain = ?", "") + return q, nil + } + q = q.ColumnExpr("follow.*"). Join("JOIN accounts AS a ON follow.account_id = TEXT(a.id)"). Where("follow.target_account_id = ?", accountID). - Where("? IS NULL", pg.Ident("a.domain")) + WhereGroup(whereGroup) } else { q = q.Where("target_account_id = ?", accountID) }