我有一个表格中的枚举字段。当我使用sqlx Get()方法进行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
);
proto文件的一部分:
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枚举类型?我是否需要自己实现扫描器,还是有其他方法?