Thx, the fix is in trunk. I'll make a release soon.

On Sun, May 18, 2008 at 1:52 PM, Wojciech Kaczmarek
<[EMAIL PROTECTED]> wrote:
>
> Hello!
>
> When evaluating intoduction tutorial I found a bug in
> erlydb_mnesia.erl preventing from using order_by.
>
> Here's the example result of invoking entry:find_with({order_by, {id, desc}}) 
> :
>
> erlydb_mnesia:204 ["In q with: ",
>                   {select,'*',
>                           {from,entry},
>                           {where,undefined},
>                           {order_by,{id,desc}}}]
> erlydb_mnesia:539 ["Unhandled extras: ",{order_by,{id,desc}}]
>
> Below is the quick fix - patch against revision 245.
>
> Regards,
> Wojtek
>
>
> Sun May 18 22:50:28 CEST 2008  Wojciech Kaczmarek <[EMAIL PROTECTED]>
>  * fixed mnesia order_by impl
> diff -rN -u old-current/src/erlydb/erlydb_mnesia.erl
> new-current/src/erlydb/erlydb_mnesia.erl
> --- old-current/src/erlydb/erlydb_mnesia.erl    2008-05-18
> 22:50:47.000000000 +0200
> +++ new-current/src/erlydb/erlydb_mnesia.erl    2008-05-18
> 22:50:47.000000000 +0200
> @@ -508,11 +508,12 @@
>  extras([], QHDesc) ->
>     QHDesc;
>
> -extras({order_by, Field}, #qhdesc{metadata = QLCData} = QHDesc) when
> is_atom(Field) ->
> +extras({order_by, {Field, Order}}, #qhdesc{metadata = QLCData} =
> QHDesc) when is_atom(Field) ->
>     QHDesc#qhdesc{postqh =
>                fun(QH, QHOptions) ->
>             [Table | _Rest] = dict:fetch(tables, QLCData),
> -            qlc:keysort(dict:fetch({index,Table,Field}, QLCData), QH,
> QHOptions)
> +            SortOptions = [{order, translate_order(Order)} | QHOptions],
> +            qlc:keysort(dict:fetch({index,Table,Field}, QLCData), QH,
> SortOptions)
>         end};
>  extras({limit, Limit}, QHDesc) ->
>     QHDesc#qhdesc{evalfun =
> @@ -539,6 +540,8 @@
>     ?L(["Unhandled extras: ", Extras]),
>     exit("Unhandled extras").
>
> +translate_order(asc) -> ascending;
> +translate_order(desc) -> descending.
>
>  postqh(QueryHandle, _QHOptions) ->
>     QueryHandle.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"erlyweb" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to