fix duplicate db references being allowed (#12795)

This commit is contained in:
Kim Santiago
2020-10-08 09:55:51 -07:00
committed by GitHub
parent 18f87ab03c
commit bd56c49538

View File

@@ -435,6 +435,12 @@ export class Project {
*/ */
public async addProjectReference(settings: IProjectReferenceSettings): Promise<void> { public async addProjectReference(settings: IProjectReferenceSettings): Promise<void> {
const projectReferenceEntry = new SqlProjectReferenceProjectEntry(settings); const projectReferenceEntry = new SqlProjectReferenceProjectEntry(settings);
// check if reference to this database already exists
if (this.databaseReferenceExists(projectReferenceEntry)) {
throw new Error(constants.databaseReferenceAlreadyExists);
}
await this.addToProjFile(projectReferenceEntry); await this.addToProjFile(projectReferenceEntry);
} }
@@ -621,7 +627,7 @@ export class Project {
} }
private databaseReferenceExists(entry: IDatabaseReferenceProjectEntry): boolean { private databaseReferenceExists(entry: IDatabaseReferenceProjectEntry): boolean {
const found = this.databaseReferences.find(reference => reference.fsUri.fsPath === entry.fsUri.fsPath) !== undefined; const found = this.databaseReferences.find(reference => reference.pathForSqlProj() === entry.pathForSqlProj()) !== undefined;
return found; return found;
} }