Select accounts where empty string

This commit is contained in:
tsmethurst 2021-06-03 21:13:13 +02:00
parent 31a24167fe
commit de3b6bc6d9

View File

@ -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)
}