public void CqlStatementBuilder_LoadSqlStatements_SplitsScriptCorrectly() { var cql = @"create keyspace my_keyspace with replication = { 'class' : 'SimpleStrategy', 'replication_factor' : '1' }; use my_keyspace; create table my_table ( id text, timestamp_unixepoch_ticks bigint, content text, primary key ((id), timestamp_unixepoch_ticks));"; var migrationScript = new FakeMigrationScript(cql); var sut = new CqlStatementBuilder(); var statements = sut.LoadSqlStatements(migrationScript, new Dictionary <string, string>()); Assert.Equal(3, statements.Count()); Assert.Equal(0, statements.ElementAt(0).LineNumber); Assert.Equal(5, statements.ElementAt(1).LineNumber); Assert.Equal(7, statements.ElementAt(2).LineNumber); Assert.False(statements.ElementAt(0).MustExecuteInTransaction); Assert.False(statements.ElementAt(1).MustExecuteInTransaction); Assert.False(statements.ElementAt(2).MustExecuteInTransaction); }
public void SQLServerStatementBuilder_LoadSqlStatements_SplitsScriptCorrectly() { string sql = @"PRINT 'GO' /* Create a user-defined table type. GO */ CREATE TYPE LocationTableType AS TABLE -- GO ( LocationName VARCHAR(50) , CostRate INT ); /* GO */ go GO -- ============================================= -- SSN -- ============================================= CREATE TYPE SSN FROM varchar(11) NOT NULL ; GO"; string sql1 = @"PRINT 'GO' /* Create a user-defined table type. GO */ CREATE TYPE LocationTableType AS TABLE -- GO ( LocationName VARCHAR(50) , CostRate INT ); /* GO */"; string sql2 = @"-- ============================================= -- SSN -- ============================================= CREATE TYPE SSN FROM varchar(11) NOT NULL ;"; var migrationScript = new FakeMigrationScript(sql); var sut = new SQLServerStatementBuilder(); var statements = sut.LoadSqlStatements(migrationScript, new Dictionary <string, string>()); Assert.Equal(2, statements.Count()); Assert.Equal(sql1, statements.ElementAt(0).Sql); Assert.Equal(sql2, statements.ElementAt(1).Sql); Assert.True(statements.ElementAt(0).MustExecuteInTransaction); Assert.True(statements.ElementAt(1).MustExecuteInTransaction); }
public void SimpleSqlStatementBuilder_LoadSqlStatements_SplitsScriptCorrectly() { var sql = @"-- Define a primary key constraint for table distributors. The following two examples are equivalent CREATE TABLE distributors1 ( did integer, name varchar(40), PRIMARY KEY(did) ); CREATE TABLE distributors2 ( did integer PRIMARY KEY, name varchar(40) ); INSERT INTO distributors2 VALUES(1, 'azerty');"; var migrationScript = new FakeMigrationScript(sql); var sut = new SimpleSqlStatementBuilder(); var statements = sut.LoadSqlStatements(migrationScript, new Dictionary <string, string>()); Assert.Single(statements); Assert.Equal(sql, statements.ElementAt(0).Sql); }