SQL Error when Creating Campaign with Condition

Another day, another problem… Could well be user error on my part again.



I have a campaign form with a select field consisting of 3 items (product A, product B, product C)



I want to be able to tag the user with the tags ProductA, ProductB, ProductC respectively depending on what they submit (I also want to email them different emails depending on what they select but I haven’t go that far yet).



I figured I could create a campaign for this:


  • Lead source - is my form
  • Condition - Form field value, limited to my form, using the selection field and with an equals to product A
  • Action - of Adding a Tag ‘ProductA’



    I could then have more conditions and tags for product B, C, etc…



    Unfortunately as soon as I create and publish this campaign I see the following error in the CampaignUpdate process:



    [DoctrineDBALDBALException]

    An exception occurred while executing ‘SELECT max(list_leads.lead_id) as ma

    x_id, count(distinct(list_leads.lead_id)) as lead_count FROM lead_lists_lea

    ds list_leads WHERE (list_leads.manually_removed = ?) AND (list_leads.leadl

    ist_id IN ()) AND (list_leads.date_added <= ‘2016-01-13 12:29:11’) AND (NOT

    EXISTS (SELECT null FROM campaign_leads campaign_leads WHERE (campaign_lea

    ds.lead_id = list_leads.lead_id) AND (campaign_leads.manually_removed = ?)

    AND (campaign_leads.campaign_id = 6)))’ with params [0, 0]:

    SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error i

    n your SQL syntax; check the manual that corresponds to your MySQL server v

    ersion for the right syntax to use near ‘)) AND (list_leads.date_added <= ’

    2016-01-13 12:29:11’) AND (NOT EXISTS (SELECT ’ at line 1



    [PDOException]

    SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error i

    n your SQL syntax; check the manual that corresponds to your MySQL server v

    ersion for the right syntax to use near ‘)) AND (list_leads.date_added <= ’

    2016-01-13 12:29:11’) AND (NOT EXISTS (SELECT ’ at line 1



    Any thoughts? Do I need to construct my Campaign differently? Is there an alternative way to achieve this?

Another day, another problem… Could well be user error on my part again.

I have a campaign form with a select field consisting of 3 items (product A, product B, product C)

I want to be able to tag the user with the tags ProductA, ProductB, ProductC respectively depending on what they submit (I also want to email them different emails depending on what they select but I haven’t go that far yet).

I figured I could create a campaign for this:

  • Lead source - is my form
  • Condition - Form field value, limited to my form, using the selection field and with an equals to product A
  • Action - of Adding a Tag ‘ProductA’

I could then have more conditions and tags for product B, C, etc…

Unfortunately as soon as I create and publish this campaign I see the following error in the CampaignUpdate process:

[DoctrineDBALDBALException]
An exception occurred while executing ‘SELECT max(list_leads.lead_id) as ma
x_id, count(distinct(list_leads.lead_id)) as lead_count FROM lead_lists_lea
ds list_leads WHERE (list_leads.manually_removed = ?) AND (list_leads.leadl
ist_id IN ()) AND (list_leads.date_added <= ‘2016-01-13 12:29:11’) AND (NOT
EXISTS (SELECT null FROM campaign_leads campaign_leads WHERE (campaign_lea
ds.lead_id = list_leads.lead_id) AND (campaign_leads.manually_removed = ?)
AND (campaign_leads.campaign_id = 6)))’ with params [0, 0]:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error i
n your SQL syntax; check the manual that corresponds to your MySQL server v
ersion for the right syntax to use near ‘)) AND (list_leads.date_added <= ’
2016-01-13 12:29:11’) AND (NOT EXISTS (SELECT ’ at line 1

[PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error i
n your SQL syntax; check the manual that corresponds to your MySQL server v
ersion for the right syntax to use near ‘)) AND (list_leads.date_added <= ’
2016-01-13 12:29:11’) AND (NOT EXISTS (SELECT ’ at line 1

Any thoughts? Do I need to construct my Campaign differently? Is there an alternative way to achieve this?

Seems a lot like the errors from this PR:

https://github.com/mautic/mautic/pull/1286

So this is a known bug, the fix is above if someone wants to apply the code fix now and it will be fixed in the next release 1.2.4 which is planned for this week if we manage to test 2 times each pull request for this release:

https://github.com/mautic/mautic/pulls?q=is%3Aopen+is%3Apr+milestone%3A1.2.4

Any help with testing appreciated.

Ah ok great… that does ring a bell now you mention it.