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

cli: fix double-quote escaping for JSON values with format=sql #131881

Merged
merged 1 commit into from
Oct 4, 2024

Commits on Oct 4, 2024

  1. cli: fix double-quote escaping for JSON values with format=sql

    A previous commit (98f9c8a) made an
    attempt to fix how JSON values are escaped when they contain invalid
    UTF8 codes and are displayed in the CLI using the --format=sql flag
    (see cockroachdb#107518).
    
    That commit ended up breaking how JSON values are escaped when they
    contain double quotes.
    
    Luckily it turns out that both problems were actually caused by a
    long-lived mistake in the `clisqlexec.FormatVal` function. It shouldn't
    use `fmt.Sprintf("%+q", s)` to escape a string that has invalid
    characters, as that conflicts with how SQL strings are normally escaped.
    The proper way is to use `lexbase.EscapeSQLString(s)`.
    
    Release note (bug fix): Fixed a bug where the CLI would not correctly
    escape JSON values that had double-quotes inside of a string when using
    the --format=sql flag.
    rafiss committed Oct 4, 2024
    Configuration menu
    Copy the full SHA
    fcc3621 View commit details
    Browse the repository at this point in the history