question-mark

Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Querybuilder has a problem with strings which contain `$rate` and `From` in field names

See original GitHub issue

Issue Description

In Grafana I have a template variable $UserName and I put following statement into the Querybuilder

$rate(countIf(StatusCode='200') AS Success, countIf(StatusCode!='200') AS Fail) FROM $table
WHERE Direction in ($UserDirection)
$conditionalTest(AND (FromUser like '%$UserName%' or ToUser like '%$UserName%'),$UserName)

This produces following wrong query: SELECT t, Success/runningDifference(t/1000) SuccessRate, Fail/runningDifference(t/1000) FailRate FROM ( SELECT (intDiv(toUInt32(CallTime), 1) * 1) * 1000 AS t, countIf(StatusCode = '200') AS Success, countIf(StatusCode != '200') AS Fail FromUser like '%bob%' or ToUser like '%bob%') WHERE CallTime BETWEEN toDateTime(1595870047) AND toDateTime(1595870349) GROUP BY t ORDER BY t)

If I change the conditionalTest from: $conditionalTest(AND (FromUser like '%$UserName%' or ToUser like '%$UserName%'),$UserName) To something like: $conditionalTest(AND (ToUser like '%$UserName%' or ToUser like '%$UserName%'),$UserName)

Querybuilder produces the right query: SELECT t, Success/runningDifference(t/1000) SuccessRate, Fail/runningDifference(t/1000) FailRate FROM ( SELECT (intDiv(toUInt32(CallTime), 1) * 1) * 1000 AS t, countIf(StatusCode = '200') AS Success, countIf(StatusCode != '200') AS Fail FROM cdrmon.call_log WHERE CallTime BETWEEN toDateTime(1595870018) AND toDateTime(1595870320) AND Direction in (['incoming']) AND (ToUser like '%bob%' or ToUser like '%bob%') GROUP BY t ORDER BY t)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
Slachcommented, Jul 28, 2020

@negbie thanks a lot for reporting, i will fix it ASAP

0reactions
negbiecommented, Jul 28, 2020

@Slach works, thank you very much!

Read more comments on GitHub >

github_iconTop Results From Across the Web

php - Doctrine query builder - where IN with non string column ...
@cerad I am not using params for the column names, I do have a predefined list of them like in the example. It's...
Read more >
ArcMap definition query for a string contained in a longer ...
The initial query was built using Query Builder in 10.2 and it built the query without quotation marks around the field name.
Read more >
How To: Work with NULL values in a table - Esri Support
Select Query from the Table menu. 2. Type the following into the expression box on the Query Builder dialog box. For a string...
Read more >
jQuery QueryBuilder
The plugin's function acts as a proxy to access all underlying methods. $('#builder'). queryBuilder('methodName', param_1, param_2); You can also execute ...
Read more >
Term query does not support array of values - Opster
Term query returns documents that contain an exact term in a provided field. You cannot use term query to search an array of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found