go-sqlmock icon indicating copy to clipboard operation
go-sqlmock copied to clipboard

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

Open Jleagle opened this issue 6 months ago • 0 comments
trafficstars

I have a test with:

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:

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!

Jleagle avatar May 18 '25 09:05 Jleagle