public void InvalidScript1() { var content = new SqlScriptContent(); content.Content = ScriptManager.GetInvalidScript1(); Assert.False(content.IsValid); }
public PSSqlScriptContent(SqlScriptContent sqlscriptContent) { this.Query = sqlscriptContent?.Query; this.CurrentConnection = new PSSqlConnection(sqlscriptContent?.CurrentConnection); this.Metadata = new PSSqlScriptMetadata(sqlscriptContent?.Metadata); this.ResultLimit = sqlscriptContent?.ResultLimit; this.AdditionalProperties = sqlscriptContent?.AdditionalProperties; }
public override void ExecuteCmdlet() { if (this.IsParameterBound(c => c.WorkspaceObject)) { this.WorkspaceName = this.WorkspaceObject.Name; } if (!this.IsParameterBound(c => c.Name)) { string path = this.TryResolvePath(DefinitionFile); this.Name = Path.GetFileNameWithoutExtension(path); } if (this.ShouldProcess(this.WorkspaceName, String.Format(Resources.SettingSynapseSqlScript, this.Name, this.WorkspaceName))) { string query = this.ReadFileAsText(DefinitionFile); SqlConnection currentConnection = new SqlConnection(); if (this.IsParameterBound(c => c.SqlPoolName)) { if (SqlPoolName.ToLower() == "built-in") { currentConnection.PoolName = "Built-in"; currentConnection.Type = SqlConnectionType.SqlOnDemand; currentConnection.DatabaseName = this.SqlDatabaseName; } else { currentConnection.Type = SqlConnectionType.SqlPool; currentConnection.PoolName = this.SqlPoolName; currentConnection.DatabaseName = this.SqlDatabaseName; } } else { currentConnection.PoolName = "Built-in"; currentConnection.Type = SqlConnectionType.SqlOnDemand; currentConnection.DatabaseName = "master"; } SqlScriptMetadata metadata = new SqlScriptMetadata { Language = "sql" }; SqlScriptContent content = new SqlScriptContent(query); content.CurrentConnection = currentConnection; content.Metadata = metadata; content.ResultLimit = ResultLimit; SqlScript sqlscript = new SqlScript(content); sqlscript.Type = SqlScriptType.SqlQuery; if (this.IsParameterBound(c => c.FolderPath)) { SqlScriptFolder folder = new SqlScriptFolder(); folder.Name = FolderPath; sqlscript.Folder = folder; } if (this.IsParameterBound(c => c.Description)) { sqlscript.Description = Description; } SqlScriptResource sqlscriptResource = new SqlScriptResource(this.Name, sqlscript); WriteObject(new PSSqlScriptResource(SynapseAnalyticsClient.CreateOrUpdateSqlScript(this.Name, sqlscriptResource), this.WorkspaceName)); } }
public DeploymentException(string message, Exception ex, SqlScriptFile currentFile, SqlScriptContent currentContent) : this(ex) { this.ScriptFile = currentFile; this.FileName = ScriptFile.Name; this.ScriptContent = currentContent; if (ex is SqlException) { var sqlex = ex as SqlException; this.LineNumber = sqlex.LineNumber;//TODO: Convert ScriptContent Line to FileLine } }