英文:
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.
答案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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论