Erlang Mailing Lists

Author Message

<  Erlyweb mailing list  ~  music example with postgresql

Guest
Posted: Thu Jan 03, 2008 3:29 pm Reply with quote
Guest
Hi,

I had problems to get the music example working with the psql driver. A small change to erlsql.erl was needed since postgresql does not seem to support LIMIT with two arguments (offset and limit). Instead the extra OFFSET argument
Guest
Posted: Thu Jan 03, 2008 6:39 pm Reply with quote
Guest
Thanks Mikael.

It looks like ErlSQL will have to accept another parameter indicating
the dialect to translate into in order to make it portable across
MySQL and Postgres. The right way to do it would be to turn the second
parameter ('Safe') into a list of options.

Yariv

On Jan 3, 2008 7:28 AM, Mikael Karlsson <karlsson.rm@gmail.com> wrote:
> Hi,
>
> I had problems to get the music example working with the psql driver. A
> small change to erlsql.erl was needed since postgresql does not seem to
> support LIMIT with two arguments (offset and limit). Instead the extra
> OFFSET argument had to be given explicitly. I do not know how this affects
> the MySQL driver but it would be nice if the example worked for both though.
>
> Best Regards
> Mikael
>
> svn diff:
>
> Index: erlsql/erlsql.erl
> ===================================================================
> --- erlsql/erlsql.erl (revision 228)
> +++ erlsql/erlsql.erl (working copy)
> @@ -309,7 +309,7 @@
> extra_clause({limit, Num}, _Safe) ->
> [<<" LIMIT ">>, encode(Num)];
> extra_clause({limit, Offset, Num}, _Safe) ->
> - [<<" LIMIT ">>, encode(Offset), $, , encode(Num)];
> + [<<" LIMIT ">>, encode(Num), <<" OFFSET ">>, encode(Offset)];
> extra_clause({group_by, ColNames}, _Safe) ->
> [<<" GROUP BY ">>, make_list(ColNames, fun convert/1)];
> extra_clause({group_by, ColNames, having, Expr}, Safe) ->
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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 recived from mailinglist

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

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