public override string Translate(SqlCompilerContext context, SqlUnary node, NodeSection section)
        {
            //substitute UNIQUE predicate with a more complex EXISTS predicate,
            //because UNIQUE is not supported

            if (node.NodeType == SqlNodeType.Unique)
            {
                if (node.Operand is SqlSubQuery origSubselect)
                {
                    var origQuery = SqlDml.QueryRef(origSubselect.Query);
                    var existsOp  = SqlDml.Select(origQuery);
                    existsOp.Columns.Add(1);
                    existsOp.Where = true;
                    foreach (SqlColumn col in origQuery.Columns)
                    {
                        existsOp.Where = existsOp.Where && SqlDml.IsNotNull(col);
                        existsOp.GroupBy.Add(col);
                    }
                    existsOp.Having = SqlDml.Count(SqlDml.Asterisk) > 1;
                    existsOp.Limit  = 1;

                    node.ReplaceWith(SqlDml.Not(SqlDml.Exists(existsOp)));
                }
            }
            return(base.Translate(context, node, section));
        }
        public void SqlUnaryReplacingTest()
        {
            SqlUnary u          = -SqlDml.Literal(1);
            SqlUnary uReplacing = ~SqlDml.Literal(2);

            u.ReplaceWith(uReplacing);

            bool passed = false;

            try {
                u.ReplaceWith(1);
            }
            catch {
                passed = true;
            }

            Assert.IsTrue(passed);
            Assert.AreNotEqual(u, uReplacing);
            Assert.AreEqual(u.NodeType, uReplacing.NodeType);
            Assert.AreEqual(u.Operand, uReplacing.Operand);
        }