QueryTransformer NullReferenceException while filtering
Hello,
I am working with c# and with AQB version 3.2.1.1033 and i just want to transform a provided sql by adding a filter. But when I add the filter, i am getting a NullReferenceException:
at ActiveQueryBuilder.Core.PrepareAndFixupVisitor.(AstNodeBase )
at ActiveQueryBuilder.Core.PrepareAndFixupVisitor.(AstNodeBase )
at ActiveQueryBuilder.Core.PrepareAndFixupVisitor.FixupInContext(AstNodeBase rootNode, IList`1 cteItems, IList`1 fromItems)
at ActiveQueryBuilder.Core.AstNodeBase.PrepareAndFixupRecursive(IList`1 cteList, IList`1 fromSourcesList)
at ActiveQueryBuilder.Core.QueryTransformer.QueryTransformer.(QueryRoot , Boolean )
at ActiveQueryBuilder.Core.QueryTransformer.QueryTransformer.()
at ActiveQueryBuilder.Core.QueryTransformer.QueryTransformer.get_ResultAST()
at ActiveQueryBuilder.Core.QueryTransformer.QueryTransformer.get_SQL()
My source code :
ActiveQueryBuilder.Core.SQLQuery query = new ActiveQueryBuilder.Core.SQLQuery();
SQLContext ctx = new SQLContext();
ctx.SyntaxProvider = new MSSQLSyntaxProvider();
query.SQLContext = ctx;
query.SQL = "SELECT ID, NAME FROM PARAMETER";
QueryTransformer t = new QueryTransformer();
t.QueryProvider = query;
t.AlwaysWrapInSubQuery = false;
t.OrderBy(t.Columns[0], false);
t.Where("NAME LIKE %A%");
string sql = t.SQL;
Am I doing something wrong or is it a bug? This excption is only thrown when i use the filtering. Just adding an order command works without problems.
Best regards,
Christian Sack
Hello Christian,
thank you for detailed bug report.
You should quote %A% into single quotes:
t.Where("NAME LIKE '%A%'");
Anyway, I'll add the check to verify the string given to Where is valid SQL expression.