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

[BUG] Encode Selection as M Text Value is missing escapes on complex values #167

Open
ninmonkey opened this issue Sep 22, 2022 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@ninmonkey
Copy link
Contributor

ninmonkey commented Sep 22, 2022

Expected behavior

I'm expecting the selected value will escaped quotes, converting it to a raw string.
I thought it would simplify adding the Code part of function's metadata ( Documentation.Examples )

For example this

let
    x  = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcszNr8hMzszJycxT0EgsVjBUcFTQVIrVwSbjjFNGAY8uhEwBskRxfkppLhYpoFkwWaBkLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Raw Name" = _t])
in 
    x

Expected Output

let
    x  = "Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText(""i45WcszNr8hMzszJycxT0EgsVjBUcFTQVIrVwSbjjFNGAY8uhEwBskRxfkppLhYpoFkwWaBkLAA="", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#""Raw Name"" = _t])"
in 
    x

Actual behavior

let
    x  = 
Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText(""i45WcszNr8hMzszJycxT0EgsVjBUcFTQVIrVwSbjjFNGAY8uhEwBskRxfkppLhYpoFkwWaBkLAA="", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#(#)""Raw Name"" = _t])
in 
    x

To Reproduce

VsCode.PowerQuery.-.text.to.M.expression.-.2022-09.-.export.1.mp4

Environment

Name Version
Extension [email protected]
Code code: 1.71.2, 74b1f979648cc44d385a2286793c226e611f59e7, x64
Pwsh>
    code.cmd --show-versions --list-extensions | sls 'powerquery'
    code.cmd --version | Join-String -sep ', ' -op 'vscode: '

Solution?

A naive replace appears to be working, at least for this sample

  1. Replace " with ""
  2. Surround that with ""
Pwsh> $Content -replace '"', '""'
    | Join-String -op '"' -os '"'
@ninmonkey ninmonkey added the bug Something isn't working label Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants