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

Update VS code SQL highlighting extension #392

Merged
merged 1 commit into from
Sep 6, 2022
Merged

Update VS code SQL highlighting extension #392

merged 1 commit into from
Sep 6, 2022

Conversation

aust1nz
Copy link
Contributor

@aust1nz aust1nz commented Aug 30, 2022

This is a simple readme-only update that points users to the vscode-sql-lit extension.

The extension was recently updated and supports SQL highlighting even when using the sql.type(zodType)`SELECT * from Users`; syntax, unlike the previously recommended extension.

vscode-sql-lit has support for a wider variety of SQL tagging, including sql with the new sql.type(zodType)`SELECT * FROM TABLE` syntax.
@gajus
Copy link
Owner

gajus commented Sep 5, 2022

Nice, I was looking for something that would work with .type!

@gajus
Copy link
Owner

gajus commented Sep 5, 2022

@aust1nz are you the author of lit?

Unfortunately it does not work if sql.type definition is multi-line, e.g.

sql.type(
  z.object({
    id: z.number(),
    // ...
  }),
)`
  SELECT
    tr1.id,
    tr1.created_at "createdAt",
    tr1.started_at "startedAt"
`

@aust1nz
Copy link
Contributor Author

aust1nz commented Sep 5, 2022

Ah, didn't look for that syntax! I'm not the library maintainer but did open a PR last week that the maintainer merged/pushed. Let me see if I can figure out the appropriate regex for that syntax. I'll follow up if I can get the lib updated.

@aust1nz
Copy link
Contributor Author

aust1nz commented Sep 6, 2022

Ack, upon further review, it doesn't look like multi-line syntax highlighting is supported in VS Code. Source

So, neither library will highlight this syntax properly:

sql.type(
  z.object({
    id: z.number(),
    // ...
  }),
)`
  SELECT
    tr1.id,
    tr1.created_at "createdAt",
    tr1.started_at "startedAt"
`

However, the suggested vscode-sql-lit library IS an improvement over the current selection, because it WILL successfully highlight the following:

const zodObject =
  z.object({
    id: z.number(),
    // ...
  });

sql.type(zodObject)`
  SELECT
    tr1.id,
    tr1.created_at "createdAt",
    tr1.started_at "startedAt"

Defer to your judgment if that level of improvement merits updated docs. I think it’s a nice quality of life improvement, even if it’s not a perfect SQL highlighting match.

@gajus gajus merged commit 9615201 into gajus:main Sep 6, 2022
@aust1nz aust1nz temporarily deployed to release September 6, 2022 14:17 Inactive
@aust1nz aust1nz temporarily deployed to release September 6, 2022 14:17 Inactive
@aust1nz aust1nz temporarily deployed to release September 6, 2022 14:17 Inactive
@aust1nz aust1nz temporarily deployed to release September 6, 2022 14:17 Inactive
@aust1nz aust1nz temporarily deployed to release September 6, 2022 14:17 Inactive
@github-actions
Copy link
Contributor

github-actions bot commented Sep 7, 2022

🎉 This PR is included in version 30.4.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants