示例#1
0
 public static SqlExpression ParseDefaultValue(string expr, ISqlDialect dialect)
 {
     if (expr == null)
     {
         return(null);
     }
     if (expr.Trim() == "")
     {
         return(null);
     }
     if (dialect == null)
     {
         dialect = new GenericDialect();
     }
     try
     {
         ISqlParser par = dialect.CreateParser(expr);
         par.AllowOperators = false;
         par.AllowSpecialConstantReplacement = true;
         var res = par.ParseExpression();
         if (res != null && res.XmlPersistent)
         {
             return(res);
         }
     }
     catch { }
     return(new SpecificSqlExpression(expr, dialect != null ? dialect.DialectName : null, SymbolPosition.WholeString(expr)));
 }
示例#2
0
            public override void RunCommand()
            {
                if (Template == null)
                {
                    throw new CommandLineError("DAE-00153 Missing template argument");
                }
                IDatabaseSource db = m_connection.GetConnection();

                Async.SafeOpen(db.Connection);
                IAppObjectSqlGenerator sqlgen = (IAppObjectSqlGenerator)AppObjectSqlGeneratorAddonType.Instance.FindHolder(Template).CreateInstance();
                ISqlDialect            dial;

                if (Dialect != null)
                {
                    dial = (ISqlDialect)DialectAddonType.Instance.FindHolder(Dialect).CreateInstance();
                }
                else
                {
                    dial = new GenericDialect();
                }
                using (TextWriter fw = GetOutputStream())
                {
                    SqlOutputStream so   = new SqlOutputStream(dial, fw, new SqlFormatProperties());
                    ISqlDumper      dmp  = dial.CreateDumper(so, new SqlFormatProperties());
                    var             name = new FullDatabaseRelatedName
                    {
                        ObjectName = new NameWithSchema(Objschema, Objname),
                        ObjectType = Objtype,
                        SubName    = Subname
                    };
                    sqlgen.GenerateSql(db, name, dmp, dial);
                }
                Async.SafeClose(db.Connection);
            }
示例#3
0
        public override ISqlDialect CloneDialect()
        {
            var res = new GenericDialect();

            res.m_builder = this.m_builder;
            res.m_factory = this.m_factory;
            return(res);
        }
示例#4
0
        public void GenerateFillTable(ITableSource table, TextWriter tw, ISqlDialect dialect)
        {
            if (dialect == null)
            {
                dialect = new GenericDialect();
            }
            ISqlDumper dmp = dialect.CreateDumper(tw, TemplateFormatProps);

            GenerateFillTable(table, dmp, dialect);
        }
示例#5
0
        public void GenerateDropAllTables(IDatabaseSource conn, TextWriter tw, ISqlDialect dialect)
        {
            if (dialect == null)
            {
                dialect = new GenericDialect();
            }
            ISqlDumper dmp = dialect.CreateDumper(tw, TemplateFormatProps);

            GenerateDropAllTables(conn, dmp, dialect);
        }
示例#6
0
        public static string GenerateScript(this ISqlDialect dialect, Action <ISqlDumper> script, SqlFormatProperties props)
        {
            StringWriter sw = new StringWriter();
            ISqlDumper   dmp;

            if (dialect != null)
            {
                dmp = dialect.CreateDumper(sw, props);
            }
            else
            {
                dialect = new GenericDialect();
                dmp     = new InfoSqlDumper(new SqlOutputStream(dialect, sw, props), dialect, props);
            }
            script(dmp);
            return(sw.ToString());
        }
示例#7
0
 public static string SafeGetSql(this SqlExpression expr, ISqlDialect dialect)
 {
     if (expr == null)
     {
         return(null);
     }
     if (dialect == null)
     {
         dialect = new GenericDialect();
     }
     try
     {
         return(dialect.GenerateScript(expr.GenerateSql));
     }
     catch
     {
         return(null);
     }
 }