Skip to content

Commit

Permalink
Do the lowercasing in Go, always
Browse files Browse the repository at this point in the history
  • Loading branch information
elffjs committed Dec 3, 2024
1 parent 7cd7a7f commit 9f14720
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions internal/rpc/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package rpc
import (
"context"
"fmt"
"strings"

"github.com/DIMO-Network/accounts-api/models"
pb "github.com/DIMO-Network/accounts-api/pkg/grpc"
Expand All @@ -22,7 +23,7 @@ type Server struct {
var emailJoin = fmt.Sprintf("%s ON %s = %s", models.TableNames.Emails, models.EmailTableColumns.AccountID, models.AccountTableColumns.ID)
var walletJoin = fmt.Sprintf("%s ON %s = %s", models.TableNames.Wallets, models.WalletTableColumns.AccountID, models.AccountTableColumns.ID)

var emailHas = fmt.Sprintf("position(lower(?) in lower(%s)) > 0", models.EmailTableColumns.Address)
var emailHas = fmt.Sprintf("position(? in %s) > 0", models.EmailTableColumns.Address)
var walletHas = fmt.Sprintf("position(? in %s) > 0", models.WalletTableColumns.Address)

func (s *Server) ListAccounts(ctx context.Context, in *pb.ListAccountsRequest) (*pb.ListAccountsResponse, error) {
Expand All @@ -36,7 +37,7 @@ func (s *Server) ListAccounts(ctx context.Context, in *pb.ListAccountsRequest) (
}

if in.PartialEmailAddress != "" {
mods = append(mods, qm.Where(emailHas, in.PartialEmailAddress))
mods = append(mods, qm.Where(emailHas, strings.ToLower(in.PartialEmailAddress)))
}
if addrLen := len(in.PartialWalletAddress); addrLen != 0 {
if addrLen > common.AddressLength {
Expand Down

0 comments on commit 9f14720

Please sign in to comment.