Exemplo n.º 1
0
        public void Delete1()
        {
            var statement = Sql.Delete.Top(1).From(Sql.Name("foo.bar"));

            var text = Provider.GenerateStatement(statement);

            Assert.IsNotNull(text);
            Assert.AreEqual("DELETE FROM \"foo\".\"bar\" LIMIT 1;", text);
        }
Exemplo n.º 2
0
        public IStatement BeginCommitTransactions()
        {
            var statement = Sql.Statements(Sql.BeginTransaction(), Sql.CommitTransaction());

            var text = Provider.GenerateStatement(statement);

            Assert.IsNotNull(text);
            Assert.AreEqual("BEGIN TRANSACTION;\r\nCOMMIT TRANSACTION;", text);
            return(statement);
        }
Exemplo n.º 3
0
        public static void AreEqual(IStatement statement, string script)
        {
            var text = Provider.GenerateStatement(statement);

            Assert.NotNull(text);
            Assert.Equal(script, text);
        }
Exemplo n.º 4
0
        public void UpdateDefault()
        {
            var statement =
                Sql.Update("foo.bar").Set(Sql.Name("a"), Sql.Scalar(1)).Where(Sql.Name("z").IsEqual(Sql.Scalar("b")));

            var text = Provider.GenerateStatement(statement);

            Assert.IsNotNull(text);
            Assert.AreEqual("UPDATE \"foo\".\"bar\" SET \"a\" = 1 WHERE \"z\" = 'b';", text);
        }
Exemplo n.º 5
0
        public IStatement CreateTable()
        {
            var statement = Sql.CreateTable(Sql.Name("tbl"), false)
                            .Columns(
                TableColumn.Int("C1").NotNull().PrimaryKey().AutoIncrement()
                , TableColumn.NVarChar("C2").Null().Default("foo"))
            ;

            var text = Provider.GenerateStatement(statement);


            Assert.IsNotNull(text);
            Assert.AreEqual(
                "CREATE TABLE \"tbl\" ( \"C1\" INTEGER PRIMARY KEY ASC AUTOINCREMENT NOT NULL, \"C2\" NVARCHAR NULL DEFAULT ( 'foo' ) );",
                text);
            return(statement);
        }
Exemplo n.º 6
0
        public void InsertDefault()
        {
            var statement = Sql.Insert.Into(Sql.Name("foo.bar")).DefaultValues();

            var text = Provider.GenerateStatement(statement);

            Assert.IsNotNull(text);
            Assert.AreEqual("INSERT INTO \"foo\".\"bar\" DEFAULT VALUES;", text);
        }
Exemplo n.º 7
0
        public IStatement Select1()
        {
            var statement = Sql.Select.Output(Sql.Scalar(1));

            var text = Provider.GenerateStatement(statement);

            Assert.NotNull(text);
            Assert.Equal("SELECT 1;", text);
            return(statement);
        }