In order to minimize possible errors, I am trying to do minimal example of a `<select>` widget to edit a foreign-key field, but I am still getting a compile error "Some constructor unification variables are undetermined".
Strangely, this error message mentions a field [Id = string] - but my code only uses [Id = int]. The code is on GitHub (and also reproduced at the end of this message). It's very short and simple: https://github.com/StefanScott/urweb-colorThing_Fk It uses only two tables ("parent" table 'color', and "child" table 'thing'): ``` table color : { Id : int, Nam : string } PRIMARY KEY Id table thing : { Id : int, Nam : string, Color : int } PRIMARY KEY Id, CONSTRAINT Thing_isof_Color FOREIGN KEY Color REFERENCES color(Id) ``` It also makes the following additional simplifications: - no sequence or auto-increment (ie, the user has to create the primary key) - no meta-programming - no Ur/Web modules, structures, functors or libraries - web interface provided only for *creating* records in table 'thing' (no updating or deleting) - no web interface provided for creating, updating or deleting 'color' records (must do this via via psql) The Ur/Web compiler gives the following error: ``` Some constructor unification variables are undetermined in declaration (look for them as "<UNIF:...>") ``` It can be difficult to debug this error, as it refers to a wide range of lines (covering all the function definitions). --------- Clue: There is one interesting clue in the compiler error message: it frequently mentions a field: ``` Id = string ``` However, both instances of 'Id' defined in the program (the primary keys of tables 'thing' and 'color') have type 'int', not 'string'. I'm very puzzled. Can anyone help explain this compile error? The compile output is reproduced in Issue 1 of the GitHub repo: https://github.com/StefanScott/urweb-colorThing_Fk/issues/1 --------- Below is the complete source code of colorThing_Fk.ur (also on GitHub). It's very short, in order to make it easier find the error! https://github.com/StefanScott/urweb-colorThing_Fk table color : { Id : int, Nam : string } PRIMARY KEY Id, CONSTRAINT Nam UNIQUE Nam, CONSTRAINT Id CHECK Id >= 0 table thing : { Id : int, Nam : string, Color : int } PRIMARY KEY Id, CONSTRAINT Id CHECK Id >= 0, CONSTRAINT Thing_isof_Color FOREIGN KEY Color REFERENCES color(Id) fun list () = thingRows <- queryX1 (SELECT * FROM thing) (fn r => <xml> <tr> <td> {[r.Id]} </td> <td> {[r.Nam]} </td> <td> {[r.Color]} </td> </tr> </xml>); colorOptions <- queryX1 (SELECT * FROM color) (fn r => <xml> <option value={r.Id}> {[r.Nam]} </option> </xml>); return <xml> <table border={1}> <tr> <th>Id</th> <th>Nam</th> <th>Color</th> </tr> {thingRows} </table> <br/><hr/><br/> <form> <table> <tr> <th>A:</th> <td><textbox{#Id}/></td> </tr> <tr> <th>B:</th> <td><textbox{#Nam}/></td> </tr> <tr> <th>C:</th> <td><select{#Color}>{colorOptions}</select></td> </tr> <tr> <th/> <td><submit action={create} value="Add Row"/></td> </tr> </table> </form> </xml> and create r = dml (INSERT INTO thing (Id, Nam, Color) VALUES ({[readError r.Id]}, {[r.Nam]}, {[readError r.Color]})); ls <- list (); return <xml><body> <p>Thing inserted!</p> {ls} </body></xml> and main () = ls <- list (); return <xml><body> <h1>Things</h1> {ls} </body></xml> --------- Thanks for any help!
_______________________________________________ Ur mailing list [email protected] http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
