[DBAL-522] BC break : executeQuery with an array containing null value(s). Created: 20/May/13  Updated: 15/Sep/14  Resolved: 21/May/13

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: 2.3.4
Fix Version/s: 2.4, 2.3.5

Type: Bug Priority: Blocker
Reporter: lemeunier Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: dbal
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!



 Comments   
Comment by Marco Pivetta [ 20/May/13 ]

I suggested a hotfix at https://github.com/doctrine/dbal/pull/322

Comment by lemeunier [ 21/May/13 ]

Thanks for the hotfix.





[DBAL-508] MySqlSchemaManager accessing undefined index tableColumn[comment] Created: 30/Apr/13  Updated: 09/May/13  Resolved: 09/May/13

Status: Resolved
Project: Doctrine DBAL
Component/s: Schema Managers
Affects Version/s: 2.3.3
Fix Version/s: 2.4

Type: Bug Priority: Trivial
Reporter: Martin Kuckert Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

Linux 3.2.0-24-generic-pae #39-Ubuntu,
mysql Ver 14.14 Distrib 5.5.31, for debian-linux-gnu (i686) using readline 6.2



 Description   

in the method Doctrine\DBAL\Schema\MySqlSchemaManager::_getPortableTableColumnDefinition the index "comment" in the array $tableColumn is accessed without ensuring that this index is set. This leads to an Undefined index: comment warning in E_ALL-environments.

This method is triggered e.g. by the Doctrine\ORM\Tools\SchemaTool getUpdateSchemaSql method.



 Comments   
Comment by Benjamin Eberlei [ 01/May/13 ]

Can't really explain this, the key has to be existant. This is only called with information from MysqlPlatform#getListTableColumnsSQL().

Comment by Martin Kuckert [ 02/May/13 ]

I've just found the issue. The main problem is the usage of 'DESCRIBE ' . $table; in the getListTableColumnsSQL, if there's no $database set. describe does not return the comment column, but 'show full columns from ' . $table; does.
At the basis of the missing $database value was my own DBAL\Driver implementation not properly returning the currently connected database. So $database was NULL and the alternate code path was executed, so resulting in no comment-property.

Seems like an uncovered code path instead of a bug in a real environment.

Comment by Benjamin Eberlei [ 09/May/13 ]

Special case fixed for 2.4





[DBAL-394] Unsigned integers are not respected by the schema tool for assocations Created: 30/Nov/12  Updated: 02/Jan/14  Resolved: 01/May/13

Status: Resolved
Project: Doctrine DBAL
Component/s: Schema Managers
Affects Version/s: 2.3
Fix Version/s: 2.4

Type: Bug Priority: Minor
Reporter: Jonathan Ingram Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 1
Labels: None

Issue Links:
Reference
is referenced by DDC-2661 Options not respected for ID Fields i... Resolved

 Description   

Before commenting, I've done so much debugging and searching into this issue and if I missed something major, I apologise.

From what I understand, the ORM doesn't care about unsigned. That's fair enough. That leaves it to DBAL to handle it.

However, it's not possible to successfully use something like the following table without having the schema manager complain.

CREATE TABLE `account` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '(DC2Type:unsigned_integer)',
  `user_id` int(10) unsigned DEFAULT NULL COMMENT '(DC2Type:unsigned_integer)',
  PRIMARY KEY (`id`),
  KEY `IDX_7D3656A461220EA6` (`user_id`)
) ENGINE=InnoDB

In that code, I'm using a custom type "unsigned_integer" that extends the DBAL integer type with this:

    public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
    {
        $fieldDeclaration['unsigned'] = true;

        return $platform->getIntegerTypeDeclarationSQL($fieldDeclaration);
    }

The reason for this is because the ORM won't map unsigned ints for me. Combined with this is an event listener for the class metadata. Something like this:

    /**
     * Maps additional metadata.
     *
     * Specifically, if there exist an unsigned integer field, attach the
     * "unsigned" option to it. This is required because the Doctrine ORM does
     * not do this and we are using "UNSIGNED INT"s in our MySQL columns.
     * Without this. the Doctrine Schema Tool will complain about column
     * differences.
     *
     * Note: there is no performance impact in doing this because the class
     * metadata should be cached after the first request.
     *
     * @param LoadClassMetadataEventArgs $eventArgs
     */
    public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
    {
        foreach ($eventArgs->getClassMetadata()->fieldMappings as &$mapping) {
            if (isset($mapping['type']) && UnsignedIntegerType::UNSIGNED_INTEGER === $mapping['type']) {
                if (!isset($mapping['options'])) {
                    $mapping['options'] = array();
                }

                $mapping['options']['unsigned'] = true;
            }
        }
    }

Now, in the example table above, the schema tool will honour the "id" column, however it won't honour the association join column no matter what I do. My attempts include adding an event listener for class meta data as above (basically tricking the ORM) and also adding an event listener for the schema events.

The other day on GitHub there was a commit (https://github.com/doctrine/doctrine2/commit/a27be2fab61b1cfde4d2ecbc729a4a68816fca76) to help with this, but it's still not all working.

Also, comments and issues on the Jira tracker have said how there's legacy code related to "unsigned" and "default", but I can't tell what's legacy and what's allowed, especially when there's a commit like that one above.

By the way, I have found that the simple unsigned field mapping works. E.g.:

    fields:
        counter:
            type: integer
            column: counter
            options:
                unsigned: true

If it helps at all, here's the YAML mapping file for the above table/entity:

Account:
    type: entity
    table: account
    id:
        id:
            type: unsigned_integer
            generator:
                strategy: AUTO
    manyToOne:
        creator:
            targetEntity: User
            joinColumn:
                name: user_id
                referencedColumnName: id # Note: user table id is also unsigned_integer

Is it possible to 1) fix this or 2) let me know if I'm just doing something wrong?

Note: as I said above, I know that Doctrine DBAL and ORM does not care so much for unsigned ints because of portability, etc. but it seems that because of that commit above (24 days ago), there's a half-implememented/legacy solution going on here.

Cheers,
Jon



 Comments   
Comment by Benjamin Eberlei [ 01/May/13 ]

This was fixed in 657a54da

Comment by Gaetan Rousseau [ 03/May/13 ]

This was not fixed. We can use the option "unsigned" for the fields but not the id.

If someone has a solution or if you can fix this, that would be really cool !

Comment by Gaetan Rousseau [ 03/May/13 ]

After some research with a co-worker we've found a solution to our little problem.

To fix this you just have to add these lines in the YamlDriver (Doctrine/ORM/Mapping/Driver/YamlDriver.php) in the function "loadMetadataForClass", line 265 in the 2.3.3 version of Doctrine ORM :

if (isset($idElement['options'])) {
   $mapping['options'] = $idElement['options'];
}

Just before the :

$metadata->mapField($mapping);

And that an example of schema :

Entities\Test:
  type: entity
  table: Test
  id:
    id:
      type: integer
      options:
        unsigned: true
      generator:
        strategy: AUTO
  fields:
    testField:
      type: smallint
      options:
        unsigned: true

With this, the id can be unsigned without using special type of column, and yes just with this little if
It has been tested in more complexes schemas and all is going well.

In fact, maybe it could be interesting to use the function "columnToArray" like it's used for the other fields.
In the two cases you must care about what you put in your "options" section.

Comment by Benjamin Eberlei [ 08/Sep/13 ]

Gaetan Rousseau i just now found this additional bug report here in the comments. I opened DDC-2661 for it and fixed it. Will be included in 2.4.1. Please don't report additional bugs in already closed issues in the future, because they can easily get lost.

Comment by Doctrine Bot [ 02/Jan/14 ]

A related Github Pull-Request [GH-816] was closed:
https://github.com/doctrine/doctrine2/pull/816





[DBAL-318] getSQLDeclaration Created: 12/Aug/12  Updated: 21/Nov/13  Resolved: 21/Nov/13

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: 2.2.2
Fix Version/s: 2.4

Type: Improvement Priority: Minor
Reporter: Till Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Types/Type.php#L119-L125

Should define a @return type. Otherwise you have to step through other types to figure this out.



 Comments   
Comment by Christophe Coevoet [ 19/Aug/12 ]

Already fixed in master





[DBAL-200] Connection::update() Created: 10/Jan/12  Updated: 21/Nov/13  Resolved: 21/Nov/13

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: 2.3.2
Fix Version/s: 2.4

Type: Documentation Priority: Trivial
Reporter: Jonas Liljestrand Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: documentation


 Description   

missing @param array $data in docblock



 Comments   
Comment by Padraig O'Sullivan [ 11/Dec/12 ]

Resolved by pull request 236:

https://github.com/doctrine/dbal/pull/236





Generated at Fri Sep 04 21:24:09 EDT 2015 using JIRA 6.4.10#64025-sha1:5b8b74079161cd76a20ab66dda52747ee6701bd6.