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

mergePrimitiveObjects fails on GenericDeserializeInto #53

Open
rightisleft opened this issue Mar 30, 2017 · 1 comment
Open

mergePrimitiveObjects fails on GenericDeserializeInto #53

rightisleft opened this issue Mar 30, 2017 · 1 comment

Comments

@rightisleft
Copy link

rightisleft commented Mar 30, 2017

I'm attempting to use GenericDeserializeInto to merge A and B where certain fields on A have the exact same values of object B, both B has some newer fields.
Result:

Production Error:

TypeError: Cannot assign to read only property '0' of string 'base'
    at /Users/jmurphy/projects/ubq/api/node_modules/cerialize/dist/serialize.js:321:34
    at Array.forEach (native)
    at mergePrimitiveObjects (/Users/jmurphy/projects/ubq/api/node_modules/cerialize/dist/serialize.js:294:23)
    at /Users/jmurphy/projects/ubq/api/node_modules/cerialize/dist/serialize.js:308:36
    at Array.forEach (native)
    at mergePrimitiveObjects (/Users/jmurphy/projects/ubq/api/node_modules/cerialize/dist/serialize.js:294:23)
    at /Users/jmurphy/projects/ubq/api/node_modules/cerialize/dist/serialize.js:308:36
    at Array.forEach (native)
    at mergePrimitiveObjects (/Users/jmurphy/projects/ubq/api/node_modules/cerialize/dist/serialize.js:294:23)
    at deserializeObjectInto (/Users/jmurphy/projects/ubq/api/node_modules/cerialize/dist/serialize.js:350:16)
    at deserializeObjectInto (/Users/jmurphy/projects/ubq/api/node_modules/cerialize/dist/serialize.js:402:37)
    at DeserializeInto (/Users/jmurphy/projects/ubq/api/node_modules/cerialize/dist/serialize.js:438:16)
    at Object.GenericDeserializeInto (/Users/jmurphy/projects/ubq/api/node_modules/cerialize/dist/serialize.js:622:12)
    at ModelController.<anonymous> (/Users/jmurphy/projects/ubq/api/dist/src/ubq/controllers/models.controller.js:105:41)
    at next (native)
    at fulfilled (/Users/jmurphy/projects/ubq/api/dist/src/ubq/controllers/models.controller.js:4:58)
    at process._tickCallback (internal/process/next_tick.js:103:7)
Cannot assign to read only property '0' of string 'base'

iModelDTO = GenericDeserializeInto(req.body, DTOModel, iModelDTO);

Test Harness Error:

let payload: any = { items: {
    "alpha": ["dna", "chromatin", "core", "hmg", "particles", "nucleosome", "histones", "nucleosomes", "micrococcal", "nuclease"],
    "beta": ["cancer", "studies", "risk", "data", "lave", "analysis", "seskin", "osaka", "registry", "analyses"],
    "delta": ["dna", "sequence", "sequences", "gene", "cloned", "region", "genes", "cdna", "repeated", "coding"],
    "gama": ["dna", "sequence", "sequences", "mitochondrial", "human", "wheat", "rrna", "rdna", "cytosine", "cell"]
} };

class IStringTMap<T> { [key: string]: T; };
class IStringMapStringArray extends IStringTMap<string[]> {};

class Airport {
  @autoserialize items: IStringMapStringArray;
}

let lax: Airport = GenericDeserialize<Airport>(payload, Airport);
let san: Airport = GenericDeserializeInto<Airport>(payload, Airport, lax);

console.log( lax );
console.log( san );
TypeError: Cannot assign to read only property '0' of string 'dna'
    at /Users/jmurphy/projects/test_harness/node_modules/cerialize/dist/serialize.js:321:34
    at Array.forEach (native)
    at mergePrimitiveObjects (/Users/jmurphy/projects/test_harness/node_modules/cerialize/dist/serialize.js:294:23)
    at /Users/jmurphy/projects/test_harness/node_modules/cerialize/dist/serialize.js:308:36
    at Array.forEach (native)
    at mergePrimitiveObjects (/Users/jmurphy/projects/test_harness/node_modules/cerialize/dist/serialize.js:294:23)
    at deserializeObjectInto (/Users/jmurphy/projects/test_harness/node_modules/cerialize/dist/serialize.js:350:16)
    at deserializeObjectInto (/Users/jmurphy/projects/test_harness/node_modules/cerialize/dist/serialize.js:402:37)
    at DeserializeInto (/Users/jmurphy/projects/test_harness/node_modules/cerialize/dist/serialize.js:438:16)
    at Object.GenericDeserializeInto (/Users/jmurphy/projects/test_harness/node_modules/cerialize/dist/serialize.js:622:12)

Process finished with exit code 1

@rightisleft
Copy link
Author

FYI:
I've swapped IStringMapStringArray for any, and i get the same results.

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

1 participant