Add type for Document in sql database projects (#17539)

This commit is contained in:
Kim Santiago
2021-11-02 13:17:18 -07:00
committed by GitHub
parent 8c3c18e8dc
commit 312b410fff
4 changed files with 96 additions and 95 deletions

View File

@@ -158,22 +158,22 @@ export function convertSlashesForSqlProj(filePath: string): string {
* @param xmlDoc xml doc to read SQLCMD variables from. Format must be the same that sqlproj and publish profiles use
* @param publishProfile true if reading from publish profile
*/
export function readSqlCmdVariables(xmlDoc: any, publishProfile: boolean): Record<string, string> {
export function readSqlCmdVariables(xmlDoc: Document, publishProfile: boolean): Record<string, string> {
let sqlCmdVariables: Record<string, string> = {};
for (let i = 0; i < xmlDoc.documentElement.getElementsByTagName(constants.SqlCmdVariable)?.length; i++) {
const sqlCmdVar = xmlDoc.documentElement.getElementsByTagName(constants.SqlCmdVariable)[i];
const varName = sqlCmdVar.getAttribute(constants.Include);
const varName = sqlCmdVar.getAttribute(constants.Include)!;
// Publish profiles only support Value, so don't use DefaultValue even if it's there
// SSDT uses the Value (like <Value>$(SqlCmdVar__1)</Value>) where there
// are local variable values you can set in VS in the properties. Since we don't support that in ADS, only DefaultValue is supported for sqlproj.
if (!publishProfile && sqlCmdVar.getElementsByTagName(constants.DefaultValue)[0] !== undefined) {
// project file path
sqlCmdVariables[varName] = sqlCmdVar.getElementsByTagName(constants.DefaultValue)[0].childNodes[0].nodeValue;
sqlCmdVariables[varName] = sqlCmdVar.getElementsByTagName(constants.DefaultValue)[0].childNodes[0].nodeValue!;
}
else {
// profile path
sqlCmdVariables[varName] = sqlCmdVar.getElementsByTagName(constants.Value)[0].childNodes[0].nodeValue;
sqlCmdVariables[varName] = sqlCmdVar.getElementsByTagName(constants.Value)[0].childNodes[0].nodeValue!;
}
}