Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concerto 1.0 generates identifiers even when they should be user-provided #244

Closed
jeromesimeon opened this issue Mar 23, 2021 · 4 comments
Closed
Assignees
Labels

Comments

@jeromesimeon
Copy link
Member

Description

I think this should be a bug? I thought user-declared identifiers (with identified by XXX) were now meant to be provided by the user -- and distinguished from system generated identifiers (with identified).

But Concerto 1.0.0-alpha.2 generates user-declared identifiers. For instance:

Model

namespace org.test

concept C identified by id {
	o String name
	o String id
}

Data

{
    "$class": "org.test.C",
    "name": "John"
}

Validates as:

zsh-5.8$ concerto validate --ctoFiles test6.cto --sample test6.json  
10:49:53 AM - INFO: 
{
  "$class": "org.test.C",
  "name": "John",
  "id": "e55698df-2218-40ee-bcf9-13e6bfb38958"
}
@jeromesimeon
Copy link
Member Author

I'm unclear if that is the intended behaviour though.

@dselman
Copy link
Contributor

dselman commented Mar 23, 2021

That's a bug imo - id is declared as an identifier and identifiers are never optional.

@jeromesimeon
Copy link
Member Author

That's a bug imo - id is declared as an identifier and identifiers are never optional.

That makes sense to me too!

I think the issue here is that id is automatically generated (so it behaves is if it had a default generated value, even when not optional).

@jeromesimeon
Copy link
Member Author

Addressed in #246:

zsh-5.8$ more test.cto
namespace org.test

concept C identified by id {
        o String name
        o String id
}
zsh-5.8$ more test.json
{
    "$class": "org.test.C",
    "name": "John"
}
zsh-5.8$ ./index.js validate --model test.cto --input test.json
2:16:00 PM - INFO: Input is invalid
2:16:00 PM - ERROR: Invalid or missing identifier for Type C in namespace org.test
zsh-5.8$ ./index.js validate --model test.cto --input test.json --functional
2:16:01 PM - INFO: Input is invalid
2:16:01 PM - ERROR: Instance org.test.C#undefined has an empty identifier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants