[Bug 1600202] [NEW] program indicator d2condition bug

Public bug reported:

There is a bug in d2:condition which messes up the quotes in the SQL
that is generated based on the expression:

E.g. this simple d2:condition():
d2:condition(#{wmSb9TmevMn.FlzVuMSdC2F} == 'MONTHS', true, false)

Is translated into this SQL:
select count(distinct psi) as value,"yearly" from analytics_event_2016_jo4aktbheqq where Yearly in ('2016') and (uidlevel1 = 'M4nRM5O3mH8' ) and (case when (FlzVuMSdC2F" = 'MONTHS) then true else false end) group by "yearly" limit 200001

Which
1) is missing a " before FlzVuMSdC2F, AND
2) has stripped off the ‘ after MONTHS

** Affects: dhis2
     Importance: Undecided
         Status: New

···

--
You received this bug notification because you are a member of DHIS 2
developers, which is subscribed to DHIS.
https://bugs.launchpad.net/bugs/1600202

Title:
  program indicator d2condition bug

Status in DHIS:
  New

Bug description:
  There is a bug in d2:condition which messes up the quotes in the SQL
  that is generated based on the expression:

  E.g. this simple d2:condition():
  d2:condition(#{wmSb9TmevMn.FlzVuMSdC2F} == 'MONTHS', true, false)

  Is translated into this SQL:
  select count(distinct psi) as value,"yearly" from analytics_event_2016_jo4aktbheqq where Yearly in ('2016') and (uidlevel1 = 'M4nRM5O3mH8' ) and (case when (FlzVuMSdC2F" = 'MONTHS) then true else false end) group by "yearly" limit 200001

  Which
  1) is missing a " before FlzVuMSdC2F, AND
  2) has stripped off the ‘ after MONTHS

To manage notifications about this bug go to:
https://bugs.launchpad.net/dhis2/+bug/1600202/+subscriptions

I encountered this and was able to resolve by putting double quotes outside the expression as in:

d2:condition("#{wmSb9TmevMn.FlzVuMSdC2F} == ‘MONTHS’ ", true, false)