-
Notifications
You must be signed in to change notification settings - Fork 25
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
Nesting Query Type #344
Comments
You're right, types can't be generated for queries like this at the moment. I'm hoping that #315 will improve this somewhat. For now, see the readme "Limitations" section. You should find that since the tool doesn't know how to get a type for the query with a nested subquery, you can add a manual type and it won't be removed. But you will see an error message. To make the tool skip the query entirely, use a variable other than const q1 = sql`select * from my_table`;
const _sql = sql;
const q2 = _sql`
select q1.id, q1.my_col
from (${q1}) q1
`; I'll leave this open until I add a case along these lines to the limitations section, but keep an eye on #315 for a fix that doesn't require manually adding a type. |
Thanks for the fast reply. I want just to ask that, "vscode-sql-template-literal" does not do syntax highlighting when I use "_sql" is there a work around? |
You would have to ask the maintainer to support underscores too. Looks like it'd be as easy as adding |
I'm also open to other ways of skipping codegen for certain queries like a comment directive if there are issues with the above suggestion for some reason, but I like
|
I used SQL tagged template literals and it works as expected.
It also support typed sql fragments.
You might consider change the readme to suggest this plugin instead |
Is there a way to generate the type for nesting queries?
It gives me this error:
which the reason is quite obvious.
If it is inevitable, is there a way to tell the type generator not to try for that nesting query. I will generate the type manually for nesting queries, but if it gives error, it will be hard to manage the code. (It will cause us to ignore the errors)
The text was updated successfully, but these errors were encountered: