The Go sql package (for instance) provides a means for driver implementers to escape user provided values by way of the separation of a parametric query string and the user provided values like so: Exec(query string, args ...interface{}). Is it possible to do something similar with N1QL using the gocb package?
Alternatively has anybody written a general purpose wrapper that escapes user provided values for N1QL correctly (in any programming language)? Also if somebody could point me to the formal spec for the N1QL language and specifically anything that would help pin down the exact characters that need to be escaped (and how that escaping must be done), that would be very helpful and appreciated.
So now I will go digging through server code to try to find out how to format the parameters and whether they’re escaped (unless somebody has more easily accessible information).
SQL injection attacks are possible with N1QL, however the SDK’s provides a means of substitution which is done on the server, which protects the consuming application.
Thanks jmorris! Definitely interesting to note that (despite being schemaless):
there is no named parameter equivalent for identifiers
In my specific use case when dealing with identifiers / schema related stuff I’ll likely maintain an explicit mapping in the application rather than using user supplied data for that.