-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathSqlScriptGenerator.AlterExternalModelStatement.cs
More file actions
130 lines (120 loc) · 4.53 KB
/
Copy pathSqlScriptGenerator.AlterExternalModelStatement.cs
File metadata and controls
130 lines (120 loc) · 4.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
//------------------------------------------------------------------------------
// <copyright file="SqlScriptGeneratorVisitor.AlterExternalModelStatement.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System.Globalization;
using System.Collections.Generic;
using Microsoft.SqlServer.TransactSql.ScriptDom;
namespace Microsoft.SqlServer.TransactSql.ScriptDom.ScriptGenerator
{
partial class SqlScriptGeneratorVisitor
{
public override void ExplicitVisit(AlterExternalModelStatement node)
{
GenerateKeyword(TSqlTokenType.Alter);
GenerateSpaceAndIdentifier(CodeGenerationSupporter.External);
GenerateSpaceAndIdentifier(CodeGenerationSupporter.Model);
GenerateAlterExternalModelStatementBody(node);
}
protected void GenerateAlterExternalModelStatementBody(AlterExternalModelStatement node)
{
// external model name
GenerateSpaceAndFragmentIfNotNull(node.Name);
NewLine();
GenerateKeywordAndSpace(TSqlTokenType.Set);
GenerateKeyword(TSqlTokenType.LeftParenthesis);
bool ifFirst = true;
// external model location
if (node.Location != null)
{
if (!ifFirst)
{
GenerateSymbol(TSqlTokenType.Comma);
}
ifFirst = false;
NewLine();
GenerateNameEqualsValue(CodeGenerationSupporter.Location, node.Location);
}
// external model API Format options
if (node.ApiFormat != null)
{
if (!ifFirst)
{
GenerateSymbol(TSqlTokenType.Comma);
}
ifFirst = false;
NewLine();
GenerateNameEqualsValue(CodeGenerationSupporter.ApiFormat, node.ApiFormat);
}
// external model Model Type options
if (node.ModelTypeSpecification != null)
{
if (!ifFirst)
{
GenerateSymbol(TSqlTokenType.Comma);
}
ifFirst = false;
NewLine();
GenerateFragmentIfNotNull(node.ModelTypeSpecification);
}
else if (node.ModelType != null)
{
if (!ifFirst)
{
GenerateSymbol(TSqlTokenType.Comma);
}
ifFirst = false;
NewLine();
string externalModelTypeOption = GetValueForEnumKey(_externalModelTypeOption, node.ModelType.Value);
GenerateNameEqualsValue(CodeGenerationSupporter.ModelType, externalModelTypeOption);
}
// external model name options
if (node.ModelName != null)
{
if (!ifFirst)
{
GenerateSymbol(TSqlTokenType.Comma);
}
ifFirst = false;
NewLine();
GenerateNameEqualsValue(CodeGenerationSupporter.ModelName, node.ModelName);
}
// external model credential options
if (node.Credential != null)
{
if (!ifFirst)
{
GenerateSymbol(TSqlTokenType.Comma);
}
ifFirst = false;
NewLine();
GenerateNameEqualsValue(CodeGenerationSupporter.Credential, node.Credential);
}
// external model parameters options
if (node.Parameters != null)
{
if (!ifFirst)
{
GenerateSymbol(TSqlTokenType.Comma);
}
ifFirst = false;
NewLine();
GenerateNameEqualsValue(CodeGenerationSupporter.Parameters, node.Parameters);
}
// external model local runtime path options
if (node.LocalRuntimePath != null)
{
if (!ifFirst)
{
GenerateSymbol(TSqlTokenType.Comma);
}
ifFirst = false;
NewLine();
GenerateNameEqualsValue(CodeGenerationSupporter.LocalRuntimePath, node.LocalRuntimePath);
}
NewLine();
GenerateKeyword(TSqlTokenType.RightParenthesis);
}
}
}