public override IMigrationProcessor Create(string connectionString, IAnnouncer announcer, IMigrationProcessorOptions options)
        {
            var factory    = new SQLiteDbFactory(_serviceProvider);
            var connection = factory.CreateConnection(connectionString);
            var quoter     = new SQLiteQuoter();

            return(new SQLiteProcessor(connection, new SQLiteGenerator(quoter), announcer, options, factory, quoter));
        }
Пример #2
0
 public NzbDroneSQLiteProcessor(SQLiteDbFactory factory,
                                SQLiteGenerator generator,
                                ILogger <NzbDroneSQLiteProcessor> logger,
                                IOptionsSnapshot <ProcessorOptions> options,
                                IConnectionStringAccessor connectionStringAccessor,
                                IServiceProvider serviceProvider,
                                SQLiteQuoter quoter)
     : base(factory, generator, logger, options, connectionStringAccessor, serviceProvider, quoter)
 {
 }
Пример #3
0
 public SQLiteProcessor(
     IDbConnection connection,
     IMigrationGenerator generator,
     IAnnouncer announcer,
     [NotNull] IMigrationProcessorOptions options,
     IDbFactory factory,
     [NotNull] SQLiteQuoter quoter)
     : base(connection, factory, generator, announcer, options)
 {
     _quoter = quoter;
 }
Пример #4
0
 public SQLiteProcessor(
     [NotNull] SQLiteDbFactory factory,
     [NotNull] SQLiteGenerator generator,
     [NotNull] ILogger <SQLiteProcessor> logger,
     [NotNull] IOptionsSnapshot <ProcessorOptions> options,
     [NotNull] IConnectionStringAccessor connectionStringAccessor,
     [NotNull] IServiceProvider serviceProvider,
     [NotNull] SQLiteQuoter quoter)
     : base(() => factory.Factory, generator, logger, options.Value, connectionStringAccessor)
 {
     _serviceProvider = serviceProvider;
     _quoter          = quoter;
 }
Пример #5
0
        protected virtual void ProcessAlterTable(TableDefinition tableDefinition, List <ColumnDefinition> oldColumnDefinitions = null)
        {
            var tableName     = tableDefinition.Name;
            var tempTableName = tableName + "_temp";

            var uid = 0;

            while (TableExists(null, tempTableName))
            {
                tempTableName = tableName + "_temp" + uid++;
            }

            // What is the cleanest way to do this? Add function to Generator?
            var quoter          = new SQLiteQuoter();
            var columnsToInsert = string.Join(", ", tableDefinition.Columns.Select(c => quoter.QuoteColumnName(c.Name)));
            var columnsToFetch  = string.Join(", ", (oldColumnDefinitions ?? tableDefinition.Columns).Select(c => quoter.QuoteColumnName(c.Name)));


            Process(new CreateTableExpression()
            {
                TableName = tempTableName, Columns = tableDefinition.Columns.ToList()
            });

            Process(string.Format("INSERT INTO {0} ({1}) SELECT {2} FROM {3}", quoter.QuoteTableName(tempTableName), columnsToInsert, columnsToFetch, quoter.QuoteTableName(tableName)));

            Process(new DeleteTableExpression()
            {
                TableName = tableName
            });

            Process(new RenameTableExpression()
            {
                OldName = tempTableName, NewName = tableName
            });

            foreach (var index in tableDefinition.Indexes)
            {
                Process(new CreateIndexExpression()
                {
                    Index = index
                });
            }
        }
Пример #6
0
        public void ShouldEscapeSqliteObjectNames()
        {
            SQLiteQuoter quoter = new SQLiteQuoter();

            quoter.Quote("Table\"Name").ShouldBe("\"Table\"\"Name\"");
        }
Пример #7
0
 public void ShouldEscapeSqliteObjectNames()
 {
     SQLiteQuoter quoter = new SQLiteQuoter();
     quoter.Quote("Table\"Name").ShouldBe("\"Table\"\"Name\"");
 }
Пример #8
0
        protected virtual void ProcessAlterTable(TableDefinition tableDefinition)
        {
            var tableName = tableDefinition.Name;
            var tempTableName = tableName + "_temp";

            var uid = 0;
            while (TableExists(null, tempTableName))
            {
                tempTableName = tableName + "_temp" + uid++;
            }

            // What is the cleanest way to do this? Add function to Generator?
            var quoter = new SQLiteQuoter();
            var columnsToTransfer = string.Join(", ", tableDefinition.Columns.Select(c => quoter.QuoteColumnName(c.Name)));

            Process(new CreateTableExpression() { TableName = tempTableName, Columns = tableDefinition.Columns.ToList() });

            Process(string.Format("INSERT INTO {0} SELECT {1} FROM {2}", quoter.QuoteTableName(tempTableName), columnsToTransfer, quoter.QuoteTableName(tableName)));

            Process(new DeleteTableExpression() { TableName = tableName });

            Process(new RenameTableExpression() { OldName = tempTableName, NewName = tableName });

            foreach (var index in tableDefinition.Indexes)
            {
                Process(new CreateIndexExpression() { Index = index });
            }
        }