问题
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