简体   繁体   English

使用Korma限制选择字段

[英]Restricting select fields with Korma

I'm trying to restrict the columns returned from a select query to just one column, but Korma seems to just add the additional column to the default ones instead of using just this one: 我试图将选择查询返回的列限制为仅一列,但是Korma似乎只是将其他列添加到默认列中,而不是仅使用此列:

=> (dry-run (select games (fields :white_id))) dry run :: SELECT "games"."stones", "games"."white_id", "games"."black_id", "games"."white_id" FROM "games" :: []

For reference: 以供参考:

=> (dry-run (select games )) dry run :: SELECT "games"."stones", "games"."white_id", "games"."black_id" FROM "games" :: []

What I'd like to see as the output is: 我希望看到的输出是:

SELECT "games"."white_id" FROM "games";

Using latest Korma 0.4.0 使用最新的Korma 0.4.0

How can I get that? 我该怎么办?

I've reported this upstream and it seems to be the expected behaviour (by the Korma developers) for the current version. 我已经在上游报告了这一点,这似乎是当前版本的预期行为(由Korma开发人员进行)。

I expect the discussion to continue there instead: https://github.com/korma/Korma/issues/251 我希望讨论会继续在那里: https//github.com/korma/Korma/issues/251

I checked following 我检查了以下

(use :reload-all 'korma.core)

=> nil =>无

(dry-run (select :users (fields :id)))

dry run :: SELECT "users"."id" FROM "users" :: [] 试运行::选择“用户”。“ id”从“用户” :: []

=> [{nil 1}] => [{nil 1}]

(dry-run (select :users))

dry run :: SELECT "users".* FROM "users" :: [] 空运行::选择“用户”。*从“用户” :: []

=> [{nil 1}] => [{nil 1}]

i am using korma 0.3.1 and it's working fine for me. 我正在使用科尔马0.3.1,对我来说很好。 check your korma version and reply back if you still have any issue or mention version number in reply 检查您的科尔马版本,如果仍然有任何问题或回覆提及版本号,请回覆

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM