Beispiel #1
0
        public void TestConditionWhereString()
        {
            var sqlRaw = "select * from test";
            var nsql   = new NSQLQuery(sqlRaw);

            var texto = "nome do cliente";

            nsql.Where("coluna1", Op.IGUAL, texto);
            nsql.Where("coluna2", Op.Diferente, texto);

            Assert.AreEqual(nsql.ToSql(), sqlRaw + " WHERE coluna1 = 'nome do cliente' AND coluna2 != 'nome do cliente'", true);
        }
Beispiel #2
0
        public void TestConditionWHereNull()
        {
            var sqlRaw = "select * from test";
            var nsql   = new NSQLQuery(sqlRaw);

            nsql.Where("coluna1", Op.Null);
            var expected = "select * from test where coluna1 is null";

            Assert.AreEqual(expected, nsql.ToSql(), true);
        }
Beispiel #3
0
        public void TestConditionWhereNumber()
        {
            var sqlRaw = "select * from test";
            var nsql   = new NSQLQuery(sqlRaw);

            var valor = 10;

            nsql.Where("coluna1", Op.IGUAL, valor);

            Assert.AreEqual(nsql.ToSql(), sqlRaw + " WHERE coluna1 = 10", true);
        }
Beispiel #4
0
        public void TestConditionWhereSubCondition()
        {
            var sqlRaw = "select * from test";
            var nsql   = new NSQLQuery(sqlRaw);

            nsql.Where("coluna2", Op.IGUAL, "teste").Where(x =>
            {
                x.Where("coluna1", Op.IGUAL, "teste");
            });

            var expected = "select * from test WHERE coluna2 = 'teste' AND ( coluna1 = 'teste' )";

            Assert.AreEqual(expected, nsql.ToSql(), true);
        }
Beispiel #5
0
        public void TestConditionWhereOr()
        {
            var sqlRaw = "select * from test";
            var nsql   = new NSQLQuery(sqlRaw);

            var numero = 10;

            nsql.Where("coluna1", Op.IGUAL, numero);
            nsql.WhereOr("coluna2", Op.Diferente, numero);


            var expected = sqlRaw + " WHERE coluna1 = 10 OR coluna2 != 10";

            Assert.AreEqual(expected, nsql.ToSql(), true);
        }
Beispiel #6
0
        public void TestConditionWhereJoinWhere()
        {
            // Query Principal
            var sqlRaw = "select * from test";
            var nsql   = new NSQLQuery(sqlRaw);

            // Query 2
            var nSubSql = new NSQLQuery();

            nSubSql.Where("coluna1", Op.IGUAL, "TESTE");

            // Adiciona sub query
            nsql.JoinWhere(nSubSql);

            var expected = "select * from test WHERE coluna1 = 'TESTE'";

            Assert.AreEqual(expected, nsql.ToSql(), true);
        }