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

fix: change OrmUtils.mergeDeep to not merge RegExp objects #5182

Merged
merged 5 commits into from
Jan 22, 2020

Conversation

tobyhinloopen
Copy link
Contributor

@tobyhinloopen tobyhinloopen commented Dec 5, 2019

Closes #3534

Before entity column values are transformed, changes are deeply merged using OrmUtils.mergeDeep. This mergeDeep function attempts to merge objects, but wrongly attempted to merge RegExp objects. This merging of RegExp objects breaks the object, rendering them unusable. This commit changes mergeDeep to not merge RegExp objects but overwrite them instead.

To cleanup the mergeDeep function, I also refactored propertyKey away, and I changed all references to source[key] or source[propertyKey] to value, also removing the commented code.

@tobyhinloopen tobyhinloopen changed the title Change OrmUtils.mergeDeep to not merge RegExp objects fix: change OrmUtils.mergeDeep to not merge RegExp objects Dec 5, 2019
Before entity column values are transformed, changes are deeply merged using OrmUtils.mergeDeep. This mergeDeep function attempts to merge objects, but wrongly attempted to merge RegExp objects. This merging of RegExp objects breaks the object, rendering them unusable. This commit changes mergeDeep to not merge RegExp objects but overwrite them instead.

Closes typeorm#3534
before(async () => {
connections = await createTestingConnections({
entities: [__dirname + '/entity/*{.js,.ts}'],
enabledDrivers: ['postgres'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please enable all drivers? since we don't have anything postgres specific

connections = await createTestingConnections({
entities: [__dirname + '/entity/*{.js,.ts}'],
enabledDrivers: ['postgres'],
dropSchema: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need it? (please remove if we don't)

after(() => closeTestingConnections(connections));

it('allows entities with regexp columns', () => PromiseUtils.runInSequence(connections, async connection => {
await connection.synchronize();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't usually do it this way... can you please remove it? (just take a look on other tests how we do it in most of the times)...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im just trying to find why tests are passed but CI failed. Usually it happens on a "stucked promise", but I can't easily find the problem in this test

@pleerock
Copy link
Member

Looks like a valid feature request, we just need to find out why CI failed.

@pleerock
Copy link
Member

I applied few changes let's see if tests won't fail.

@tobyhinloopen
Copy link
Contributor Author

@pleerock Thanks for your review. I'll fix any remaining issues / feedback one of the next (work)days. :)

@tobyhinloopen
Copy link
Contributor Author

@pleerock - The CI is 🍏

@pleerock pleerock merged commit 0f51836 into typeorm:master Jan 22, 2020
@pleerock
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

RegExp.prototype.source getter called on non-RegExp object
2 participants