Description
Version
1.11.0
What happened?
Upon SQLC generate with the following schema and queries I have a type generated for the params for the GetUserByEmailOrUsername query but not the GetUserByEmail.
I understand that this might be by design and that for a lot of people they would end up with redundant types but I would much prefer that it generated the types (even with just a single field) to allow for more con-formative and similar code.
I would like for a query with a single param to generate a struct like this:
type GetUserByEmailParams struct {
Email string
}
And for that to be used within the generated function:
func (q *Queries) GetUserByEmail(ctx context.Context, arg GetUserByEmailParams) (User, error) {}
I know that this might not be what everyone prefers in terms of redundant types being generated for others. Perhaps a flag or a configuration field could be added to turn this on or off. Happy to work on it if it is something you would be willing to accept.
Relevant log output
No response
Database schema
CREATE TABLE users (
id SERIAL PRIMARY KEY,
username VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL
);
SQL queries
-- name: GetUserByEmail :one
SELECT * FROM users WHERE email = $1;
-- name: GetUserByEmailOrUsername :one
SELECT * FROM users WHERE email = $1 OR username = $2;
Configuration
version: 1
packages:
- path: "queries"
name: "queries"
engine: "postgresql"
schema: "schema.sql"
queries: "query.sql"
Playground URL
No response
What operating system are you using?
macOS
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go