sqlc-dev / sqlc

Generate type-safe code from SQL
https://sqlc.dev
MIT License
13.42k stars 803 forks source link

Automatically infer the types and use better Column names like offset and limit #3281

Open eprokhor opened 7 months ago

eprokhor commented 7 months ago

What do you want to change?

https://docs.sqlc.dev/en/stable/howto/named_parameters.html

Not working for postgresql. original:

...
when 'all' = $1::varchar then true
...

OFFSET $2::int LIMIT $3::int;

tried both ways in docs :

sqlc.arg(exchange) and @exchange

but get errors: queries/queries.sql:1:1: could not determine data type of parameter $1

WHY bother? Because its annoying/unclear to have to use the following in the code.

    Column1 string
    Column2 int32
    Column3 int32

What database engines need to be changed?

PostgreSQL

What programming language backends need to be changed?

Go

eprokhor commented 7 months ago

@Jille

Jille commented 7 months ago

In this old thread Kyle mentioned this would be broken indeed: https://github.com/sqlc-dev/sqlc/pull/209