【发布时间】:2020-08-17 21:07:13
【问题描述】:
我已经在表格中归档了枚举。当我在 sqlxGet() 方法的帮助下进行 SELECT 查询时,我得到:
sql:列索引 1 上的扫描错误,名称“type”:将 driver.Value 类型字符串(“INDIVIDUAL”)转换为 int32:语法无效
Postgres 表:
create type account_type as enum ('INDIVIDUAL', 'BUSINESS');
create table account (
id varchar not null primary key,
type account_type not null,
email varchar(254) not null unique
);
原型文件的一部分:
enum AccountType {
INDIVIDUAL = 0;
BUSINESS = 1;
}
message Account {
string id = 1;
AccountType type = 2;
string email = 3;
}
SQL 查询:
SELECT id, type, email
FROM account
WHERE email = $1
LIMIT 1
如何将 PostgresQL 枚举扫描到 Protobuf 枚举?我必须实现自己的扫描仪还是有其他方法?
【问题讨论】:
标签: sql postgresql enums protocol-buffers sqlx