squirrel icon indicating copy to clipboard operation
squirrel copied to clipboard

Named and positional placeholder support

Open gonzojive opened this issue 3 years ago • 1 comments

I only see documentation for using '?' as a placeholder. This is a request for more robust placeholder syntax, so the following would work:

Desired behavior:

keyBytes := req.GetKey().GetKeyBytes()
valueBytes := req.GetValue().GetValueBytes()
insertBuilder := psq.Insert("keyvals(key, value)").Values(keyBytes, valueBytes)
if req.GetOverwrite() {
  insertBuilder = insertBuilder.Suffix("ON CONFLICT DO UPDATE SET value = ?{2}")
}

Possible today:

keyBytes := req.GetKey().GetKeyBytes()
valueBytes := req.GetValue().GetValueBytes()
insertBuilder := psq.Insert("keyvals(key, value)").Values(keyBytes, valueBytes)
if req.GetOverwrite() {
  insertBuilder = insertBuilder.Suffix("ON CONFLICT DO UPDATE SET value = ?", valueBytes)
}

gonzojive avatar May 08 '22 17:05 gonzojive

Long ago I considered adding support for other parameter syntax, but it would be a ton of work with squirrel's existing design. I don't think it is going to happen in this project.

lann avatar May 09 '22 13:05 lann