golang/pq pq: 运算符不存在:bigint = text

huangapple go评论71阅读模式
英文:

golang/pq pq: operator does not exist: bigint = text

问题

查询 := "WITH b(ColA, ColB) AS (VALUES ($1,$2)) UPDATE schema_name.table_name AS a SET ColC = b.ColB FROM b WHERE a.ColA = b.ColA AND a.ColB = b.ColB"
res, err := db.Exec(query, 1, 1)

上述代码出现以下错误:

pq: operator does not exist: bigint = text

"ColC" 的类型是 BIGINT。

经过我的调查,驱动程序将值插入为文本而不是整数。

问题链接:https://github.com/lib/pq/issues/582

英文:
query := "WITH b(ColA, ColB) AS (VALUES ($1,$2)) UPDATE schema_name.table_name AS a SET ColC = b.ColB FROM b WHERE a.ColA = b.ColA AND a.ColB = b.ColB"
res, err := db.Exec(query, 1, 1)

The above code fails with the following error:

pq: operator does not exist: bigint = text

"ColC" is of type BIGINT.

From my investigation, the driver is inserting the values as text instead of ints.

issue: https://github.com/lib/pq/issues/582

答案1

得分: 2

原来是PostgreSQL的行为问题,而不是驱动程序的问题。
我不得不使用显式转换来使我的查询工作正常。

英文:

It turns out to be the postgres behavior and not the driver.
I had to use explicit casts to get my queries to work.

huangapple
  • 本文由 发表于 2017年3月16日 18:50:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/42831947.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定