jmoiron / sqlx

general purpose extensions to golang's database/sql
http://jmoiron.github.io/sqlx/
MIT License
16.3k stars 1.09k forks source link

sqlx.Named could not find name #947

Open danqiye1 opened 1 month ago

danqiye1 commented 1 month ago

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

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

[]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.