Ejemplo n.º 1
0
        public static void SinglePrivilege_WithNoGrantOption()
        {
            var statement = new GrantPrivilegesStatement("user1", Privileges.Select, ObjectName.Parse("t1"));

            var sql = statement.ToString();
            var expected = "GRANT SELECT TO user1 ON t1";
            Assert.AreEqual(expected, sql);
        }
Ejemplo n.º 2
0
        public static void SinglePrivilege_WithNoGrantOption()
        {
            var statement = new GrantPrivilegesStatement("user1", Privileges.Select, ObjectName.Parse("t1"));

            var sql      = statement.ToString();
            var expected = "GRANT SELECT TO user1 ON t1";

            Assert.AreEqual(expected, sql);
        }
Ejemplo n.º 3
0
        public static void MultiplePrivileges_WithGrantOption()
        {
            var privs     = Privileges.Update | Privileges.Insert;
            var statement = new GrantPrivilegesStatement("admin", privs, true, ObjectName.Parse("APP.test1"));

            var sql      = statement.ToString();
            var expected = "GRANT UPDATE, INSERT TO admin ON APP.test1 WITH GRANT OPTION";

            Assert.AreEqual(expected, sql);
        }
Ejemplo n.º 4
0
        public static void MultiplePrivileges_WithGrantOption()
        {
            var privs = Privileges.Update | Privileges.Insert;
            var statement = new GrantPrivilegesStatement("admin", privs, true, ObjectName.Parse("APP.test1"));

            var sql = statement.ToString();
            var expected = "GRANT UPDATE, INSERT TO admin ON APP.test1 WITH GRANT OPTION";

            Assert.AreEqual(expected, sql);
        }
Ejemplo n.º 5
0
 protected virtual SqlStatement VisitGrantPrivilege(GrantPrivilegesStatement statement)
 {
     return new GrantPrivilegesStatement(statement.Grantee, statement.Privilege, statement.WithGrant, statement.ObjectName,
         statement.Columns);
 }
Ejemplo n.º 6
0
        public void GrantPrivilegesNoOption()
        {
            var privs = Privileges.Insert | Privileges.Update;
            var objName = ObjectName.Parse("APP.test_table1");
            var statement = new GrantPrivilegesStatement("user1", privs, objName);

            SerializeAndAssert(statement, (serialized, deserialized) => {
                Assert.IsNotNull(deserialized);
                Assert.IsNotNull(deserialized.ObjectName);
                Assert.IsNotNull(deserialized.Grantee);
                Assert.AreEqual(objName, deserialized.ObjectName);
                Assert.AreEqual("user1", deserialized.Grantee);
                Assert.AreEqual(privs, deserialized.Privilege);
                Assert.IsFalse(deserialized.WithGrant);
                Assert.IsNull(deserialized.Columns);
            });
        }
Ejemplo n.º 7
0
 protected virtual SqlStatement VisitGrantPrivilege(GrantPrivilegesStatement statement)
 {
     return(new GrantPrivilegesStatement(statement.Grantee, statement.Privilege, statement.WithGrant, statement.ObjectName,
                                         statement.Columns));
 }