コード例 #1
0
        public void OneColumn_NO_Direction()
        {
            string sql  = @"select userId from [me] order by userId";
            var    info = SQLParser.ParseSQL(sql);

            Assert.AreEqual(OrderByDirection.ASC, info.OrderBy.First().Direction);
        }
コード例 #2
0
        public void ColumnCount_1()
        {
            string sql  = @"select userId from [me]";
            var    info = SQLParser.ParseSQL(sql);

            Assert.AreEqual(1, info.Columns.Count);
        }
コード例 #3
0
        public void ColumnCount_2_Has2Alias()
        {
            string sql  = @"select userId as uid, userName as uname from [me]";
            var    info = SQLParser.ParseSQL(sql);

            Assert.AreEqual(2, info.Columns.Count);
        }
コード例 #4
0
        public void WhereClause_2()
        {
            string sql  = @"select userId from me where userId=100 and userId>1";
            var    info = SQLParser.ParseSQL(sql);

            Assert.AreEqual(3, info.WhereCondition.TotalCount);
        }
コード例 #5
0
        public void WhereClause_GreaterThen_Operator()
        {
            string sql  = @"select userId from me where userId=100 and userId>1";
            var    info = SQLParser.ParseSQL(sql);

            Assert.AreEqual(">", info.WhereCondition.Statement_RightNode.Condition_Operator);
        }
コード例 #6
0
        public void TableName_Equal_To_mE()
        {
            string sql  = @"select userId from mE";
            var    info = SQLParser.ParseSQL(sql);

            Assert.AreEqual("mE", info.TableDescriptor.TableName);
        }
コード例 #7
0
        public void PredictWordNotExists()
        {
            string sql  = @"select userId from [me]";
            var    info = SQLParser.ParseSQL(sql);

            Assert.AreEqual(false, info.Column_PredictExists);
        }
コード例 #8
0
        public void TwoColumn_OneDirection()
        {
            string sql  = @"select userId from [me] order by userId desc, userName";
            var    info = SQLParser.ParseSQL(sql);

            Assert.AreEqual(OrderByDirection.DESC, info.OrderBy[0].Direction);
            Assert.AreEqual(OrderByDirection.ASC, info.OrderBy[1].Direction);
        }
コード例 #9
0
        public void ColumnOnly()
        {
            string sql  = @"select 1";
            var    info = SQLParser.ParseSQL(sql);

            Assert.AreEqual(1, info.Columns.Count);
            Assert.AreEqual(null, info.TableDescriptor);
        }
コード例 #10
0
        public void TableName_Equal_To_me_READPAST()
        {
            string sql  = @"select userId from me(READPAST)";
            var    info = SQLParser.ParseSQL(sql);

            Assert.AreEqual("me", info.TableDescriptor.TableName);
            Assert.AreEqual(TableReadType.READPAST, info.TableDescriptor.TableReadType);
        }
コード例 #11
0
        public void PredictWordExists()
        {
            string sql  = @"select distinct userId from [me]";
            var    info = SQLParser.ParseSQL(sql);

            Assert.AreEqual(true, info.Column_PredictExists);
            Assert.AreEqual("distinct", info.Column_PredictWord);
        }
コード例 #12
0
        public void ColumnDetail_1_Has_UnderLine()
        {
            string sql  = @"Select user_Id from [me]";
            var    info = SQLParser.ParseSQL(sql);

            Assert.AreEqual("user_Id", info.Columns.First().Expression.ColumnName);
            Assert.AreEqual(ExpressionType.ColumnName, info.Columns.First().Expression.ExpressionType);
        }
コード例 #13
0
        public void ColumnDetail_1_FIX_NUMBER()
        {
            string sql  = @"Select 1 from [me]";
            var    info = SQLParser.ParseSQL(sql);

            Assert.AreEqual("1", info.Columns.First().Expression.ColumnName);
            Assert.AreEqual(ExpressionType.ColumnName, info.Columns.First().Expression.ExpressionType);
        }
コード例 #14
0
        static void Main(string[] args)
        {
            string sql  = @"select * from [me]";
            var    info = SQLParser.ParseSQL(sql);

            var generator = new DefaultSqlGenerator();

            Console.WriteLine(generator.Generate(info));
        }
コード例 #15
0
        public void WhereClause_1_string()
        {
            string sql  = @"select userId from me where userName='******'";
            var    info = SQLParser.ParseSQL(sql);

            Assert.AreEqual(1, info.WhereCondition.TotalCount);
            Assert.AreEqual("userName", info.WhereCondition.Condition_LeftExpression);
            Assert.AreEqual("=", info.WhereCondition.Condition_Operator);
            Assert.AreEqual("'McKay'", info.WhereCondition.Condition_RightExpression);
        }
コード例 #16
0
        public void ColumnDetail_2()
        {
            string sql  = @"Select userId, 1 from [me]";
            var    info = SQLParser.ParseSQL(sql);

            Assert.AreEqual("userId", info.Columns[0].Expression.ColumnName);
            Assert.AreEqual(ExpressionType.ColumnName, info.Columns[0].Expression.ExpressionType);

            Assert.AreEqual("1", info.Columns[1].Expression.ColumnName);
            Assert.AreEqual(ExpressionType.ColumnName, info.Columns[1].Expression.ExpressionType);
        }
コード例 #17
0
        public void ColumnDetail_2_With_Alias()
        {
            string sql  = @"Select userId, 1 as fid from [me]";
            var    info = SQLParser.ParseSQL(sql);

            Assert.AreEqual("userId", info.Columns[0].Expression.ColumnName);
            Assert.AreEqual(ExpressionType.ColumnName, info.Columns[0].Expression.ExpressionType);

            Assert.AreEqual("1", info.Columns[1].Expression.ColumnName);
            Assert.AreEqual(ExpressionType.ColumnName, info.Columns[1].Expression.ExpressionType);

            Assert.AreEqual(true, info.Columns[1].HasAlias);
            Assert.AreEqual("fid", info.Columns[1].Alias);
        }
コード例 #18
0
        public void ColumnDetail_10()
        {
            string sql  = @"Select userId, 1 as fid, userId2, userId3, userId4, userId5, userId6, userId7, userId8, userId9 from [me]";
            var    info = SQLParser.ParseSQL(sql);

            Assert.AreEqual("userId", info.Columns[0].Expression.ColumnName);
            Assert.AreEqual(ExpressionType.ColumnName, info.Columns[0].Expression.ExpressionType);

            Assert.AreEqual("1", info.Columns[1].Expression.ColumnName);
            Assert.AreEqual(ExpressionType.ColumnName, info.Columns[1].Expression.ExpressionType);

            Assert.AreEqual(true, info.Columns[1].HasAlias);
            Assert.AreEqual("fid", info.Columns[1].Alias);

            Assert.AreEqual("userId9", info.Columns.Last().Expression.ColumnName);

            Assert.AreEqual(10, info.Columns.Count);
        }
コード例 #19
0
 public void OrderByNotExists()
 {
     string sql  = @"select userId from [me] order by";
     var    info = SQLParser.ParseSQL(sql);
 }
コード例 #20
0
 public void WhereClause_0()
 {
     string sql  = @"select userId from me where";
     var    info = SQLParser.ParseSQL(sql);
 }
コード例 #21
0
 public void TableName_DoesNot_Equal_To_ME4()
 {
     string sql  = @"select userId from";
     var    info = SQLParser.ParseSQL(sql);
 }
コード例 #22
0
 public void ColumnCount_0()
 {
     string sql  = @"select FROM asdfa";
     var    info = SQLParser.ParseSQL(sql);
 }