Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Go language #95

Open
alochym01 opened this issue Feb 21, 2022 · 2 comments
Open

Support Go language #95

alochym01 opened this issue Feb 21, 2022 · 2 comments

Comments

@alochym01
Copy link

No description provided.

@jschaf
Copy link

jschaf commented Mar 14, 2022

Are y'all open to PRs for this? If so:

  • Do you have preferred API approach? Should I aim for idiomatic Go or consistency with an existing API?

If the goal is idiomatic Go, I think the API is probably similar to url.Values: https://pkg.go.dev/net/url#Values

@sjs994
Copy link
Collaborator

sjs994 commented Mar 15, 2022

Thanks @jschaf. It would be really great to have the community contribute for this feature.

Do you have preferred API approach? Should I aim for idiomatic Go or consistency with an existing API?

We would want to go with the existing API as we need a consistent spec. It would not make sense to have database instrumentation spec change for different languages.

jschaf added a commit to jschaf/sqlcommenter that referenced this issue Mar 21, 2022
This implements the SQL Commenter specification for affixing comments to a
SQL query. Loosely inspired by url.Values [1] in the Go standard library.

The specification doesn't fully describe the following situation, so I'll
list the intended behavior of the Go implementation here:

- Empty keys: omitted and don't appear in the comment string.

- Keys with single quotes: this Go library uses the valid URL encoding
  of a single quote `%27` instead of escaping with a backslash. The
  spec has the confusing example: `name''` serialized to `name=\'\'`.
  Where did the equal sign come from? Also, the website shows fancy
  quotes, not plain ascii quotes.

- Already URL encoded values: this Go library double-encodes the value,
  meaning the key-pair `a=%3D` is encoded as `a='%253D'`. The spec exhibit
  doesn't double-encode, instead preserving the original percent encoding.
  That seems inadvisable since the parsing a serialized sql comment won't
  result in the same original values.

Fixes google#95.

[1]: https://pkg.go.dev/net/url#Values
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants