Test failing as there are some extra spaces, can i do anything about it?

Author: JleagleCreated May 18, 2025Updated Aug 27, 2026

I have a test with:

go
mock.ExpectExec(`UPDATE public.project_member SET ("order", updated_at) = ($1, $2) WHERE ((project_member.project_id = $3::varchar(20)) AND (project_member.user_id = $4::varchar(20)));`).

and it's failing as the actual query is:

sql
UPDATE public.project_member SET ("order", updated_at) = ($1, $2) WHERE ( (project_member.project_id = $3::varchar(20)) AND (project_member.user_id = $4::varchar(20)) );

Which is the same except a couple of spaces which shouldn't effect anything.

I have tried with sqlmock.New() and sqlmock.New(sqlmock.QueryMatcherOption(sqlmock.QueryMatcherEqual)).

Is there something i can do other than add spaces to the expected SQL? Im using a SQL generator so can't change the query run.

Thanks!