question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`get` properties break record merging

See original GitHub issue

In Collection#add when onConflict === 'merge' the utils.deepMixin is called on records, but when a record has a property with only getter it breaks.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
altschulercommented, Jan 18, 2017

Great! Very informative, thank you very much! And thank you very, very much for js-data! 😃

0reactions
jmdobrycommented, Jan 18, 2017

You ran into this issue because of the way TypeScript compiles ES2015 classes to ES5. According to the ES2015 spec, your getter property should be non-enumerable, but TypeScript produces an enumerable property, hence why it is seen by utils.deepMixIn as it iterates over properties of the record.

You can change it to a method, as you mentioned, or you could add a setter that does nothing, or you can modify it to be non-enumerable.

Option 1:

export class Person extends Record {
  age: number;
  isAdult () { return this.age > 18 }
}

Option 2:

export class Person extends Record {
  age: number;
  get isAdult () { return this.age > 18 }
  set isAdult () {}
}

Option 3:

export class Person extends Record {
  age: number;
  get isAdult () { return this.age > 18 }
}
Object.defineProperty(
  Person.prototype,
  Object.assign(
    Object.getOwnPropertyDescriptor(Person.prototype, 'isAdult'),
    {
      enumerable: false
    }
  ),
  'isAdult'
)

EDIT: Fixed typo in Option 3 code

Read more comments on GitHub >

github_iconTop Results From Across the Web

Procedure for Splitting or Merging Property
Our office will split or merge your property as long as you supply us with the legal description. Our office will not create...
Read more >
Dividing and Merging Lots - NYC.gov
Apportionment and Merger Filing ... July 2, 2019 - New rules and policies for obtaining final tax lots for properties that have applied...
Read more >
Duplicate Records - How to Merge Attributes from 2...
I merged 2 separate shps into one master shp. Now, I have a shp that contains many duplicate records. Each shp contained some...
Read more >
How do I avoid large number of svn:mergeInfo when merging ...
I am trying to keep a feature branch up to date by merging trunk into the branch. Problem is, that about 2000 files...
Read more >
Mastering: Matching and Merging - Documentation - MarkLogic
Matching determines if two records are candidates for merging, based on the degree of similarity between them and the weight of the comparison....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found