Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-522

BC break : executeQuery with an array containing null value(s).

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.3.4
    • Fix Version/s: 2.4
    • Component/s: None
    • Labels:
    • Environment:
      Mac OSX 10.8.3, Mysql 5.5.28, PHP5.4

      Description

      Hello, i have got an error with doctrine 2.3.4 when i try to run the following code :

       
          $conn->executeQuery(
              'INSERT INTO FOO (foo, bar) values (:foo, :bar)', 
               array('foo' => 1, 'bar' => null)
           );
      

      Error : Value for :bar not found in params array. Params array key should be "bar"

      This code worked with doctrine 2.3.3.

      I think the error comes from the function 'extractParam' in SQLParserUtils.php (DBAL)

      line 215 : if (isset($paramsOrTypes[$paramName]))
      

      The key exists even if the value is null.
      So it should be:

        if (array_key_exists($paramName, $paramsOrTypes)) 
      

      I am not enough confident to try a PR.
      Thanks in advance!

        Activity

        Hide
        lemeunier added a comment -

        Thanks for the hotfix.

        Show
        lemeunier added a comment - Thanks for the hotfix.
        Hide
        Marco Pivetta added a comment -
        Show
        Marco Pivetta added a comment - I suggested a hotfix at https://github.com/doctrine/dbal/pull/322

          People

          • Assignee:
            Marco Pivetta
            Reporter:
            lemeunier
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: