Skip to content

Question: how to properly use UpdateFooParams and Foo class? #691

Answered by kyleconroy
issmirnov asked this question in General
Discussion options

You must be logged in to vote

By design, sqlc will never re-use parameter structs for methods, even if those structs have the same fields as other parameter or model structs. Since database schema and queries change often, this design limits the impact of those changes.

Taking your example one step further, imagine that we need to add a created_at column to the users table. This column defaults to now().

CREATE TABLE users (
  id serial primary key,
  name not null,
  created_at timestamp default now()
);
type User struct {
	ID              int32        `json:"id"`
	Name            string       `json:"name"`
	CreatedAt           time.Time      `json:"created_at"`
}

Since the column can be null, we don't have to updat…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by issmirnov
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #691 on August 28, 2020 16:06.