[英]HugSQL defined function not found
This will probably be very thin but I am running out of options...这可能会很薄,但我已经没有选择了……
I am using clojure with hugsql and I am a true beginner with database tech.我将 clojure 与 hugsql 一起使用,我是数据库技术的真正初学者。 I am trying to call an user-defined function that a colleague has defined in the database.
我正在尝试调用同事在数据库中定义的用户定义的 function。
So, my problem is: making the query in databases software such as dbeaver, I get the results with no issues, however running from hugsql I get an error claiming it does not recognize the function.所以,我的问题是:在 dbeaver 等数据库软件中进行查询,我得到的结果没有问题,但是从 hugsql 运行我得到一个错误,声称它无法识别 function。
My.sql file is something like我的.sql 文件是这样的
-- :name a-fake-name :? :1
-- :doc some fake documentation
select * from a_fake_user_defined_function(:arg1, :arg2, :arg3, :arg4, 1);
I read the queries like so我这样阅读查询
(ns sql.commands
(:require [hugsql.core :as hugsql]))
(hugsql/def-db-fns "sql/file.sql")
I runned the command from clojure:我从 clojure 运行命令:
(def db
{:classname "org.postgresql.Driver"
:subprotocol "postgresql"
:subname subname
:user user
:password password})
(sql/a-fake-name db {:arg1 "first-argument" :arg2 "second-one" :arg3 "third" :arg4 "and-forth"})
And the error I get is我得到的错误是
ERROR: function a_fake_user_defined_function(character varying,
character varying, character varying, character varying, integer)
does not exist Hint: No function matches the given name and
argument types. You might need to add explicit type casts.
Position: 15
From the error I assume, I am missing some notation or configuration... Does anyone have an idea on what I can do?从我假设的错误来看,我缺少一些符号或配置......有没有人知道我能做什么?
I tried to look on hugsql documentation but got no luck.我试图查看hugsql 文档,但没有成功。
Thx!谢谢!
PS.: I am well aware it is a good practice provide an reproducible error on stackoverflow, but this is from my work I am quite clueless on how to reproduce the database. PS.:我很清楚在 stackoverflow 上提供可重现的错误是一种很好的做法,但这是我的工作,我对如何重现数据库一无所知。 Hopefully this is enough...
希望这就足够了......
As hinted by @cfrick, the problem was with the arguments definition in the hugsql file.正如@cfrick 所暗示的,问题出在 hugsql 文件中的 arguments 定义上。 The answer was also provided by a contributor in a github issue .
答案也由贡献者在github 问题中提供。
The problem was that it was not finding a function with that name and those type of arguments. The solution then was to type cast with double-colon each of the arguments ( https://www.hugsql.org/#colon ).问题是它没有找到具有该名称和 arguments 类型的 function。然后解决方案是使用双冒号 arguments ( https://www.hugsql.org/#colon ) 中的每一个进行类型转换。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.