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

Fix literals format #237

Merged

Conversation

apstndb
Copy link
Contributor

@apstndb apstndb commented Dec 19, 2024

This PR align literals format to Spanner/ZetaSQL FORMAT("%T", input) functions.

  • Generic quoted literals and quoted identifiers

    • ' ' and '~' should be printable characters.
    • Use lowercased hex rather than uppercased hex
    • Don't escape quotes except currently used.
    • Only \ is always escaped printable character.
    • Use single quote if double quote is not suitable.
  • String literals

    • Use \x%02x for non-printable runes of r <= 0x7f.
    • Use only \t, \r, \n in r < 0x20 instead of \x%02x.
  • Bytes literals

    • Use b"" rather than B"" for bytes literal
  • close Emulate string/bytes literal format in FORMAT("%T", input) #236

token/quote.go Outdated
if q != "" {
buf.WriteString(q)
continue
}
if char.IsPrint(b) {

// Note: char.IsPrint(' ') is false
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to fix char.IsPrint, isn't it?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. You could fix char.IsPrint.

Copy link
Collaborator

@makenowjust makenowjust left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@makenowjust makenowjust merged commit 0230ae2 into cloudspannerecosystem:main Dec 19, 2024
2 checks passed
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 this pull request may close these issues.

Emulate string/bytes literal format in FORMAT("%T", input)
2 participants