Beispiel #1
0
 public void ShouldEscapeSqliteObjectNames()
 {
     SqliteQuoter quoter = new SqliteQuoter();
     quoter.Quote("Table'name").ShouldBe("'Table''name'");
 }
Beispiel #2
0
 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 });
            }
        }