// replace string argument(s) with Value object (string treated as values) internal static void PrepareFunctionArguments(FunctionArgument[] arguments, DbNode node) { if (node.Map.Params.Count > 0) { if (arguments.IsEmpty()) { node.Mapper.Throw(QueryTalkExceptionType.MissingFunctionArguments, null, Text.NotAvailable); } } else { return; } for (int i = 0; i < arguments.Length; ++i) { var arg = arguments[i]; if (!arg.IsNullReference() && arg.Original is System.String) { if (Variable.Detect(arg.Original)) { continue; } arguments[i] = new FunctionArgument(((string)arguments[i].Original).V()); } } }
internal string BuildString(string arg) { if (Variable.Detect(arg)) { return(arg); } else { return(arg.Parameterize(this) ?? Mapping.BuildCast(arg)); } }
internal bool ProcessVariable( BuildContext buildContext, BuildArgs buildArgs, out string sql, Variable variable) { sql = null; if (variable == null) { if (Variable.Detect(Original)) { if (buildContext.Root.CompilableType.IsProcOrSnippet() || (buildContext.Root.CompilableType == Compilable.ObjectType.View && buildContext.Query.Master.Root.CompilableType.IsProc())) { buildContext.Exception = new QueryTalkException("Argument.ProcessVariable", QueryTalkExceptionType.ParamOrVariableNotDeclared, String.Format("variable = {0}", Original)); return(true); } // non-declared variables in views are valid: if (buildContext.Root.CompilableType == Compilable.ObjectType.View) { sql = (string)Original; return(true); } } return(false); } // here variable has been found: buildContext.TryTakeException(variable.DisallowedInliningException()); if (buildContext.Exception != null) { return(true); } if (variable.IsConcatenator()) { sql = BuildConcatenator(buildContext, buildArgs, variable); return(true); } buildContext.TryAddParamToConcatRoot(variable); return(false); }
internal static string ProcessVariable( string argument, BuildContext buildContext, BuildArgs buildArgs, out QueryTalkException exception) { exception = null; var variable = buildContext.TryGetVariable(argument, out exception); if (exception != null) { return(null); } if (variable == null) { if (Variable.Detect(argument)) { if (buildContext.Root.CompilableType.IsProc() || (buildContext.Root.CompilableType == Compilable.ObjectType.View && buildContext.Query.Master.Root.CompilableType.IsProc())) { buildContext.Exception = new QueryTalkException("Variable.ProcessVariable", QueryTalkExceptionType.ParamOrVariableNotDeclared, String.Format("variable = {0}", argument)); return(null); } } return(null); } buildContext.TryTakeException(variable.DisallowedInliningException()); if (buildContext.Exception != null) { return(null); } if (variable.IsConcatenator()) { return(Argument.BuildConcatenator(buildContext, buildArgs, variable)); } buildContext.TryAddParamToConcatRoot(variable); return(null); }
private void RemoveTabs() { _tabControl.ThreadSafeInvoke(new Action(() => { _tabControl.SelectedTab = _tabSQL; })); foreach (TabPage tab in _tabControl.TabPages) { if (tab == _tabSQL || Variable.Detect(tab.Text) || Common.IsTempTable(tab.Text)) { continue; } _tabControl.ThreadSafeInvoke(new Action(() => _tabControl.TabPages.Remove(tab))); } }
private string BuildStoredProcArguments() { StringBuilder argumentBuilder = new StringBuilder(); int i = 0; var root = _compilable.GetRoot(); root.AllParams .ForEach(param => { if (i++ == 0) { argumentBuilder.Append(Text.OneSpace); } else { argumentBuilder.Append(Text.Comma); } if (Admin.IsValueParameterizationOn) { argumentBuilder.Append(param.Name); } else // (unreachable code) { #pragma warning disable CS0162 // Unreachable code detected if (!_inner) #pragma warning restore CS0162 // Unreachable code detected { argumentBuilder.Append(param.Name); } else { object directArgument = Arguments .Where(a => a.ParamName == param.Name) .Select(a => a.Value) .FirstOrDefault(); Type directArgumentType = directArgument == null ? null : directArgument.GetType(); if (Variable.Detect(directArgument)) { argumentBuilder.Append((string)directArgument); } else { if (directArgument != null && (directArgumentType == typeof(View) || (directArgumentType == typeof(DataTable)))) { argumentBuilder.Append(param.Name); } else { argumentBuilder.Append(Mapping.BuildUnchecked(directArgument)); } } } } if (param.IsOutput) { argumentBuilder.S().Append(Text.Output); } }); argumentBuilder.Terminate(); if (chainException != null) { TryThrow(Text.Method.Pass); } return(argumentBuilder.ToString()); }