| Author |
Message |
< Erlyweb mailing list ~ fix for order_by handling in erlydb_mnesia |
| Guest |
Posted: Sun May 18, 2008 8:53 pm |
|
|
|
Guest
|
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 <wk@dual-tech.com.pl>
* 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 erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---
Post received from mailinglist |
|
|
| Back to top |
|
| Guest |
Posted: Thu May 22, 2008 6:15 am |
|
|
|
Guest
|
Thx, the fix is in trunk. I'll make a release soon.
On Sun, May 18, 2008 at 1:52 PM, Wojciech Kaczmarek
<kaczmarek.w@gmail.com> 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 <wk@dual-tech.com.pl>
> * 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 erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---
Post received from mailinglist |
|
|
| Back to top |
|
| dmitriid |
Posted: Thu May 22, 2008 6:53 am |
|
|
|
User
Joined: 17 Aug 2006
Posts: 213
|
BTW, it's been on my mind for some time. Could you please add quoting
to table names in the mysql driver like so:
SELECT `some_table`.field FROM `some_table`
http://dev.mysql.com/doc/refman/5.0/en/identifiers.html
I ran into this issue when I tried to select somethig from a table
named 'user'
>
> Thx, the fix is in trunk. I'll make a release soon.
>
> On Sun, May 18, 2008 at 1:52 PM, Wojciech Kaczmarek
> <kaczmarek.w@gmail.com> 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 <wk@dual-tech.com.pl
>> >
>> * 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 erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---
Post received from mailinglist |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|
|