Giter Site home page Giter Site logo

Comments (9)

herenickname avatar herenickname commented on July 30, 2024

+1

from inline_sql_syntax.

karlhorky avatar karlhorky commented on July 30, 2024

Generic type arguments can be implemented (⚠️ if they are on a single line - I'll come back to this in a followup comment) - check out working versions of this feature in the following VS Code extensions:

  1. SQL tagged template literals by @frigus02 (repo: https://github.com/frigus02/vscode-sql-tagged-template-literals)
  2. Inline SQL by @notyetspecified (repo: https://github.com/notyetspecified/vscode-sql-template-literal)

In the following PR by @KristjanTammekivi, the generic type parameter feature was added to Inline SQL:

from inline_sql_syntax.

karlhorky avatar karlhorky commented on July 30, 2024

The problem with the original example in this current issue by @ariesclark above is that the generic type argument spans multiple lines.

The root cause for this is a bit more of a problem, since TextMate grammars have limitations, as @sheetalkamat is familiar with:

VS Code itself somehow gets around the limitations and can do correct syntax highlighting over multiple lines, maybe with Semantic Highlighting by @aeschli and @alexdima.

I also see some changes with regular expressions, which @sheetalkamat has also been maintaining:

So maybe there is a way for a VS Code extension to also achieve this, by also using this Semantic Highlighting / these regular expressions.

The TextMate grammar limitations have also been explored in the following SQL tagged template literals VS Code extension, but no solution has yet appeared:

from inline_sql_syntax.

karlhorky avatar karlhorky commented on July 30, 2024

Workaround (/* sql */ comment)

Add a /* sql */ comment after the multi-line generic

sql<{
  value: number
-}[]>`
+}[]>/* sql */ `
  SELECT 1 value;
`

Credit: @net in thebearingedge/vscode-sql-lit#13 (comment)

from inline_sql_syntax.

vicary avatar vicary commented on July 30, 2024

This actually breaks coloring for the rest of the documents with generics.

image

image

from inline_sql_syntax.

KristjanTammekivi avatar KristjanTammekivi commented on July 30, 2024

This actually breaks coloring for the rest of the documents with generics.

image

image

I can't seem to replicate
image

Can you give a full example? Here's mine:

const sql = <T>(q): any => {
    return {
        execute: (db) => {}
    }
}

interface F {
    now: string;
}

const db = {};

await sql<F>`SELECT NOW(6) AS 'now'`.execute(db);
const boo = true;

await sql<{ now: string }>`SELECT NOW(6) AS 'now'`.execute(db);
const foo = true;

await sql`SELECT NOW(6) AS 'now'`.execute(db);
const moo = true;


export { };

from inline_sql_syntax.

vicary avatar vicary commented on July 30, 2024

@KristjanTammekivi testing with your snippet below:

With the extension enabled

image

With the extension disabled

image

from inline_sql_syntax.

KristjanTammekivi avatar KristjanTammekivi commented on July 30, 2024

Ah my bad, I thought this was the same extension as I made a contribution to because I was mentioned here. I'm using this extension:
image

from inline_sql_syntax.

vicary avatar vicary commented on July 30, 2024

@KristjanTammekivi nice ad (and i'm sold) =D

from inline_sql_syntax.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.