问题标签 [sqlkorma]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
994 浏览

mysql - MySQL 和 clj-time 的时区问题

我在 MySQL 中有一个表。

create table demo ( theDate datetime );

我插入了两个日期,一个在夏令时,一个不是。

从我的 MySQL 客户端看来,正确的值已经进入:

当我使用 Korma 进行选择时(我不认为 Korma 在 JDBC 之上做任何相关的事情),我在非夏令时日期中得到一个时区差异。

当我选择日期时:

而我本来希望得到(1 6)(我故意把日期放在一个月的边界上来说明)。当我使用date而不是datetimeMySQL 类型时,也会发生同样的事情。

我错过了什么?如何插入[(t/date-time 2014 01 01) (t/date-time 2014 06 01)]和返回(1 6)

0 投票
1 回答
734 浏览

sql - 使用 Korma 清理 Clojure 中的数据库输入

我在 RESTful API 后面使用 Korma,我突然想到我正在将用户提交的值传递给我的(insert)调用。Clojure 中有没有很好的方法来防止 SQL 注入攻击?Korma 以一种非常直接的方式生成 SQL,所以如果有人告诉我他们的名字是little Bobby Tables,我担心会受到伤害。

0 投票
1 回答
193 浏览

sql - “插入选择”查询在 korma

除了“CustomerName”和“Country”之外,客户表还有其他列

这是我的简单 sql 查询。

请帮我用 KORMA SQL 编写它。

0 投票
2 回答
310 浏览

clojure - 如何在 korma 中访问其他模式中的表?

在 SQL 中,访问其他模式中的表很简单:

我怎么能在科尔马做到这一点?我实际上要做的是访问information_schema.tables表。db所以定义另一个defdb不会有帮助。

我试图定义实体,但是失败了。

0 投票
1 回答
584 浏览

clojure - 如何将 korma 选择结果转换为 json 用于休息服务(组合)?

我正在使用 compojure、cheshire 和 korma(以及 postgre db)来创建休息服务。我创建了一个包含两个字符串字段(名称和描述)的表,其结构如下:

我可以将记录插入到该表中,但是当我尝试执行时

并从服务器返回结果

我收到这样的错误:java.lang.IllegalArgumentException 没有方法的实现::render of protocol:#'compojure.response/Renderable found for class:clojure.lang.PersistentVector

如我所见,我需要将帖子集合转换为 json。怎么做?

0 投票
1 回答
49 浏览

sqlkorma - SQL Korma“此类型不支持计数”错误消息

从 1 个表中执行非常简单的请求行,即从用户中选择 *。我正在尝试将响应传递给 selmer 模板以进行迭代,但我收到上面的错误消息,实际上我无法执行以下操作

所以看起来响应不是 Seq

那么我如何将下面的输出转换为 seq

所以在下面的塞尔默电话中使用

我正在使用 0.4.0 的 korma

谢谢

0 投票
1 回答
1191 浏览

java - 在clojure中将json对象转换为字符串

我正在尝试使用 clojure、sql korma 和 angularJS 将 json 对象从表显示到 UI 屏幕。我有一个列的数据类型为 json 的表。数据库是 postgres。当我尝试运行代码时,出现错误。我查询数据库的代码如下。

错误是:com.fasterxml.jackson.core.JsonGenerationException:无法 JSON 编码类的对象:类 org.postgresql.util.PGobject:[“所有节点中的容器编号必须一致”]

我不知道我们是否可以在这里使用 java 的任何 toString 方法enter code here将 JSON 转换为普通字符串。非常感谢任何帮助

0 投票
1 回答
87 浏览

clojure - 选择korma的字段功能不拒绝列?

我在 windows 上使用 sqlite3 数据库玩弄 clojure 及其 korma 库。我以 7web 书为例。它介绍了select*函数及其朋友。

但是使用该fields函数会添加字段而不是限制。

我错过了什么吗?

0 投票
3 回答
640 浏览

filter - Clojure thread-first with filter function

I'm having a problem stringing some forms together to do some ETL on a result set from a korma function.

I get back from korma sql:

({:id 1 :some_field "asd" :children [{:a 1 :b 2 :c 3} {:a 1 :b 3 :c 4} {:a 2 :b 2 :c 3}] :another_field "qwe"})

I'm looking to filter this result set by getting the "children" where the :a keyword is 1.

My attempt:

What I'm expecting here is a vector of hashmaps that :a is set to 1, i.e :

However, I'm getting the following error:

From the error I gather it's trying to create a sequence from a function...though just not able to connect the dots as to why.

Further, if I separate the filter function entirely by doing the following:

it works. I'm not sure why the first-thread is not applying the filter function, passing in the :children vector as the coll argument.

Any and all help much appreciated.

Thanks

0 投票
1 回答
430 浏览

postgresql - 使用 Korma 插入原始 SQL

我想用 Korma 执行以下原始 SQL:

参数等于:

两者都评估以纠正字符串并在 repl 中工作。

但是在运行时我在 psql 控制台中有以下错误:

无法弄清楚是什么问题。有人用 Korma 做过插入吗?

PostgreSQL 9.5 + 科尔马 0.4.2


12345678910