Menu

#444 MySQL syntax error with UTF8 chars in process rule

closed
None
fixed
Prototype Generator
low
bug
2015-03-17
2014-11-30
Rieks
No

Consider the following script:

CONTEXT Ticket444 IN DUTCH

PROCESS "Ticket444"

nhIsDashboard :: Normenhiërarchie * Normenhiërarchie [PROP]
ouDashboardNH :: OrgUnit * Normenhiërarchie [UNI]
bfDashboardNH :: Bedrijfsfunctie * Normenhiërarchie [UNI]

ROLE Developer MAINTAINS "Regeltje"
RULE "Regeltje": I /\ (bfDashboardNH~;bfDashboardNH \/ ouDashboardNH~;ouDashboardNH) |- nhIsDashboard

ENDPROCESS

ENDCONTEXT

When the prototype is running and the rule evaluates, there is a (quite complex) syntax error, as shown below. I have identified 2 ways that will let this error go away:
1) do not use the UTF character 'ë' in Normenhiërarchie, but rather use 'old school' characters. This suggests that the UTF characters are not handled correctly everywhere.
2) turn the process rule into an invariant (comment out the line starting with 'ROLE Developer'. This suggests that the code to generate MySQL for invariants differs from the code to generate MySQL for process rules, which seems a bit odd.

Here is the error message - the relevant stuff is at the end:

Error in Database.php: While evaluating rule 'Regeltje': Error 1064 in query "/ case: EUni (l,r) (I[Normenhiërarchie] /\ bfDashboardNH~;bfDashboardNH /\ -nhIsDashboard) \/ (I[Normenhiërarchie] /\ ouDashboardNH~;ouDashboardNH /\ -nhIsDashboard) ([Normenhiërarchie*Normenhiërarchie]) / (/ case: (EIsc lst\'@(::_)) I[Normenhiërarchie] /\ bfDashboardNH~;bfDashboardNH /\ -nhIsDashboard ([Normenhiërarchie*Normenhiërarchie]) / SELECT DISTINCT isect0.SrcNormenhiërarchie AS src, isect0.TgtNormenhiërarchie AS tgt FROM ( / case: (ECps es), with two or more elements in es. bfDashboardNH~;bfDashboardNH / SELECT DISTINCT ECps0.tgt_bfDashboardNH AS SrcNormenhiërarchie, ECps1.tgt_bfDashboardNH AS TgtNormenhiërarchie FROM ( SELECT Bedrijfsfunctie, tgt_bfDashboardNH FROM Bedrijfsfunctie WHERE Bedrijfsfunctie IS NOT NULL AND tgt_bfDashboardNH IS NOT NULL) AS ECps0, ( SELECT Bedrijfsfunctie, tgt_bfDashboardNH FROM Bedrijfsfunctie WHERE Bedrijfsfunctie IS NOT NULL AND tgt_bfDashboardNH IS NOT NULL) AS ECps1 WHERE ECps0.Bedrijfsfunctie=ECps1.Bedrijfsfunctie AND ECps0.tgt_bfDashboardNH IS NOT NULL AND ECps1.tgt_bfDashboardNH IS NOT NULL ) AS isect0, Normenhiërarchie AS isect1 WHERE isect0.SrcNormenhiërarchie = isect0.TgtNormenhiërarchie AND NOT EXISTS (SELECT * FROM ( SELECT Normenhiërarchie, tgt_nhIsDashboard FROM Normenhiërarchie WHERE Normenhiërarchie IS NOT NULL AND tgt_nhIsDashboard IS NOT NULL) AS cp WHERE isect0.SrcNormenhiërarchie=cp.Normenhiërarchie AND isect0.TgtNormenhiërarchie=cp.tgt_nhIsDashboard) AND isect0.SrcNormenhiërarchie IS NOT NULL AND isect0.TgtNormenhiërarchie IS NOT NULL ) UNION (/ case: (EIsc lst\'@(::_)) I[Normenhiërarchie] /\ ouDashboardNH~;ouDashboardNH /\ -nhIsDashboard ([Normenhiërarchie*Normenhiërarchie]) / SELECT DISTINCT isect0.SrcNormenhiërarchie AS src, isect0.TgtNormenhiërarchie AS tgt FROM ( / case: (ECps es), with two or more elements in es. ouDashboardNH~;ouDashboardNH / SELECT DISTINCT ECps0.tgt_ouDashboardNH AS SrcNormenhiërarchie, ECps1.tgt_ouDashboardNH AS TgtNormenhiërarchie FROM ( SELECT OrgUnit, tgt_ouDashboardNH FROM OrgUnit WHERE OrgUnit IS NOT NULL AND tgt_ouDashboardNH IS NOT NULL) AS ECps0, ( SELECT OrgUnit, tgt_ouDashboardNH FROM OrgUnit WHERE OrgUnit IS NOT NULL AND tgt_ouDashboardNH IS NOT NULL) AS ECps1 WHERE ECps0.OrgUnit=ECps1.OrgUnit AND ECps0.tgt_ouDashboardNH IS NOT NULL AND ECps1.tgt_ouDashboardNH IS NOT NULL ) AS isect0, Normenhiërarchie AS isect1 WHERE isect0.SrcNormenhiërarchie = isect0.TgtNormenhiërarchie AND NOT EXISTS (SELECT * FROM ( SELECT Normenhiërarchie, tgt_nhIsDashboard FROM Normenhiërarchie WHERE Normenhiërarchie IS NOT NULL AND tgt_nhIsDashboard IS NOT NULL) AS cp WHERE isect0.SrcNormenhiërarchie=cp.Normenhiërarchie AND isect0.TgtNormenhiërarchie=cp.tgt_nhIsDashboard) AND isect0.SrcNormenhiërarchie IS NOT NULL AND isect0.TgtNormenhiërarchie IS NOT NULL )": You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '�rarchie AND isect0.TgtNormenhiërarchie=cp.tgt_nhIsDashboard) AND isect0' at line 21

The point here is that somehow �rarchie ends up in the query where it should not.

I have also observed that this error does NOT occur when the rule is turned into an invariant

Discussion

  • Han Joosten

    Han Joosten - 2015-03-17
    • assigned_to: Han Joosten
    • Resolution: <not fixed=""> --> fixed
     
  • Han Joosten

    Han Joosten - 2015-03-17
    • status: new --> closed