Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TableJournal"/> class.
 /// </summary>
 /// <param name="connectionManager">The connection manager.</param>
 /// <param name="logger">The log.</param>
 /// <param name="sqlObjectParser"></param>
 /// <param name="schema">The schema that contains the table.</param>
 /// <param name="table">The table name.</param>
 protected TableJournal(
     Func <IConnectionManager> connectionManager,
     Func <IUpgradeLog> logger,
     ISqlObjectParser sqlObjectParser,
     string schema, string table)
 {
     this.sqlObjectParser = sqlObjectParser;
     ConnectionManager    = connectionManager;
     Log = logger;
     UnquotedSchemaTableName = table;
     SchemaTableSchema       = schema;
     FqSchemaTableName       = string.IsNullOrEmpty(schema)
         ? sqlObjectParser.QuoteIdentifier(table)
         : sqlObjectParser.QuoteIdentifier(schema) + "." + sqlObjectParser.QuoteIdentifier(table);
 }
Пример #2
0
        protected IDbCommand GetCreateTableCommand(Func <IDbCommand> dbCommandFactory)
        {
            var command        = dbCommandFactory();
            var primaryKeyName = sqlObjectParser.QuoteIdentifier("PK_" + UnquotedSchemaTableName + "_Id");

            command.CommandText = CreateSchemaTableSql(primaryKeyName);
            command.CommandType = CommandType.Text;
            return(command);
        }
Пример #3
0
 string Preprocess(string query)
 {
     if (string.IsNullOrEmpty(Schema))
     {
         query = new StripSchemaPreprocessor().Process(query);
     }
     if (!string.IsNullOrEmpty(Schema) && !variables.ContainsKey("schema"))
     {
         variables.Add("schema", sqlObjectParser.QuoteIdentifier(Schema));
     }
     if (variablesEnabled())
     {
         query = new VariableSubstitutionPreprocessor(variables).Process(query);
     }
     query = additionalScriptPreprocessors.Aggregate(query, (current, additionalScriptPreprocessor) => additionalScriptPreprocessor.Process(current));
     return(query);
 }
Пример #4
0
 /// <summary>
 /// Quotes the sql object.
 /// </summary>
 /// <param name="schema"></param>
 protected string QuoteSqlObjectName(string objectName)
 {
     return(sqlObjectParser.QuoteIdentifier(objectName));
 }