带有 Postgres 查询的 KubeCTL 不起作用并抛出 "LINE 1: select * FROM "employees" where employeeData::text like someSampleHere;"

KubeCTL with Postgres query doesn't work and throws "LINE 1: select * FROM "employees" where employeeData::text like someSampleHere;"

字段 employeeData 的类型为 json

考虑查询:

select * FROM "employees" where employeeData::text like '%someSampleHere%'

当我在 Postgres 中 运行 查询时,它工作得很好,我得到了我要的行。

然而,当我将它与 KubeCTL 一起使用时 运行 此查询在 PG 应用程序之外

psql -d employess_db -U postgres -c 'select * FROM "employees" where employeeData::text like 'someSampleHere';'

PG 投球

ERROR:  syntax error at or near "%"
LINE 1: select * FROM "employees" where employeeData::text like %someSampleHere%;

我们该如何解决?

对我来说这听起来像是一个引用问题。您忽略了在问题中显示实际的 kubectl 命令行,但这对我来说没有任何错误:

kubectl exec postgres-pod -- psql -U postgres -d employees_db \
  -c "select * from \"employees\" where employeeData::text like '%someSampleHere%'"