#947·sqlx

sqlx.Named could not find name

Author: danqiye1Created Oct 1, 2024Updated Sep 6, 2025

The function sqlx.Named seems to be registering extra bind variables. For example, if I do the following:

go
sqlx.Named(`select id, title, 'http://example.com' as link 
		from mytable 
		where id = (:input_id)`, map[string]interface{}{"input_id": 1})

I will get the following names

go
[]string{"", "input_id"}

which means sqlx.Named incorrectly identified the colon in 'http://example.com' as a beginning of a named argument. Is there a way to fix this or perhaps a workaround to this, as I do have regex + hardcoded urls in my CTE.