AmpersandTarski / Ampersand

Build database applications faster than anyone else, and keep your data pollution free as a bonus.
http://ampersandtarski.github.io/
GNU General Public License v3.0
40 stars 8 forks source link

Cannot use 'trace' as a label in INTERFACES #447

Closed RieksJ closed 5 years ago

RieksJ commented 8 years ago

Consider the following script:

CONTEXT Issue447 IN ENGLISH

var :: A * B [UNI,TOT]
trace :: B * A [INJ,UNI,TOT]

POPULATION var CONTAINS [("a1","b1"),("a2","b2")] -- 
POPULATION var CONTAINS [("a3","b1"),("a4","b2")]
POPULATION trace CONTAINS [("b1","a1"),("b2","a2")]

INTERFACE "Test"  : V[SESSION*B] COLS
 [ "B"            : I
 , "var~"         : var~
 , "trace"        : trace
 , "var~ - trace" : var~ - trace
 ]

ENDCONTEXT

When you run the generated prototype, the trace field does not show anything. This is wrong, since trace is a functional relation and the script does not produce errors.

hanjoosten commented 8 years ago

curious! If trace is some kind of special word in javascript, how can we prevent using keywords? Is this a never-ending list?

Michiel-s commented 8 years ago

Issue occurs due to use of restangular library. Issue already mentioned there mgonto/restangular#1107

List of words that cannot be used as interface label are the restangular Element and Collection methods.

Michiel-s commented 8 years ago

Maybe the .plain() method will help. I'll look into this later.

Michiel-s commented 8 years ago

.plain() method does not help. We have two options:

Michiel-s commented 5 years ago

As of version v1.5.3 of Restangular (a library we use for API calls) a settings is introduced called setPlainByDefault. This prevents Restangular methods being added to resources, which caused the problem that certain labels (e.g. trace, get, post, put) could not be used.

This fix will be available in the next release.