Closed lmtyler closed 1 year ago
I changed SQL file to
CREATE TABLE IF NOT EXISTS channel_approval_request_type
(
request_type_id SMALLINT(5) UNSIGNED NOT NULL,
PRIMARY KEY (request_type_id)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8;
/* name: ListChannelApprovalRequestTypes :many */
select *
from channel_approval_request_type
order by request_type_id;
This is what I got as output which is still incorrect, but it seems to work from playground
// Code generated by sqlc. DO NOT EDIT.
// source: channel_approval_request_type.sql
package db
import (
"context"
)
const listChannelApprovalRequestTypes = `-- name: ListChannelApprovalRequestTypes :many
select channel_approval_request_type
from channel_approval_request_type
order by request_type_id
`
func (q *Queries) ListChannelApprovalRequestTypes(ctx context.Context) ([]int32, error) {
rows, err := q.query(ctx, q.listChannelApprovalRequestTypesStmt, listChannelApprovalRequestTypes)
if err != nil {
return nil, err
}
defer rows.Close()
var items []int32
for rows.Next() {
var channel_approval_request_type int32
if err := rows.Scan(&channel_approval_request_type); err != nil {
return nil, err
}
items = append(items, channel_approval_request_type)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
and in model.go
type ChannelApprovalRequestType struct {
ChannelApprovalRequestType int32 `json:"channel_approval_request_type"`
}
I checked if this is working in 1.21 and didn't get any errors
https://play.sqlc.dev/p/63d0e4263d6388089eedacd3f17f56e16f4ec5b65c08dac51bda41a3fcc244bb
Version v1.11.0 - brew v1.7.1-devel - built from code clone
OS MocOS
What happened? sqlc generate fails to find a column
Relevant log output
SQL FILE
Configuration