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); }
public void ColumnCount_1() { string sql = @"select userId from [me]"; var info = SQLParser.ParseSQL(sql); Assert.AreEqual(1, info.Columns.Count); }
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); }
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); }
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); }
public void TableName_Equal_To_mE() { string sql = @"select userId from mE"; var info = SQLParser.ParseSQL(sql); Assert.AreEqual("mE", info.TableDescriptor.TableName); }
public void PredictWordNotExists() { string sql = @"select userId from [me]"; var info = SQLParser.ParseSQL(sql); Assert.AreEqual(false, info.Column_PredictExists); }
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); }
public void ColumnOnly() { string sql = @"select 1"; var info = SQLParser.ParseSQL(sql); Assert.AreEqual(1, info.Columns.Count); Assert.AreEqual(null, info.TableDescriptor); }
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); }
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); }
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); }
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); }
static void Main(string[] args) { string sql = @"select * from [me]"; var info = SQLParser.ParseSQL(sql); var generator = new DefaultSqlGenerator(); Console.WriteLine(generator.Generate(info)); }
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); }
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); }
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); }
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); }
public void OrderByNotExists() { string sql = @"select userId from [me] order by"; var info = SQLParser.ParseSQL(sql); }
public void WhereClause_0() { string sql = @"select userId from me where"; var info = SQLParser.ParseSQL(sql); }
public void TableName_DoesNot_Equal_To_ME4() { string sql = @"select userId from"; var info = SQLParser.ParseSQL(sql); }
public void ColumnCount_0() { string sql = @"select FROM asdfa"; var info = SQLParser.ParseSQL(sql); }