<div dir="ltr">Now I really get what was going wrong :) I was defining a variable 'posts' that was then being queried rather than the table named 'posts'. I guess I thought that the SQL table and variable namespace was different than the Ur namespace, or I just didn't notice the variable and table names were the same.<br><br>I dream of having the ML knowledge and time to work on better error messages for Ur/Web. Maybe someday. I once worked on a small compiler and kept a log of bad error messages, the code and then the solution and possible error message to what the problem was so the messages could get better. Maybe we could start a place on the wiki or issue tracker for such a database.<br><br>Burton<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 3, 2014 at 1:39 PM, Burton Samograd <span dir="ltr"><<a href="mailto:burton.samograd@gmail.com" target="_blank">burton.samograd@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Looks like I have to take better care of my variable naming to prevent clashes. <br><br></div>Thanks.<span class="HOEnZb"><font color="#888888"><br><br>Burton<br></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 3, 2014 at 1:33 PM, mutaamba maasha <span dir="ltr"><<a href="mailto:maasha@gmail.com" target="_blank">maasha@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">-----BEGIN PGP SIGNED MESSAGE-----<br>
Hash: SHA1<br>
<br>
(* It seems the problem was the naming of the<br>
query result, the query result was colliding<br>
with the table. Let me know if this was the<br>
case and if the code below helps.<br>
<br>
Happy hacking<br>
*)<br>
<br>
(* adding the needed styles *)<br>
style topbar<br>
<span>style postsList<br>
style post<br>
style postTitle<br>
style postAuthor<br>
style postBody<br>
style postBottom<br>
style postComments<br>
style postDate<br>
<br>
</span><span>table posts : { Id : int, Title : string, Body : string, Created : time }<br>
PRIMARY KEY Id<br>
table userIdToPostIds : { UserId : int, PostId : int }<br>
PRIMARY KEY UserId<br>
table users : { Id : int, Username : string }<br>
PRIMARY KEY Id<br>
<br>
</span>(* Adding this here so it compiles *)<br>
val blogName : string = "The finest culinary selections from the land<br>
of tofu."<br>
(* Using modules to so everything fits in one<br>
file. If you are curious about modules you<br>
can find out more about them here :<br>
<a href="http://www.impredicative.com/ur/tutorial/intro.html" target="_blank">http://www.impredicative.com/ur/tutorial/intro.html</a><br>
You want to remove this because you have the<br>
files page.ur*<br>
*)<br>
signature PAGE = sig<br>
val page' : string -> xbody -> page<br>
end<br>
structure Page : PAGE = struct<br>
fun page' (t : string) (b : xbody) : page=<br>
<xml><br>
<head><title>{[t]}</title></head><br>
<body><br>
{[b]}<br>
</body><br>
</xml><br>
end<br>
(* The end of the module code/code you should remove *)<br>
<span><br>
<br>
fun blog () : transaction page =<br>
</span> (* Changed the name of the query result - this is most likely<br>
what is was causing your problem. *)<br>
post_query_1 <- queryX (SELECT Posts.Title, Posts.Body,<br>
<span>Users.Username, Posts.Created<br>
FROM posts, users, userIdToPostIds<br>
WHERE users.Id = userIdToPostIds.UserId<br>
AND posts.Id = userIdToPostIds.PostId)<br>
(fn row => post' row.Posts.Title<br>
row.Posts.Body row.Users.Username row.Posts.Created);<br>
</span> (* changed the name of the query result *)<br>
post_query_2 <- queryX (SELECT Posts.Title, Posts.Body,<br>
Users.Username,Posts.Created<br>
<span> FROM posts, users, userIdToPostIds<br>
WHERE users.Id = userIdToPostIds.UserId<br>
AND posts.Id = userIdToPostIds.PostId)<br>
(fn row => post' row.Posts.Title<br>
row.Posts.Body row.Users.Username row.Posts.Created);<br>
return (Page.page' blogName<br>
<xml><br>
{topbar' ()}<br>
</span> {posts' post_query_1}<br>
{posts' post_query_2}<br>
<span> </xml>)<br>
<br>
and topbar' () : xbody =<br>
<xml><div class="topbar">{[blogName]}</div></xml><br>
</span>(* added type information here *)<br>
and posts' (posts : xbody) : xbody =<br>
<span> <xml><div class="postsList"><br>
{posts}<br>
</div></xml><br>
</span>(* Used the code from the previous email<br>
... I am going to guess it is what you<br>
have. *)<br>
<span>and post' (title : string)<br>
(body : string)<br>
</span> (username : string)<br>
(created : time) : xbody =<br>
<span> let<br>
val numComments = 0<br>
in<br>
<xml><br>
<div class="post"><br>
<div class="postTitle">{[title]}</div><br>
</span> <div class="postAuthor">{[username]}</div><br>
<span> <div class="postBody">{[body]}</div><br>
<div class="postBottom"><br>
<div class="postComments"><br>
<a link={comments ()}>{[numComments]} comments</a><br>
</div><br>
<div class="postDate">{[created]}</div><br>
</div><br>
</div><br>
</xml><br>
end<br>
</span><span>and comments () : transaction page = error <xml>error : comment<br>
function not implemented</xml><br>
<br>
<br>
</span>fun main () = return <xml></xml><br>
-----BEGIN PGP SIGNATURE-----<br>
Version: GnuPG v1<br>
<br>
iQIcBAEBAgAGBQJULvn0AAoJEHxRxnzR1VWyyx4QALnOK3VgRpYNWK6wgBUxkPyz<br>
R+rKe0Vq0KCgzF3MjjyQPLaxwTxdfbg9gaXVZyXkpDnX8RIOhySYFmNOsN6BHGu3<br>
f8I4uvtS+N4Wsa4FjHzmY35XoyGiDlki6kbE+Yw8Myp7Jv2iY+FXXuQvumS83Wvr<br>
JXlujVROxY+Iglsqsu3iAh5btw+VaBaNC2SQUQLHrrIeZTvUOsIS5A0+MW7SQn5p<br>
6Aj77EDtbA2k0xpCyAADZ54UrSvzHFrMnLEheHAoLjAufNdrzl5+dyFyZukJRndg<br>
y/cc4dUgkqZhX/wsDEbMBkTqbW1R+vZvNxX0+lUSqDc53LxNYwDQQGgIuVrAqKBf<br>
yom/3IbvoS4Nkt1MF/2qZU7bptXK59rpBbWTk9zt00FO/nsf2/zR+nDU6Os6rkST<br>
4DUTmBGOcGd9/e1RO6UdK819PoVVPOXdy7JsAyzHacp3aTMH3gEkAHia7wAsb/Iz<br>
wnljBwssuNOPY1vT3s4ul8BXDRCclOsg1cb66EedFiGEnZW1PyD1mYvWeRUjR4IK<br>
CzRa3xpsliE5XisYuZqEoplQ3gaovPInJ7CZEG3k8w350ts+D85VU2WqKATIG2gr<br>
gTi9SzzqlTlIS/H2dmlNwvMsEJG38byXuCZQar0ElX7wVg8nANlv4xqAEjIbJ+YH<br>
039UXNim4rX2XSgGmg4P<br>
=6vna<br>
-----END PGP SIGNATURE-----<br>
<div><div><br>
_______________________________________________<br>
Ur mailing list<br>
<a href="mailto:Ur@impredicative.com" target="_blank">Ur@impredicative.com</a><br>
<a href="http://www.impredicative.com/cgi-bin/mailman/listinfo/ur" target="_blank">http://www.impredicative.com/cgi-bin/mailman/listinfo/ur</a><br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>