GORM Playground Link
https://github.com/go-gorm/playground/pull/699
Description
In addition to JSON Path, we also need to use regexp_like() and other functions in SQL statement, in both cases ? literal is often used, for example where regexp_like(x.name, '.*(_|-)(done|done_flag(s)?|archive(d)?)$'.
But expression.go iterate the SQL string 1 char at a time, and when it sees ?, it jumps into the conclusion that this is a placeholder and tries to substitute it with the variable.
There seems no mechanism to escape ? literal in gorm at this point, I tested 2 syntaxes below w/o any luck:
* where regexp_like(x.name, '.*(_|-)(done|done_flag(s)\?|archive(d)\?)$'
* where regexp_like(x.name, '.*(_|-)(done|done_flag(s)??|archive(d)??)$'
Can we come up with a lookback logic to check the previous char in front of ?, so that we can safely identify \? in the string, and then we skip such string from builder.AddVar()? The potential patch should go into https://github.com/go-gorm/gorm/blob/master/clause/expression.go