Restricting select fields with Korma

孤街浪徒 提交于 2019-12-11 10:04:43

问题


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:

=> (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

How can I get that?


回答1:


I've reported this upstream and it seems to be the expected behaviour (by the Korma developers) for the current version.

I expect the discussion to continue there instead: https://github.com/korma/Korma/issues/251




回答2:


I checked following

(use :reload-all 'korma.core)

=> nil

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

dry run :: SELECT "users"."id" FROM "users" :: []

=> [{nil 1}]

(dry-run (select :users))

dry run :: SELECT "users".* FROM "users" :: []

=> [{nil 1}]

i am using korma 0.3.1 and it's working fine for me. check your korma version and reply back if you still have any issue or mention version number in reply



来源:https://stackoverflow.com/questions/25825252/restricting-select-fields-with-korma

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!