mmkal / pgkit

PostgreSQL🤝TypeScript monorepo. SQL client/admin UI/smart migrator/type generator/schema inspector
https://pgkit.dev
176 stars 24 forks source link

Do not override existing types #363

Open gajus opened 2 years ago

gajus commented 2 years ago

Related to this:

https://github.com/mmkal/slonik-tools/issues/362

I want to override types for a specific query.

Expected

I expect that if I provide a custom type to sql tagged template, then then typegen won't override it.

Actual

typegen always overrides sql types.

mmkal commented 2 years ago

I usually get around this with aliasing const _sql = sql, does that work? It might be tricky coming up with a reliable way to tell if a type is generated or hand-written.

danielrearden commented 2 years ago

What about checking for a comment in the query that would cause typegen to ignore it altogether?

mmkal commented 2 years ago

What's the advantage of that over aliasing sql? To be clear, the disadvantages in my mind are: steeper learning curve, more magic, less intuitive usage, more complex implementation.

If the only rule a user needs to remember is ”slonik-typegen affects sql" then the escape hatch follows naturally.

janpaepke commented 2 years ago

hey guys, you'll be happy to hear, we're working on both of these issues ignoring queries from extraction (without renaming the literal) as well as preserving custom type enhancements.

Your feedback on both proposals is very welcome.