Skip to content

Loading…

DBAL-558: Incorrect extracting of placeholder positions from statement #1767

Closed
doctrinebot opened this Issue · 3 comments

2 participants

@doctrinebot

Jira issue originally created by user yshyshkin:

I'm trying to execute statement:

SELECT Count(*)
FROM   (SELECT DISTINCT o6_.id                          AS id0,
                        COALESCE(t3*.content, o2*.name) AS name1,
                        o7*.postal_code                 AS postal*code2,
                        CASE
                          WHEN o7*.state_text IS NOT NULL THEN o7_.state*text
                          ELSE COALESCE(t5*.content, o4*.name)
                        END
                        || ''                           AS sclr3,
                        CASE
                          WHEN o6_.id IN ( ? )
                               AND o6_.id NOT IN ( ? ) THEN true
                          ELSE false
                        END                             AS sclr4
        FROM   orocrm*contact o6*
               LEFT JOIN orocrm*contact_value o8*
                      ON o6*.id = o8_.entity*id
               LEFT JOIN oro*flexibleentity_attribute o0*
                      ON o8*.attribute_id = o0*.id
               LEFT JOIN orocrm*contact_value_option o10*
                      ON o8*.id = o10_.value*id
               LEFT JOIN oro*flexibleentity_attribute_option o9*
                      ON o9*.id = o10_.option*id
               LEFT JOIN oro*flexibleentity_attribute_option_value o11*
                      ON o9*.id = o11_.option*id
               LEFT JOIN orocrm*contact_address o7*
                      ON o6*.id = o7_.owner*id
                         AND ( o7*.is*primary = true )
               LEFT JOIN orocrm*contact_to_contact_group o13*
                      ON o6*.id = o13_.contact*id
               LEFT JOIN orocrm*contact_group o12*
                      ON o12*.id = o13_.contact_group*id
               LEFT JOIN oro*dictionary_country o2*
                      ON o7*.country_code = o2_.iso2*code
               LEFT JOIN oro*dictionary_region o4*
                      ON o7*.region_code = o4_.combined*code
               LEFT JOIN oro*flexibleentity_attribute_translation t1*
                      ON t1_.locale = 'ru'
                         AND t1_.field = 'label'
                         AND t1*.object*class =
                             'Oro\Bundle\FlexibleEntityBundle\Entity\Attribute'
                         AND t1*.foreign_key = o0*.id
               LEFT JOIN oro*dictionary_country_translation t3*
                      ON t3_.locale = 'ru'
                         AND t3_.field = 'name'
                         AND t3*.object*class =
                             'Oro\Bundle\AddressBundle\Entity\Country'
                         AND t3*.foreign_key = o2_.iso2*code
               LEFT JOIN oro*dictionary_region_translation t5*
                      ON t5_.locale = 'ru'
                         AND t5_.field = 'name'
                         AND t5*.object*class =
                             'Oro\Bundle\AddressBundle\Entity\Region'
                         AND t5*.foreign_key = o4_.combined*code
        WHERE  ( CASE
                   WHEN o6_.id IN ( ? )
                        AND o6_.id NOT IN ( ? ) THEN true
                   ELSE false
                 END <> false )
               AND CASE
                     WHEN o7*.state_text IS NOT NULL THEN o7_.state*text
                     ELSE COALESCE(t5*.content, o4*.name)
                   END
                   || '' LIKE ?) AS e  

When this statement passes to Doctrine\DBAL\SQLParserUtils::getPlaceholderPositions, it extracts only three placeholder positions instead of five.

As a result, Doctrine can't map parameters and types properly, so SQL request fails.

It looks like this unexpected behavior appeared because of regular expression in SQLParserUtils::getUnquotedStatementFragments, that incorrectly extracts unquoted statements.

@doctrinebot

Comment created by @deeky666:

Patch supplied in PR: #480

@doctrinebot

Comment created by @doctrinebot:

A related Github Pull-Request [GH-480] was closed:
#480

@doctrinebot

Issue was closed with resolution "Fixed"

@doctrinebot doctrinebot added the Bug label
@deeky666 deeky666 was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.4.2 milestone
@doctrinebot doctrinebot closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.