You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sqlc generate. GetFundSummary get wrong extend type.
constgetFundSummary=`-- name: GetFundSummary :oneSELECT id, account, name, extent FROM auth_user WHERE id = $1 LIMIT 1`typeGetFundSummaryRowstruct {
IDint32`json:"id"`Accountstring`json:"account"`Namestring`json:"name"`Extent json.RawMessage`json:"extent"`// <--------- WRONG TYPE
}
func (q*Queries) GetFundSummary(ctx context.Context, idint32) (*GetFundSummaryRow, error) {
row:=q.db.QueryRow(ctx, getFundSummary, id)
variGetFundSummaryRowerr:=row.Scan(
&i.ID,
&i.Account,
&i.Name,
&i.Extent,
)
return&i, err
}
constselectFundSummary=`-- name: SelectFundSummary :manySELECT name, extent FROM auth_user WHERE user_type = 'manager' ORDER BY name`typeSelectFundSummaryRowstruct {
Namestring`json:"name"`Extent schema.FundSummary`json:"extent"`// <---- BUT HERE GET CORRECT TYPE
}
func (q*Queries) SelectFundSummary(ctx context.Context) ([]*SelectFundSummaryRow, error) {
rows, err:=q.db.Query(ctx, selectFundSummary)
iferr!=nil {
returnnil, err
}
deferrows.Close()
varitems []*SelectFundSummaryRowforrows.Next() {
variSelectFundSummaryRowiferr:=rows.Scan(&i.Name, &i.Extent); err!=nil {
returnnil, err
}
items=append(items, &i)
}
iferr:=rows.Err(); err!=nil {
returnnil, err
}
returnitems, nil
}
Relevant log output
const getFundSummary = `-- name: GetFundSummary :oneSELECT id, account, name, extent FROM auth_user WHERE id = $1 LIMIT 1`type GetFundSummaryRow struct {
ID int32 `json:"id"`
Account string `json:"account"`
Name string `json:"name"`
Extent json.RawMessage `json:"extent"` // <--------- WRONG TYPE
}
func (q *Queries) GetFundSummary(ctx context.Context, id int32) (*GetFundSummaryRow, error) {
row := q.db.QueryRow(ctx, getFundSummary, id)
var i GetFundSummaryRow
err := row.Scan(
&i.ID,
&i.Account,
&i.Name,
&i.Extent,
)
return&i, err
}
const selectFundSummary = `-- name: SelectFundSummary :manySELECT name, extent FROM auth_user WHERE user_type = 'manager' ORDER BY name`type SelectFundSummaryRow struct {
Name string `json:"name"`
Extent schema.FundSummary `json:"extent"` // <---- BUT HERE GET CORRECT TYPE
}
func (q *Queries) SelectFundSummary(ctx context.Context) ([]*SelectFundSummaryRow, error) {
rows, err := q.db.Query(ctx, selectFundSummary)
if err != nil {
return nil, err
}
defer rows.Close()
var items []*SelectFundSummaryRow
forrows.Next() {
var i SelectFundSummaryRow
if err := rows.Scan(&i.Name, &i.Extent); err != nil {
return nil, err
}
items = append(items, &i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
Database schema
CREATETABLEIF NOT EXISTS auth_user
(
id SERIALPRIMARY KEY, -- ID
name VARCHARNOT NULL,
user_type VARCHARNOT NULL,
extent JSONB NOT NULL DEFAULT '{}', --
dept_id INTEGER-- 部门ID
);
SQL queries
-- name: SelectFundSummary :manySELECT name,
extent
FROM auth_user
WHERE user_type ='manager'ORDER BY name;
-- name: GetFundSummary :oneSELECT id,
account,
name,
extent
FROM auth_user
WHERE id = $1LIMIT1;
Version
1.27.0
What happened?
A bug happened!
database: postgres 16.x
custom type
Relevant log output
Database schema
SQL queries
Configuration
Playground URL
No response
What operating system are you using?
No response
What database engines are you using?
No response
What type of code are you generating?
No response
The text was updated successfully, but these errors were encountered: