sqlc.yaml 配置不会覆盖 postgresql 时间间隔到 time.Duration
php小编柚子在这里为大家介绍一个关于sqlc.yaml配置的问题。在使用postgresql时,我们经常需要使用时间间隔(time.Duration)来表示一段时间。然而,有时候我们会发现在sqlc.yaml配置文件中进行的时间间隔配置并不会生效,而是被默认的配置所覆盖。这个问题该如何解决呢?请继续阅读本文,我们将给出详细的解答。
问题内容
我发现 sqlc codegen 应用程序存在问题。万一,当我需要 interval
(postgresql) 字段时,sqlc 会生成一个带有 int64
字段的对象。此解决方案看起来已损坏,并在扫描行时产生错误: errorf("cannot conversion %v to interval", value)
sqlc.yaml:
version: "2" overrides: go: overrides: - db_type: "interval" engine: "postgresql" go_type: import: "time" package: "time" type: "https://pkg.go.dev/time#duration" sql: - queries: "./sql_queries/raffle.query.sql" schema: "./migrations/001-init.sql" engine: "postgresql" gen: go: package: "raffle_repo" out: "../repo/sql/raffle_repo" sql_package: "pgx/v4"登录后复制