Ejemplo n.º 1
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
                });
            }
        }
Ejemplo n.º 2
0
        public void ShouldEscapeSqliteObjectNames()
        {
            SqliteQuoter quoter = new SqliteQuoter();

            quoter.Quote("Table\"Name").ShouldBe("\"Table\"\"Name\"");
        }
Ejemplo n.º 3
0
        public void ShouldEscapeSqliteObjectNames()
        {
            SqliteQuoter quoter = new SqliteQuoter();

            quoter.Quote("Table'name").ShouldBe("'Table''name'");
        }