Closed Rugal closed 9 years ago
defentity
defines a base query and relations for the table. When querying using the entity, you can add things, such as additional fields and where conditions, and define which relations to fetch using with
. Unfortunately it doesn't work well together with aggregate
since the entity fields will be always included in the query. Simple use table name for the aggregate query:
(sql-only (select :restaurant (aggregate (count :*) :cnt)))
=> "SELECT COUNT(\"restaurant\".*) AS \"cnt\" FROM \"restaurant\""
Thanks for the reply, I also found in other places where I need only limited number of fields, korma will put all the default fields as well as the (fields )
content.
Thus I think the best strategy maybe is to manually specify fields in (select)
when on use rather than set them in defentity
.
Hope some version in the future could address this cumbersome thing in a more flexible way.
Hello: I am new to korma hence have a question maybe very easy. Here is my entity:
I try to execute
select count(*) from restaurant
in korma like:)
But in generate the SQL as below and also give me the error:
Which automatically includes all fields in my entity. I also tried the
But still not work, it still generate all fields in projection list. Could anyone help me?