cmoog / vscode-sql-notebook

Open SQL files as VSCode Notebooks.
https://marketplace.visualstudio.com/items?itemName=cmoog.sqlnotebook
MIT License
129 stars 18 forks source link

JSON on-disk notebook format #34

Closed RollsChris closed 2 years ago

RollsChris commented 2 years ago

When I open a .sql as a notebook and then come back on and open it normally and format it.. you loose the code cells. I think it's because your using /n/n as your delimitator, the formatter adds them back.

I have created a customserializer. I think it would be better ( it also persists the output ) I got inspiration from the rest book implementation....

I have started to have an issue where the play button has disappeared and the code cells default to plain text?

I'm still a bit of a noob and I was wondering if you could take a look and if you like it maybe pull it in?

I forked your repo here https://github.com/CR-OpenSource/vscode-sql-notebook

and made a branch "CustomSerializer"...

Thanks chris

cmoog commented 2 years ago

You're correct that using \n\n as the cell delimiter is not perfect and sometimes results in cell boundaries shifting. But, I do not think it can result in lost code or markdown content. If you think this is the case, please share an example input that will serialize and deserialize in a lossy way. Until then, I'm going to change the title of this issue so as to not alarm users.

Regarding your fork... the branch CustomSerializer assumes that the underlying file format is stored as JSON. But, vscode-sql-notebook currently only supports serializing/deserializing plain .sql files. So, we cannot store structured JSON as the on-disk serialized format. We need to transform to and from plain text sql files.

As mentioned in #32, the existing limitations of plain .sql files means it does make sense to adopt a JSON like format, but that will first need to be separated into a different file extension and have more intentional design choices.

cmoog commented 2 years ago

Actually, this is essentially a duplicate of #32. Please continue the discussion there.

RollsChris commented 2 years ago

hey sorry you are right, you don't loose any code but you do loose wasted time setting out a nice notebook lol.

Ill carry the discussion over on #32