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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generating types for composed template strings #10

Open
tantaman opened this issue Jul 14, 2023 · 0 comments
Open

Generating types for composed template strings #10

tantaman opened this issue Jul 14, 2023 · 0 comments

Comments

@tantaman
Copy link
Contributor

Generating types for composed template strings is going to be fun 馃槄

If you're up for it, we'll need to work on converting a string like the above to something we can pass to the SQL type generator.

So:

SELECT ${column} FROM ${table} ${condition} OR a=${"42"}

should be temporarily transformed to:

SELECT "a" FROM "a" WHERE a=? OR a=? OR a=?

at compile time and passed to the type-gen package. The TypeScript Compiler APIs let you inspect all the fragments that make up a template string and pull their type information. That should provide enough information to do the transform given sql.column("a"); would return a literal column type of "a". Same with table.

Values we can ignore (at least to start. Balues in non-value positions would pose a problem) and substitute ? in their place.

We'd do this in a future PR.

Originally posted by @tantaman in #4 (comment)

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

No branches or pull requests

1 participant