Skip to content

Add warning when developer overrides host without specifying merge #4925

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

Merged
merged 2 commits into from
May 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions packages/firestore/src/api/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ import {
validateIsNotUsedTogether,
validateSetOptions
} from '../util/input_validation';
import { setLogLevel as setClientLogLevel } from '../util/log';
import { logWarn, setLogLevel as setClientLogLevel } from '../util/log';

import { Blob } from './blob';
import {
Expand Down Expand Up @@ -216,14 +216,26 @@ export class Firestore
}

settings(settingsLiteral: PublicSettings): void {
const currentSettings = this._delegate._getSettings();
if (
!settingsLiteral.merge &&
currentSettings.host !== settingsLiteral.host
) {
logWarn(
'You are overriding the original host. If you did not intend ' +
'to override your settings, use {merge: true}.'
);
}

if (settingsLiteral.merge) {
settingsLiteral = {
...this._delegate._getSettings(),
...currentSettings,
...settingsLiteral
};
// Remove the property from the settings once the merge is completed
delete settingsLiteral.merge;
}

this._delegate._setSettings(settingsLiteral);
}

Expand Down