Skip to content

Generating types for composed template strings #10

Open
@tantaman

Description

@tantaman

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions