[Ur] Changing a single identifier in crud.ur causes a compiler error - leading to some questions about field names and table names

Stefan Scott stefanscottalexx at gmail.com
Fri Sep 4 12:17:30 EDT 2015


I'm happy to hear that there is some syntactic sugar involved here, which
is what I had been hoping. I may have overlooked where this syntactic sugar
was mentioned in the manual or demos, so I'm still a bit unsure how it
works.

Similar to the function you wrote, my attempt to extend the Crud demos to
provide a <select> element to allow users to edit foreign-key fields also
involves a table parameter. I had also been noticing that using a functor
provides a convenient way to bind local table variables, so I will try to
use this approach.


On Thu, Sep 3, 2015 at 1:29 AM, Ziv Scully <ziv at mit.edu> wrote:

> I haven't read this fully, but you are indeed correct in that there is a
> relationship between the identifier [tab], which is a value of type
> [sql_table _ _] (where the two type arguments are filled in with
> something), and [Tab], which is an ordinary (type-level) value of kind
> [Name].
>
> I believe this special relationship is only for SQL syntactic sugar in
> SELECT statements. When constructing the queries using the raw functions in
> Basis (see lib/ur/basis.urs), you can associate names with tables however
> you like. For UPDATE and DELETE statements, there's always only one table,
> and its associated name is hard-coded as [#T], though if you use the
> syntactic sugar this name never appears.
>
> I spent a lot of time digging into basis.urs because I wanted to write the
> a function that abstracts the pattern
>
> SELECT fields FROM table WHERE table.KeyColumn = {[keyValue]}
>
> and couldn't do it with the syntactic sugar.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.impredicative.com/pipermail/ur/attachments/20150904/efd8bb04/attachment.html>


More information about the Ur mailing list