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)); }
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) { }
public SQLiteProcessor( IDbConnection connection, IMigrationGenerator generator, IAnnouncer announcer, [NotNull] IMigrationProcessorOptions options, IDbFactory factory, [NotNull] SQLiteQuoter quoter) : base(connection, factory, generator, announcer, options) { _quoter = quoter; }
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; }
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 }); } }
public void ShouldEscapeSqliteObjectNames() { SQLiteQuoter quoter = new SQLiteQuoter(); quoter.Quote("Table\"Name").ShouldBe("\"Table\"\"Name\""); }
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 }); } }