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

name of standard trait is automatically prefixed with 'cdm:/primitives.cdm.json/' #353

Closed
dgcaron opened this issue Feb 24, 2023 · 5 comments

Comments

@dgcaron
Copy link

dgcaron commented Feb 24, 2023

i am trying to create a common datsmodel using the typescript sdk but i am having trouble adding standard traits to my data model.

when i use


const newTrait: CdmTraitReference = this.corpus.MakeObject(cdmObjectType.traitRef, 'is.sensitive', false);
--
attribute.appliedTraits.push(newTrait, false);

the saved document contains

{
                    "name": "SSN",
                    "appliedTraits": [
                        {
                            "corpusPath": "cdm:/primitives.cdm.json/is.sensitive",
                            "identifier": "is.sensitive"
                        }
                    ],
                    "dataFormat": "String"
                },

whereas i expect it to be

{
                    "name": "SSN",
                    "appliedTraits": [
                        "is.sensitive"
                    ],
                    "dataFormat": "String"
                },

this behaviour goes away if i remove the primitives / foundations import from the entity document.

@dgcaron dgcaron changed the title + name of standard trait is automatically prefixed with 'cdm:/primitives.cdm.json/' Feb 24, 2023
@Venkata1920
Copy link
Collaborator

Hi @dgcaron , could you provide a sample of your code that saves the file in this schema?

@dgcaron
Copy link
Author

dgcaron commented Mar 1, 2023

Sure, I am on a short break right now but will provide a gist of the code at the end of the week.

@dgcaron
Copy link
Author

dgcaron commented Mar 6, 2023

hi, i have created a repro with a test here where you can run the code using an azure default credential.

cdm-trait-gist

this code saves the manifest and the entity docs directly to adls gen2

@mafrisci
Copy link
Collaborator

mafrisci commented Mar 6, 2023

hi, I see the issue is here: https://github.com/dgcaron/cdm-trait-gist/blob/b58681a910f9c28ecc23ef3fe3db396e4084113c/src/index.ts#L183

If you remove the copyOptions and call SaveAsAsync with only the first two parameters, it should work as expected. I think that 'StringRefs' parameter is poorly named as it does not create string references if set to true (it is false by default). The default copyOptions should be what you are looking for.

@dgcaron
Copy link
Author

dgcaron commented Mar 7, 2023

yes, that fixes the issue. thanks for taking the time to check this out!

@dgcaron dgcaron closed this as completed Mar 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants