[Ur] (minor) hidden table constraints

Sergey Mironov grrwlf at gmail.com
Thu Oct 17 08:32:53 EDT 2013


Hi!

I've triggered a 'hidden constraints' error while trying to link
tables from different modules.
I have a bunch of tables in my Template.ur module but I want others to
see only the 'product' table. So I've tried to hide constraints by
simply not listing them.

The scheme is following:


(* Template.ur; page table is 'private' *)
table page : { Id : int, MenuText : string }
  PRIMARY KEY Id
table product : { Id : int, Caption : string, Slogan : string, Logo :
string, PageId : int }
  PRIMARY KEY Id
  CONSTRAINT PageLink FOREIGN KEY PageId REFERENCES page(Id)

(* Template.urs declares only 'public' table, with no constraints *)
table product : { Id : int, Caption : string, Slogan : string, Logo :
string, PageId : int }

(* App.ur *)
val product = Template.product (* looks like table declarations don't
like dots in names. *)

table featuret : { Id : int, Content: string, ProductId : int }
  PRIMARY KEY Id,
  CONSTRAINT ProductLink FOREIGN KEY ProductId REFERENCES product(Id)

The compiler doesn't allow this code, I've posted the error below.
Luckily, declaring full set of tables in Template.urs works well.  My
question: Is there a way to hide some of table declarations inside the
module? Actually, I don't necessarily need tables themselves. It's OK
here to publish their signatures plus some kind of query stubs. From
App.ur I want to execute various selects, extending the stubs with
various WHEREs. What options do I have here?

Regards,
Sergey


$ urweb -dbms sqlite  AppMM
/home/grwlf/proj/uru/AppMM.ur:6:58: (to 6:65) Error in final record unification
Can't unify record constructors
Have:  Template.product_hidden_constraints
Need:  <UNIF:X::{{Unit}}> ++ [<UNIF:W::Name> = [Id = ()]]
/home/grwlf/proj/uru/AppMM.ur:6:58: (to 6:65) Stuck unifying these
records after canceling matching pieces:
Have:  Template.product_hidden_constraints
Need:
([<UNIF:W::Name> = map (fn _ :: Type => ()) ([Id = int])]) ++
 <UNIF:X::{{Unit}}>



More information about the Ur mailing list