[DBAL-207] RemoveNamespacedAssets: Foreign Key removing does not work correctly Created: 22/Jan/12  Updated: 22/Jan/12  Resolved: 22/Jan/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: 2.2-RC1/RC2
Fix Version/s: 2.2.0-RC3, 2.2
Security Level: All

Type: Bug Priority: Blocker
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Comments   
Comment by Benjamin Eberlei [ 22/Jan/12 ]

Fixed.





[DBAL-261] MasterSlaveConnection fails to load ConnectionEventArgs Created: 24/Apr/12  Updated: 05/May/12  Resolved: 05/May/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: 2.2.1, 2.2.2
Fix Version/s: 2.2.3
Security Level: All

Type: Bug Priority: Blocker
Reporter: Raymond Burgess Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

Incorrect class referenced at line 164 of Doctrine\DBAL\Connection\MasterSlaveConnection.php:

$eventArgs = new Event\ConnectionEventArgs($this);

Current namespace is Doctrine\DBAL\Connection so class loader fails when looking for Doctrine\DBAL\Connection\Event\ConnectionEventArgs

Work around is to add Doctrine\DBAL\Event\ConnectionEventArgs to use directive and change line to:

$eventArgs = new ConnectionEventArgs($this);






[DBAL-36] Database selection with DSN Created: 21/Jul/10  Updated: 08/Sep/10  Resolved: 08/Sep/10

Status: Resolved
Project: Doctrine DBAL
Component/s: Drivers
Affects Version/s: 2.0.0-BETA4
Fix Version/s: None

Type: Bug Priority: Blocker
Reporter: Bostjan Oblak Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None
Environment:

Windows, Sql Server 2008, Sql server drivers for PHP v2



 Description   

When construstring DSN in Doctrine\DBAL\Driver\PDOSqlsrv\Driver it should add selection of database in DSN.

So for example DSN will look like:

$dsn ="sqlsrv:Server=(local) ; Database = AdventureWorks "; 

As writen in chm manual which come with Sql server drivers for PHP v2



 Comments   
Comment by Bostjan Oblak [ 08/Sep/10 ]

I changed this Issue to Bug and give it priority of blocker, since with final relase of Sql Server Driver 2 for PHP it's not working correctly.

Solution can be found on my blog: http://bostjan.muha.cc/2010/08/doctrine-2-mssql/

Comment by Benjamin Eberlei [ 08/Sep/10 ]

This was fixed in Beta4, but will probably be changed again for the next testrelease because of DBAL-49.





[DBAL-35] PDO_Sqlsrv bug in _constructPdoDsn() Created: 21/Jul/10  Updated: 31/Aug/10  Resolved: 31/Aug/10

Status: Resolved
Project: Doctrine DBAL
Component/s: Drivers
Affects Version/s: 2.0.0-BETA2
Fix Version/s: 2.0.0-BETA4

Type: Bug Priority: Blocker
Reporter: Bostjan Oblak Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 1
Labels: None
Environment:

Windows 7, Zend Server CE, Sql Server driver for PHP v2



 Description   

When connection to mssql server with pdo_sqlsrv driver you get:

 
[PDOException]
SQLSTATE[IMSSP]: The DSN string ended unexpectedly.

Sample $connectionOptions:

$connectionOptions = array(
    'dbname' => 'AdventureWorks',
    'user' => 'sa',
    'password' => 'sa_password',
    'host' => 'local',
    'driver' => 'pdo_sqlsrv'
);

Error is in Doctrine\DBAL\Driver\PDOSqlsrv\Driver in function _constructPdoDsn(array $params).
On line 53 dsn starts with

$dsn = 'sqlsrv:(';

instead of

$dsn = 'sqlsrv:server=(';

as written in offical Microsoft help which come with SQL Server Driver For PHP v2.



 Comments   
Comment by Benjamin Eberlei [ 21/Jul/10 ]

@Juozas can you evaluate this and possibly apply a fix?

Comment by Benjamin Eberlei [ 31/Aug/10 ]

Fixed





[DBAL-496] "Undefined index" errors when using prepared statements Created: 16/Apr/13  Updated: 21/Apr/13  Resolved: 20/Apr/13

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Blocker
Reporter: Lukas Kahwe Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

Since a few days we are seeing errors like this in the Jackalope Doctrine DBAL test suite when using prepared statements:
https://travis-ci.org/jackalope/jackalope-doctrine-dbal/jobs/6350278#L117



 Comments   
Comment by Marco Pivetta [ 16/Apr/13 ]

First failure I can see is at https://travis-ci.org/jackalope/jackalope-doctrine-dbal/jobs/6347501 - is there any other relevant failure before that one?

Comment by Marco Pivetta [ 16/Apr/13 ]

The notice is thrown in in

Doctrine\DBAL\SQLParserUtils::expandListParameters

Can be reproduced with parameters:

$query:

UPDATE phpcr_nodes SET sort_order = CASE CONCAT(
          namespace,
          (CASE namespace WHEN '' THEN '' ELSE ':' END),
          local_name
        ) WHEN :name0 THEN :order0 WHEN :name1 THEN :order1 WHEN :name2 THEN :order2 WHEN :name3 THEN :order3 WHEN :name4 THEN :order4 ELSE sort_order END WHERE parent = :absPath

$params:

array(
    ':absPath' => '/topic',
    ':name0' => 'page3',
    ':order0' => 0,
    ':name1' => 'page1',
    ':order1' => 1,
    ':name2' => 'page2',
    ':order2' => 2,
    ':name3' => 'page3',
    ':order3' => 3,
    ':name4' => 'page4',
    ':order4' => 4,
)

$types:

array()
Comment by David Buchmann [ 17/Apr/13 ]

are we doing something wrong or is this a regression in dbal?

should we for now force an older version of doctrine-dbal? (this would be annyoing however, as we would run into version conflicts with doctrine-commons then i think)

Comment by Daniel Leech [ 17/Apr/13 ]

Seems this is caused by: https://github.com/doctrine/dbal/commit/64647f9e55749147b738cdba9378fa0401fadcbf

Comment by Fabio B. Silva [ 18/Apr/13 ]

I think the problem here is the ':' on the parameter key, which i'm not sure if are suported for DBAL.
Before #DBAL-488 it does not apply 'SQLParserUtils::expandListParameters' for parameters without types.

Comment by Benjamin Eberlei [ 20/Apr/13 ]

Reverted in master and 2.3

Comment by Fabio B. Silva [ 20/Apr/13 ]

Benjamin, Not sure if we should consider this one related to #DBAL-488.
It just show us another unsupported/unexpected behavior.

Actually, it will keep failing with any parameter key starting with ':' when types are given.

For instance :

$query:

SELECT * FROM foo WHERE bar = :bar

$params:

array(':bar'=>'Some String')

$types:

array(':bar'=>\PDO::PARAM_STR)
Comment by Lars Strojny [ 21/Apr/13 ]

Here is a successor for the fix from PR 301, @Fabio, could you test that with your code base: https://github.com/doctrine/dbal/pull/309





[DBAL-513] downloading from github Created: 12/May/13  Updated: 12/May/13  Resolved: 12/May/13

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Blocker
Reporter: Maarten Bogaert Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

https://api.github.com/repos/doctrine/dbal/zipball/2.3.4:

500: Internal Server Error



 Comments   
Comment by Maarten Bogaert [ 12/May/13 ]

ok never mind, after a while the problem resolved itself and the zipball can be downloaded again





[DBAL-522] BC break : executeQuery with an array containing null value(s). Created: 20/May/13  Updated: 21/May/13  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-54] Incorrect sequence dropping in PostgreSQL Created: 21/Sep/10  Updated: 09/Oct/12  Resolved: 23/Sep/10

Status: Resolved
Project: Doctrine DBAL
Component/s: Platforms
Affects Version/s: 2.2.2
Fix Version/s: 2.0.0-RC1-RC3

Type: Bug Priority: Critical
Reporter: Tomasz Jędrzejewski Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

postgresql 8.4.3, Arch Linux 64-bit



 Description   

Currently, DBAL drops the PostgreSQL sequences using the query:

DROP SEQUENCE sequencename

While it is quite correct at the first look, it fails, if the sequence is actually used by a table. Because Doctrine 2 ORM tries to drop the sequences before the tables, it makes impossible to drop a database schema in PostgreSQL due to the following exception:


$ php53 doctrine.php orm:schema-tool:drop
Dropping database schema...
PDOException
SQLSTATE[2BP01]: Dependent objects still exist: 7 ERROR: cannot drop sequence admins_id_seq because other objects depend on it
DETAIL: default for table admins column id depends on sequence admins_id_seq
HINT: Use DROP ... CASCADE to drop the dependent objects too.
/.../Libs/Doctrine/DBAL/Connection.php
Line 570
Trace:
0. PDO::query on line 570
1. Doctrine\DBAL\Connection::executeQuery on line 484
2. Doctrine\ORM\Tools\SchemaTool::dropSchema on line 78
3. Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand::executeSchemaCommand on line 59
4. Doctrine\ORM\Tools\Console\Command\SchemaTool\AbstractCommand::execute on line 159
5. Symfony\Component\Console\Command\Command::run on line 205
6. Symfony\Component\Console\Application::doRun on line 117
7. Symfony\Component\Console\Application::run on line 7


A solution is simply to add the "CASCADE" keyword at the end of the query.

Although I encountered this problem on DBAL 2.0-beta4, I checked the most up-to-date code on Git, and the problem is still present there.



 Comments   
Comment by Benjamin Eberlei [ 21/Sep/10 ]

Would it help to drop sequences after tables? If then i would just move the code blocks.

Comment by Tomasz Jędrzejewski [ 21/Sep/10 ]

In this particular case - yes, it would help. But consider that different database engines may have different dependencies between schema elements and be more or less restrictive, so they may require different order of code blocks. I'd recommend to make a bit deeper investigation here in order not to cause potential problems with other database engines.

Comment by Benjamin Eberlei [ 23/Sep/10 ]

Fixed

Comment by Jon Wadsworth [ 20/Jun/12 ]

This issue is happening again with Doctrine 2.2.2 on Postgres 9.1.3. when trying to drio a database I get this message even with --full-database

> php doctrine.php orm:schema-tool:drop --force --full-database
Dropping database schema...

[PDOException]
SQLSTATE[2BP01]: Dependent objects still exist: 7 ERROR: cannot drop sequence policycategory_id_seq because other objects depend on it
DETAIL: default for table policycategory column id depends on sequence policycategory_id_seq
HINT: Use DROP ... CASCADE to drop the dependent objects too.

I would love to help diagnose, just let me know what you need and I will be more than happy to help.

Comment by Jon Wadsworth [ 09/Oct/12 ]

I forgot to update this for anyone else who might have had my problem. The issue was solved for me when I was reviewing some models. The project was originally intended for MySQL and Generated Value Strategy was not set to Auto. Upon changing it to auto, everything worked correctly.





[DBAL-52] Schema tools will alter tables with custom column definitions forever Created: 15/Sep/10  Updated: 15/Sep/10  Resolved: 15/Sep/10

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

Type: Bug Priority: Critical
Reporter: Lars Strojny Assignee: Benjamin Eberlei
Resolution: Duplicate Votes: 0
Labels: None
Environment:

MySQL 5.1, PDO MySQL



 Description   

When using custom column definition, schema tool will execute the same update statements over and over. It looks like schema tool can't find out yet, if the custom column definition has already been applied.
As MySQL does full table rebuilds quite often (sometimes for no or at least debatable reasons), this makes the schema tool for large migrations quite hard to use in a production system deployment scenario.



 Comments   
Comment by Benjamin Eberlei [ 15/Sep/10 ]

Yes this is a known issue, i plan to fix this with DDC-42, however it will take until 2.1 i guess. It annoys me too

Maybe we should also add a note to the manual, schema-tool incremental update is a development tool and should not be used on the production server.





[DBAL-44] nullable is not working for all datatypes Created: 30/Aug/10  Updated: 30/Aug/10  Resolved: 30/Aug/10

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: 2.0.0-BETA3

Type: Bug Priority: Critical
Reporter: Daniel Freudenberger Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None

Attachments: Text File nullable.patch    

 Description   

The nullable=true annotation is ignored from at least following Types:

  • SmallIntType
  • DecimalType
  • BooleanType (not sure if nullable makes sense here)


 Comments   
Comment by Roman S. Borschel [ 30/Aug/10 ]

This looks like it has been fixed for a while already. See:

http://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Types/SmallIntType.php
http://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Types/DecimalType.php
http://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Types/BooleanType.php

Comment by Daniel Freudenberger [ 30/Aug/10 ]

I'll take a look at the master next time before submitting a bug report. Anyway I think it would be better to not fix bugs without an existing ticket for the fixed bug

Comment by Daniel Freudenberger [ 30/Aug/10 ]

has already been fixed





[DBAL-129] Doctrine\ORM\Mapping\ClassMetadataInfo does not properly handle identifier quoting Created: 10/Jun/11  Updated: 17/Jun/11  Resolved: 15/Jun/11

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: 2.0.4
Fix Version/s: 2.0.6

Type: Bug Priority: Critical
Reporter: Patrick Schwisow Assignee: Juozas Kaziukenas
Resolution: Fixed Votes: 1
Labels: None


 Description   

Several methods in Doctrine\ORM\Mapping\ClassMetadataInfo assume that table names and field names may be quoted. In all places, logic assumes that the quote character will always be ` (backtick). There seems to be no way to properly quote table names with [] (square brackets) when working with SQL Server databases.



 Comments   
Comment by Benjamin Eberlei [ 11/Jun/11 ]

Just use `foo` as quotes, its just an abstract concept, doctrine will translate that to [foo] in MsSQL.

Comment by Patrick Schwisow [ 13/Jun/11 ]

I don't see how that would work. It appears that DBAL\Platforms\AbstractPlatform::quoteIdentifier assumes that the opening and closing quotes are the same. In the case of MS SQL, it appears to use the double quote, not square brackets.

Comment by Benjamin Eberlei [ 15/Jun/11 ]

Assigned to Juokaz

Comment by Benjamin Eberlei [ 15/Jun/11 ]

Fixed





[DBAL-114] MsSqlPlatform - getListTablesSQL() get's sysdiagrams table Created: 26/Apr/11  Updated: 29/Aug/11  Resolved: 29/Aug/11

Status: Resolved
Project: Doctrine DBAL
Component/s: Platforms
Affects Version/s: 2.0.4
Fix Version/s: 2.1.2, 2.2

Type: Bug Priority: Critical
Reporter: Bostjan Oblak Assignee: Juozas Kaziukenas
Resolution: Fixed Votes: 1
Labels: None
Environment:

Windows 7, PHP 5.3.5, MSSQL 2008



 Description   

getListTablesSQL() function in MsSqlPlatform.php list all tables in database.

If you have saved Database Diagrams it returns "sysdiagrams" table too.
This table have field "name" with type "sysname" which have no mapping.

If you run orm:validate-schema you get:
[Doctrine\DBAL\DBALException]
Unknown database type sysname requested, Doctrine\DBAL\Platforms\MsSqlPlatform may not support it.

Best solution is that when getting tables to ignore "sysdiagrams" tables.



 Comments   
Comment by Bostjan Oblak [ 26/Apr/11 ]

One solution is to just add "AND name != 'sysdiagrams' " to sql statement

Comment by Benjamin Eberlei [ 30/Apr/11 ]

Assigned to Jouzas

Comment by Yaroslav Zenin [ 07/Jul/11 ]

Why it is not fixed yet? The solution is so easy. Please add to repository. Because on every release I should change it manually

Comment by Benjamin Eberlei [ 29/Aug/11 ]

Fixed





[DBAL-111] MySQL Driver possibly subject to sql injections with PDO::quote() Created: 18/Apr/11  Updated: 14/May/11  Resolved: 14/May/11

Status: Resolved
Project: Doctrine DBAL
Component/s: Drivers
Affects Version/s: 2.0.0-BETA2, 2.0.0-BETA3, 2.0.0-BETA4, 2.0.0-RC1-RC3, 2.0-RC4, 2.0-RC5, 2.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.1
Fix Version/s: 2.0.4, 2.0.5, 2.1

Type: Bug Priority: Critical
Reporter: Anthony Ferrara Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

MySQL Drivers



 Description   

Prior to 5.3.6, the MySQL PDO driver ignored the character set parameter to options. Due to MySQL's C api (and MySQLND), this is required for the proper function of mysql_real_escape_string() (the C API call). Since PDO uses the mres() C call for PDO::quote(), this means that the quoted string does not take into account the connection character set.

Starting with 5.3.6, that was fixed. So now if you pass the proper character set to PDO via driver options, sql injection is impossible while using the PDO::quote() api call.

PDO proof of concept
$dsn = 'mysql:dbname=INFORMATION_SCHEMA;host=127.0.0.1;charset=GBK;';
$pdo = new PDO($dsn, $user, $pass);
$pdo->exec('SET NAMES GBK');
$string = chr(0xbf) . chr(0x27) . ' OR 1 = 1; /*';
$sql = "SELECT TABLE_NAME
            FROM INFORMATION_SCHEMA.TABLES
            WHERE TABLE_NAME LIKE ".$pdo->quote($string)." LIMIT 1;";
$stmt = $pdo->query($sql);
var_dump($stmt->rowCount());

Expected Result: `int(0)`.
Actual Result: `int(1)`.

There are 2 issues to fix. First, the documentation does not indicate that you can pass the `charset` option to the MySQL Driver. This should be fixed so that users are given the proper option to set character sets.

Secondly, `Connection::setCharset()` should be modified for MySQL to throw an exception, since the character set is only safely setable using the DSN with PDO. This is a limitation of the driver and could be asked as a feature request for the PHP core. Either that, or a big warning should be put on the documentation of the API to indicate the unsafe character set change



 Comments   
Comment by Anthony Ferrara [ 19/Apr/11 ]

Note: issued same bug report for Doctrine1 as it's also affected: http://www.doctrine-project.org/jira/browse/DC-998

Comment by Anthony Ferrara [ 29/Apr/11 ]

Also note that prepared statements in PDO will suffer the same bug since PDO always emulates prepared statements for the mysql driver (even though it fully supports them in the source). See: http://bugs.php.net/bug.php?id=54638

Comment by Benjamin Eberlei [ 14/May/11 ]

Fixed, updated the docs





[DBAL-80] Connection::_bindTypedValues() error when $types[0] is null Created: 01/Jan/11  Updated: 01/Jan/11  Resolved: 01/Jan/11

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: 2.0
Fix Version/s: 2.0.1, 2.1

Type: Bug Priority: Critical
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

When $types[0] = null (default) then _bindTypedValues starts with the wrong offset and binds the wrong types against the wrong params.



 Comments   
Comment by Benjamin Eberlei [ 01/Jan/11 ]

Fixed





[DBAL-168] orm:schema-tool:update will fail if if public scheme has a domains table (PostgreSQL) Created: 22/Sep/11  Updated: 14/Nov/11  Resolved: 14/Nov/11

Status: Resolved
Project: Doctrine DBAL
Component/s: Platforms
Affects Version/s: 2.0.5
Fix Version/s: 2.1.5
Security Level: All

Type: Bug Priority: Critical
Reporter: Martin Prebio Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

If I create a table 'domains' in the default scheme and execute the update procedure of the schema tool, it will throw a PDOException (SQLSTATE[21000]: Cardinality violation: 7 ERROR: more than one row returned by a subquery used as an expression)

I've traced the error to the following statement, which is created by Doctrine\DBAL\Platforms\PostgreSqlPlatform->getListTableForeignKeysSQL():

SELECT r.conname, pg_catalog.pg_get_constraintdef(r.oid, true) as condef
                  FROM pg_catalog.pg_constraint r
                  WHERE r.conrelid =
                  (
                      SELECT c.oid
                      FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n
                      WHERE c.relname = 'domains'
                        AND n.oid = c.relnamespace
                  )
                  AND r.contype = 'f'

This returns two oids because there are two relations with the name domains. One is my table and the other is a view in the information_scheme scheme.

The same problem should occur with the other information_scheme relations.



 Comments   
Comment by Benjamin Eberlei [ 30/Oct/11 ]

Hm the domains entry doesnt seems to pop up for me in pgadmin when executing your query. Can you help me a bit with details on how to reproduce this?

Comment by Martin Prebio [ 31/Oct/11 ]

montbook:~ postgres$ createdb -E UTF8 -T template0 -l de_AT.UTF-8 foo
montbook:~ postgres$ psql foo
foo=# create table domains (id int8 not null);

Now I have a table domains in the default schema and a domains table in the information_schema schema which is created and maintained by postgres. Now executing the query above will produce the mentioned exception.

It was necessary to create a table in the fresh database to create the information_schema. It is a meta schema from where you can select information of the database and it is afaik a sql standard (also mysql has it but as a seperate database).

pgAdmin may hide this schema (and the pg_catalog): http://www.mail-archive.com/pgadmin-support@postgresql.org/msg09332.html

Comment by Benjamin Eberlei [ 14/Nov/11 ]

Fixed and merged into 2.1.x





[DBAL-434] Incorrect type mapping on Oracle Platform Created: 30/Jan/13  Updated: 17/Feb/13  Resolved: 30/Jan/13

Status: Resolved
Project: Doctrine DBAL
Component/s: Platforms
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Critical
Reporter: Damián Nohales Assignee: Benjamin Eberlei
Resolution: Can't Fix Votes: 0
Labels: None
Environment:

Oracle 10g on Windows, using Doctrine 2 with Symfony2



 Description   

Hello,

I'm noticed a strange behaviour when I executed a migration for my Oracle database. Doctrine detects changes on all date columns, generating queries like:

ALTER TABLE the_table MODIFY (the_date DATE DEFAULT NULL);

even if the entity property was not modified. Check in out the Doctrine 2 source code I've detected that Doctrine map the DATE Oracle columns as datetime type, but entity date property are mapped as date (as it should be), so Doctrine believes that entity property and column type are different and generate the alter query.

I found the problem on the method Doctrine\DBAL\Platforms\OraclePlatform::initializeDoctrineTypeMappings, when it say 'date' => 'datetime' should say 'date' => 'date', that fix the migration problem and does not break my application.

Was a typo?

Thanks!



 Comments   
Comment by Benjamin Eberlei [ 30/Jan/13 ]

The problem is that Oracle has a "DATE" type, which is actually a DATETIME. That is why we map it to Doctrine's Datetime type.

As a workaround, you can set this information yourself using:

$conn->getDatabasePlatform()->registerDoctrineTypeMapping('date', 'date');

Be aware this is a global change for all columns. If you map DateTimes to a TIMESTAMP field you are good to go though.

Comment by John Kary [ 17/Feb/13 ]

I ran into this same issue with the default OraclePlatform configuration. I was trying to run doctrine:schema:update --force from the Symfony2 Console on my Oracle database, and ALTER statements were generated for some DATE columns that were fully up to date when looking at the actual table.

But the major issue I ran into was these unnecessary ALTER statements were for DATE columns with NOT NULL constraints, resulting in a query like ALTER TABLE your_table MODIFY (created_at_date DATE NOT NULL); Yet when running this query, Oracle throws an error: ORA-01442: column to be modified to NOT NULL is already NOT NULL. So I could no longer use doctrine:schema:update to update my schema during development against Oracle.

While technically correct, Oracle DATE types actually store time data in addition to date data, I don't agree that this should be considered Doctrine's default behavior.

I believe Oracle DATE columns should be date-only (e.g. Day, Month, Year) and time data should be disregarded. All other drivers except SQLServer map "date" fields to Doctrine's "date" type. I would rather see someone wanting to store time data with their DATE field need to make the suggested change, instead of the other way around:

$conn->getDatabasePlatform()->registerDoctrineTypeMapping('date', 'datetime');

Oracle 11g Release 1 DATE type docs: http://docs.oracle.com/cd/B28359_01/server.111/b28318/datatype.htm#i1847)

Comment by Benjamin Eberlei [ 17/Feb/13 ]

Well the other thing is, that we cannot change this for BC reasons.

We could introduce a new platform that solves this issue though.





[DBAL-244] Shema Tool is not working after DBAL-177 for postgresql (mysql working like before) Created: 25/Mar/12  Updated: 05/May/12  Resolved: 05/May/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: 2.2, 2.2.1
Fix Version/s: 2.2.3

Type: Bug Priority: Critical
Reporter: Margus Sipria Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

Ubuntu 10.10, Zend Server 5.5.0 with PHP 5.3.8



 Description   

After trying to upgrade 2.2.0 i found that schema tool wasn't working, so I switched back to 2.1.6, same thing with 2.2.1 and no bug report, so this is wats going on.

./doctrine orm:schema-tool:update --dump-sql # this will show full create table for schema even if tables are all ready there.

After git bisectin Doctrine ORM project i found that commit ea5108ea0f35fc0f7ed3a740995a590926045c6e wast to blame, but that was only submodule update so made bisect for Doctrine DBAL:

537de7ea6a34edbcc40bc6ca92e0a3f816b59330 .. 4410e4cec20b0f1f209578320e5b7d111e90c2a0 founding that 1ae87bf3e3ba93cb579a2a092b06b5a09b316542 was the problem.

[margus@laptop doctrine-dbal ((4410e4c...))]$ git reset --hard 1ae87bf3e3ba93cb579a2a092b06b5a09b316542
HEAD is now at 1ae87bf DBAL-177 - Make sure schema.table syntax is supported in Assets for quoted assets
[margus@laptop doctrine-dbal ((1ae87bf...))]$ git submodule update --recursive
Submodule path 'lib/vendor/doctrine-common': checked out 'd6e4c8b22af9800db4fd9d679ce98538da028168'

    1. shema tool printing full schema

[margus@laptop doctrine-dbal ((1ae87bf...))]$ git reset --hard HEAD^1
HEAD is now at bb84496 DBAL-144 - Dont throw exception when no primary key exists
[margus@laptop doctrine-dbal ((bb84496...))]$ git submodule update --recursive

    1. works fine

[margus@laptop build (master)]$ ./doctrine orm:schema-tool:update --dump-sql
Nothing to update - your database is already in sync with the current entity metadata.

with commit 1ae87bf3e3ba93cb579a2a092b06b5a09b316542 schema starts with 3 NULL lines, and then schema, with 2.2.0, extra "NULL" lines aren't there anymore.

Using MySQL there isn't any problem, but with PostgreSQL (i have 8.4.11) this issue appears.



 Comments   
Comment by Benjamin Eberlei [ 30/Mar/12 ]

Increase priority, will be fixed this weekend and in the next bugifx release

Comment by Benjamin Eberlei [ 30/Mar/12 ]

Are you using Postgresql Schema? Can you provide some information about your database tables? I need some more information to try reproducing this.

Comment by Nikolai Spassoff [ 03/May/12 ]

I'm experiencing the same issue.
I looked at the mentioned commit and found out that the SQL query in getSchemaNames() does not return any namespaces.
After some research I came with the following query to list all non-system namespaces in Postgres:

SELECT nspname as schema_name FROM pg_namespace WHERE nspname !~ '^pg_.*' and nspname != 'information_schema'

This fixed the issue for me and the schema-tool works again.

Comment by Benjamin Eberlei [ 05/May/12 ]

Fixed, but couldn't verify as the previous statement worked for me.





[DBAL-228] OCI8Statement' fetchAll method can not do with PDO::FETCH_BOTH Created: 02/Mar/12  Updated: 14/Mar/12  Resolved: 14/Mar/12

Status: Resolved
Project: Doctrine DBAL
Component/s: Drivers
Affects Version/s: 2.2.1
Fix Version/s: 2.2.2
Security Level: All

Type: Bug Priority: Critical
Reporter: zhouhero Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

/**

  • {@inheritdoc}

    */

private static $fetchStyleMap = array(
PDO::FETCH_BOTH => OCI_BOTH,
PDO::FETCH_ASSOC => OCI_ASSOC,
PDO::FETCH_NUM => OCI_NUM
);

public function fetchAll($fetchStyle = PDO::FETCH_BOTH)
{
if ( ! isset(self::$fetchStyleMap[$fetchStyle]))

{ throw new \InvalidArgumentException("Invalid fetch style: " . $fetchStyle); }

$result = array();
oci_fetch_all($this->_sth, $result, 0, -1,
self::$fetchStyleMap[$fetchStyle] | OCI_RETURN_NULLS | OCI_FETCHSTATEMENT_BY_ROW | OCI_RETURN_LOBS);

return $result;
}

oci_fetch_all method can only surport

  • OCI_NUM
  • OCI_ASSOC

in $fetchStyleMap, OCI_BOTH is included!!!!



 Comments   
Comment by Benjamin Eberlei [ 14/Mar/12 ]

Fixed





[DBAL-50] PgSQL driver does not create indexes on foreign key columns Created: 18/Aug/10  Updated: 11/Sep/10  Resolved: 11/Sep/10

Status: Resolved
Project: Doctrine DBAL
Component/s: Schema Managers
Affects Version/s: 2.0.0-BETA4
Fix Version/s: 2.0.0-RC1-RC3

Type: Bug Priority: Critical
Reporter: Petr Motejlek Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

The PostgreSQL database does not create indexes for foreign key columns, the user has to create them by hand. I think that indexes for foreign keys should be created automatically... On my system, an index will not be created automatically for the group_id column in the user table.

/**
 * @Entity
 */
class User {
    /**
     * @ManyToOne(targetEntity="Group", inversedBy="users")
     */
    protected $group;
}

/**
 * @Entity
 */
class Group {
    /**
     * @OneToMany(targetEntity="User", mappedBy="group")
     */
    protected $users;

    public function __construct() {
        $this->users = new \Doctrine\Common\Collections\ArrayCollection();
    }
}

I am using current git clone and PgSQL 8.4.



 Comments   
Comment by Petr Motejlek [ 09/Sep/10 ]

I'd just like to add that there's an even worse problem with this – the indices are not created even for tables that Doctrine creates automatically – for example the joining tables...

Comment by Benjamin Eberlei [ 09/Sep/10 ]

i'll look into it.

Comment by Benjamin Eberlei [ 11/Sep/10 ]

Fixed in master, leading to several follow up bugs that all had to be fixed:

1. generate identifier allowed first char to be a number
2. postgresql composite foreign key detection left a space in the second (and more) column names
3. Index column names were not sanitized to lower-case, leading to comparison bugs.

There has been a major refactoring now such that, for each foreign key there is always an explicit index being created. On SQLite, Postgres and Oracle this can lead to quite some additional indexes being created now using SchemaTool --update. MySQL already did this implicitly.

There are now heuristics that detect duplicate indexes (based on columns indexed) and override rules (adding primary on columns foo, bar will delete index on columns foo bar).

Comment by Benjamin Eberlei [ 11/Sep/10 ]

Note, this commit will not get into Doctrine ORM master unless you update the git-submodule explicitly:

cd lib/vendor/doctrine-dbal
git checkout master

For RC-1 this will be visible to the ORM trunk/master also.





[DBAL-65] No way to store binary data in PostgreSQL with Doctrine Created: 20/Nov/10  Updated: 09/Oct/12  Resolved: 20/Nov/10

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

Type: Bug Priority: Major
Reporter: Tomasz Jędrzejewski Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None
Environment:

PostgreSQL 8.4



 Description   

The type system introduced by Doctrine makes impossible to store binary data in PostgreSQL databases that use Unicode. The `text` type is mapped to `TEXT`, but any trial to place some binary data there ends up with a database error, like this:

SQLSTATE[22021]: Character not in repertoire: 7 ERROR: invalid byte sequence for encoding "UTF8": 0x9c

This is a critical limitation, because Doctrine cannot be used now in projects that for any reasons have to use PostgreSQL, and their databases must store binary data. Even if it cannot be fixed right now, it should be clearly pointed out in the documentation in "Known vendor issues".

A possible solution for this problem is creating an equivalent of 'text' field, called 'binary' or something like that. It must be a simple type that is mapped to the simplest, but large type available in the database engine without any form of data structure validation. For PostgreSQL, this could be 'blob', but other database engines can use different types.



 Comments   
Comment by Tomasz Jędrzejewski [ 20/Nov/10 ]

Just a small note why I consider this bug as quite serious: for many programmers and their projects the lack of both support for such content type and any information about the limitation can be very dangerous. It can be impossible to remove ORM, if such an issue is encountered in the implementation process, and trials to workaround it are time-consuming.

If I'm about to decide whether to use a particular ORM or not, I must have full information about ORM and database-specific limitations.

One more update: shame on me, obviously there is no "blob" type in PostgreSQL; in this database engine binary data could be represented by 'BYTEA'.

Comment by Benjamin Eberlei [ 20/Nov/10 ]

This is not an issue, there are two options to "solve" your problem in userland:

1. Create your own DBAL type - http://www.doctrine-project.org/projects/orm/2.0/docs/reference/basic-mapping/en#custom-mapping-types
2. Use columnDefinition Attribute of @column - http://www.doctrine-project.org/projects/orm/2.0/docs/reference/annotations-reference/en#ann_column

Comment by Tomasz Jędrzejewski [ 12/Dec/10 ]

I know I can create a custom type, but I'd like to have a portable binary type by default in Doctrine DBAL, not reinventing the wheel every time I want to have one. I consider binary data as one of the primitive types that every database engine supports.

Comment by Jon Wadsworth [ 09/Oct/12 ]

This is an old post but just in case somebody else finds it. There is no need to do any of the above to store binary data in Postgres. I had the same situation and was easily solved by compressing file, base64 encoding it, and finally serializing it.

public static function prepareFileforDatabase($file)

{ $compressor = new \Zend_Filter_Compress_Gz(); $file = $compressor->compress($file); $file = base64_encode($file); return serialize($file); }

We use Zend and you may be able to get away with not compressing if you wanted to avoid the extra overhead on your server. To undo it is exactly the opposite.

public static function prepareFileforPHP($file)

{ $compressor = new \Zend_Filter_Compress_Gz(); $file = unserialize($file); $file = base64_decode($file); return $compressor->decompress($file); }

Sorry for the code coming out in all one line, but you get the idea.





[DBAL-64] Fix identifier quoting in DBAL Schema Created: 17/Nov/10  Updated: 18/Nov/10  Resolved: 18/Nov/10

Status: Resolved
Project: Doctrine DBAL
Component/s: Schema Managers
Affects Version/s: 2.0.0-RC1-RC3
Fix Version/s: 2.0-RC4

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

Identifier quoting using the Schema component is sort of borked.

The optional or none approach from ClassMetadata should be looked at. Introducing a common quoting identifier `` and sanitizing this from each asset + a new method "getQuotedName()" that optionally quotes the identifier given the platform.



 Comments   
Comment by Benjamin Eberlei [ 18/Nov/10 ]

Fixed





[DBAL-63] Custom Types always detected as changed when orm:schema-tool:update Created: 16/Nov/10  Updated: 16/Nov/10  Resolved: 16/Nov/10

Status: Resolved
Project: Doctrine DBAL
Component/s: Schema Managers
Affects Version/s: 2.0.0-BETA4
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Berny Cantos Assignee: Benjamin Eberlei
Resolution: Duplicate Votes: 0
Labels: None
Environment:

Ubuntu 10.10, MySQL 5.1.49, PHP 5.3.3



 Description   

I defined a custom type for DBAL and used it in an entity annotation. Every time I call doctrine orm:schema-tool:update, even when no changes are been made to the code, DBAL thinks the schema has changed and needs an update. The type declaration is done in cli-config.php, when creating the EntityManager.

See the code and output below:

Project/CustomType.php
namespace Project;

use \Doctrine\DBAL\Platforms\AbstractPlatform,
    \Doctrine\DBAL\Types\Type;

class CustomType extends Type
{
    const TYPE = 'custom';

    public function getSqlDeclaration(array $fieldDeclaration,
                                      AbstractPlatform $platform)
    {
        return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration);
    }

    public function getName()
    {
        return self::TYPE;
    }
}
Project/Entity.php
/**
 * @entity
 */
namespace Project;
class Entity
{
    /**
     * @id
     * @column(type="integer")
     */
    private $id;

    /**
     * @column(type="custom")
     */
    private $custom;
}
cli-config.php
$cache = new \Doctrine\Common\Cache\ApcCache;
$config = new \Doctrine\ORM\Configuration;
$config->setMetadataCacheImpl($cache);
$config->setQueryCacheImpl($cache);

$driverImpl = $config->newDefaultAnnotationDriver(APPLICATION_PATH . '/Project');
$config->setMetadataDriverImpl($driverImpl);

$config->setProxyDir(APPLICATION_PATH . '/Proxies');
$config->setProxyNamespace('Proxies');
$config->setAutoGenerateProxyClasses(true);

$connectionOptions = array(
    'driver'   => 'pdo_mysql',
    'dbname'   => 'project',
    'user'     => '#user#',
    'password' => '#password#',
    'host'     => 'localhost',
);

\Doctrine\DBAL\Types\Type::addType('custom', 'Project\CustomType');
$em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config);

$helperSet = new \Symfony\Component\Console\Helper\HelperSet(array(
    'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()),
    'em' => new Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em),
));
Console Output
#:~ doctrine orm:schema-tool:create --dump-sql
CREATE TABLE Entity (id INT NOT NULL, custom VARCHAR(255) NOT NULL, PRIMARY KEY(id)) ENGINE = InnoDB

#:~ doctrine orm:schema-tool:create
Creating database schema...
Database schema created successfully!

#:~ doctrine orm:schema-tool:update --dump-sql
ALTER TABLE Entity CHANGE custom custom VARCHAR(255) NOT NULL

#:~ doctrine orm:schema-tool:update --force
Updating database schema...
Database schema updated successfully!

#:~ doctrine orm:schema-tool:update --dump-sql
ALTER TABLE Entity CHANGE custom custom VARCHAR(255) NOT NULL


 Comments   
Comment by Benjamin Eberlei [ 16/Nov/10 ]

Yes, it thinks its a varchar and wants to update that definition. This is a duplicate of DBAL-42





[DBAL-62] Length of a string column cannot exceed 255 Created: 16/Nov/10  Updated: 27/Nov/10  Resolved: 27/Nov/10

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: 2.0.0-RC1-RC3
Fix Version/s: 2.0-RC4

Type: Bug Priority: Major
Reporter: jules b Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

Mysql


Sub-Tasks:
Key
Summary
Type
Status
Assignee
DBAL-69 Varchar definition should automatical... Sub-task Open Benjamin Eberlei  

 Description   

I use the annotation mapping:
here's my mapping informations:

/** 
* @var mixed optionValue
* @orm:Column(nullable="true", name="option_value", length="2000", type="string") 
*/
protected $optionValue;

when i check the mysql column type it's still "varchar(255)".



 Comments   
Comment by Jani Hartikainen [ 26/Nov/10 ]

Confirmed on OS X 10.6, PHP 5.3.2, MySQL 5.1.51, DBAL RC3. Schema-tool always generates a VARCHAR(255) column for cases like this. 1.x used to generate TEXT, which I would assume is the correct behavior with MySQL in this case.

Comment by Benjamin Eberlei [ 27/Nov/10 ]

Fixed, the max length of varchars was set to 255.

However this is rather the default value. The maximum value is now 4000, which is the smallest common denominator between all supported vendors (Oracle is that).

In the future we would probably allow arbitrary large sizes here and switch to a CLOB definition automatically if the specifed string length is larger than max length.





[DBAL-61] Incompatible transactions in OCI8 driver with other drivers (pdo_oci, pdo_mysql, pdo_pgsql) Created: 09/Nov/10  Updated: 11/Nov/10  Resolved: 11/Nov/10

Status: Resolved
Project: Doctrine DBAL
Component/s: Drivers
Affects Version/s: 2.0.0-BETA4
Fix Version/s: 2.0.0-RC1-RC3

Type: Bug Priority: Major
Reporter: Miloslav "adrive" Kmet Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

PHP Version 5.3.3-1ubuntu9, OCI8 1.4.1, Oracle 10.2.0.4.0



 Description   

When I try to insert some data, it is not saved into database.

$connectionOptions['oci8'] = array(
    'driver' => 'oci8',
    'dbname' => 'BOOK',
    'user' => 'doctrine',
    'password' => 'doctrine',
//    'charset' => 'AL32UTF8',
);

$em = EntityManager::create($connectionOptions['oci8'], $config, $evm);
$conn = $em->getConnection();
$conn->connect();
$conn->insert('my_table', array('my_column' => 'Some value'));

When I invoke the previous code on any other DBAL driver, like pdo_oci, pdo_mysql, pdo_pgsql, the row is inserted.

That's because Oracle is transactional, and everything need to be commited. This behavior prevent's me (and I think in a feature not only me), to use 3rd party code (bundles, models, plugins...) in my applications running oracle. This behavior prevents developers to write portable code with DBAL. The solution is to make OCI8Driver commit everything after invoking oci_execute(), the same way how Doctrine_Adapter_Oracle works in Doctrine1. (https://github.com/doctrine/doctrine1/blob/master/lib/Doctrine/Adapter/Oracle.php)



 Comments   
Comment by Benjamin Eberlei [ 09/Nov/10 ]

Scheduled for RC1, thanks for the patch - I will apply asap.

Comment by Benjamin Eberlei [ 11/Nov/10 ]

Fixed





[DBAL-60] OCI8Connection couldn't connect when charset parameter specified Created: 09/Nov/10  Updated: 29/Dec/12  Resolved: 11/Nov/10

Status: Resolved
Project: Doctrine DBAL
Component/s: Drivers
Affects Version/s: 2.0.0-BETA4
Fix Version/s: 2.0.0-RC1-RC3

Type: Bug Priority: Major
Reporter: Miloslav "adrive" Kmet Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

PHP Version 5.3.3-1ubuntu9, OCI8 1.4.1, Oracle 10.2.0.4.0



 Description   

When I am trying to connect to Oracle instance with another charset then specified in my environment variable NLS_LANG I got an error.

$connectionOptions['oracle'] = array(
    'driver' => 'oci8',
    'dbname' => 'BOOK',
    'user' => 'doctrine',
    'password' => 'doctrine',
    'charset' => 'AL32UTF8',
);

$em = EntityManager::create($connectionOptions['oracle'], $config, $evm);
$em->getConnection()->connect();

Produce error messages:

PHP Warning: oci_error() expects parameter 1 to be resource, boolean given in /www/test/doctrine2/vendor/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php on line 149
PHP Fatal error: Uncaught exception 'Doctrine\DBAL\Driver\OCI8\OCI8Exception' in /www/test/doctrine2/vendor/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php:42

There is bug in OCI8Connection::errorInfo() and ::errorCode(). When oci_connect failed, it returns a boolean - false. but oci_error() accepts only resource as parameter. Therefor it is neccessary to check, whether $this->_dbh is resource.

When I've fixed the error handling, I've got the right error, why I couldn't connect to Oracle:

PHP Fatal error: Uncaught exception 'Doctrine\DBAL\Driver\OCI8\OCI8Exception' with message 'ORA-12154: TNS:could not resolve the connect identifier specified' in /www/test/doctrine2/vendor/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Exception.php:28

That's because oci_connect accepts as connection string only TNS name, or Oracle Connection string. But ;charset=* in TNS name or connection string is invalid. oci_connect has 4th parameter charset for that purpose.



 Comments   
Comment by Miloslav "adrive" Kmet [ 09/Nov/10 ]

Fixed in https://github.com/milokmet/dbal/tree/DBAL-60

Comment by Benjamin Eberlei [ 11/Nov/10 ]

Fixed

Comment by Ruslan [ 29/Dec/12 ]

Can you help me. I'm having same problem. But your link doesn't work.

Comment by Miloslav "adrive" Kmet [ 29/Dec/12 ]

You must have very old source code. The bug was fixed 2 years ago. Just compare your OCI8 driver with https://github.com/doctrine/dbal/tree/master/lib/Doctrine/DBAL/Driver/OCI8





[DBAL-56] Ship a compatibility wrapper like MDB2 Created: 29/Sep/10  Updated: 05/Mar/11  Resolved: 05/Mar/11

Status: Resolved
Project: Doctrine DBAL
Component/s: Drivers
Affects Version/s: 2.0.0-BETA4
Fix Version/s: 2.1

Type: New Feature Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

Database Portability is expensive but often necessary. We should support the important Compatibility Layer Options that MDB2 has:

http://pear.php.net/manual/en/package.database.mdb2.intro-portability.php

The following I think are doable:

  • Empty to Nulls
  • Change Case of Field-Assocs
  • Oracle RTRIM for Chars
  • Num Rows "hack" for Oracle
  • Delete Count (Some vendors rewrite a DELETE tablename into a TRUNCATE and dont report the delete count)

There should be a class extending "Doctrine\DBAL\Connection" making use of the 'wrapperClass' option. Two new classes are necessary:

Doctrine\DBAL\Portability\Connection
Doctrine\DBAL\Portability\Statement



 Comments   
Comment by Benjamin Eberlei [ 05/Mar/11 ]

Implemented.

To use define the following three parameters:

$params = array();
// ...
$params['wrapperClass'] = 'Doctrine\DBAL\Portability\Connection';
$params['portability'] = Doctrine\DBAL\Portability\Connection::PORTABILITY_ALL;
$params['fetch_case'] = \PDO::CASE_LOWER;
$conn = DriverManager::getConnection($params, $config, $evm);

This mode probably hits performance pretty hard,but it allows you to write code that works with all the quirks of fetching values from all database vendors.





[DBAL-55] Nested transaction emulation doesn't support rollback inside a nested transaction Created: 29/Sep/10  Updated: 01/Oct/10  Resolved: 01/Oct/10

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: 2.0.0-BETA4
Fix Version/s: 2.0.0-RC1-RC3

Type: Bug Priority: Major
Reporter: Lukas Kahwe Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

It seems like beginTransaction() counts transaction nesting levels, but it doesnt set a savepoint when starting a new nesting level, nor does it therefore support rollbacks when rolling back inside a nested transaction. This means that I could call rollback() and it doesnt actually do anything, which imho is a bug.

The feature of using savepoints to emulate nested transactions properly seems to be present in Doctrine1.



 Comments   
Comment by Lukas Kahwe [ 30/Sep/10 ]

ok .. i am working on a patch

Comment by Benjamin Eberlei [ 30/Sep/10 ]

I guess we need new methods on AbstractPlatform to return the SQL to set, release and rollback a savepoint and then extend the Doctrine\DBAL\Connection to work with that.

Comment by Lukas Kahwe [ 30/Sep/10 ]

yup .. thats what i am doing

Comment by Lukas Kahwe [ 30/Sep/10 ]

did some initial work: http://github.com/lsmith77/dbal/tree/savepoints

not quite sure about the changes i had to do in the unittest.
probably should add new unit tests too.
also there are a couple of questions i have in the connection class

Comment by Benjamin Eberlei [ 01/Oct/10 ]

merged.





[DBAL-53] Missing convertToDatabase-calls when loading and persisting entities Created: 15/Sep/10  Updated: 15/Sep/10  Resolved: 15/Sep/10

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

Type: Bug Priority: Major
Reporter: Lars Strojny Assignee: Benjamin Eberlei
Resolution: Duplicate Votes: 0
Labels: None

Attachments: File 001-doctrine-type-conversion-support-for-onetomany.diff     File 002-doctrine-type-conversion-support-for-onetoone.diff     File 004-doctrine-type-conversion-support-delete.diff    
Issue Links:
Duplicate
duplicates DDC-1503 Add support for executing custom SQL ... Closed

 Description   

As we use binary encoded UUIDs as primary keys, we sometimes stumbled upon the issue of having incorrect SQL queries executed with unencoded database values. Currently we observed the wrong behavior for the following scenarios:

  • Deleting entities
  • OneToOne relations
  • OneToMany relations

I'm pretty sure this bug also exists for OneToMany relations, but we haven't used them yet.



 Comments   
Comment by Benjamin Eberlei [ 15/Sep/10 ]

Duplicate of DBAL-15





[DBAL-49] PDOSqlsrv's constructor breaks when using non "local" server host Created: 07/Sep/10  Updated: 23/Sep/10  Resolved: 23/Sep/10

Status: Resolved
Project: Doctrine DBAL
Component/s: Drivers
Affects Version/s: 2.0.0-BETA4
Fix Version/s: 2.0.0-RC1-RC3

Type: Bug Priority: Major
Reporter: Aaron DM Assignee: Juozas Kaziukenas
Resolution: Fixed Votes: 0
Labels: None
Environment:

Windows 7, Apache 2.1, PHP 5.3.3, Microsoft SQL Server 2008 Enterprise Edition



 Description   

Problem:

Currently, the _constructPdoDsn() for the PDOSqlsrv driver works fine only if the host provided is: local or localhost.
If using an IP address, this breaks. Reason is because _constructPdoDsn() applies ( and ) around the host.

        $dsn = 'sqlsrv:server=(';
        if (isset($params['host'])) {
            $dsn .= $params['host'];
        }
        $dsn .= ')';

This is fine for when $params['host'] = 'local'; because I believe local is a name pipe (I think) and to properly use it you need to add the brackets around it

However if $params['host'] = '127.0.0.1'; this breaks!

Fix:

Get rid of the forced brackets

        $dsn = 'sqlsrv:server=';
        if (isset($params['host'])) {
            $dsn .= $params['host'];
        }

That way, when supplying local as a host, you have to enter (local) (which makes more sense as that's how you would do it normally in other applications).



 Comments   
Comment by Benjamin Eberlei [ 23/Sep/10 ]

This is fixed in master.





[DBAL-47] Incorrect filename -- EchoSqlLogger.php Created: 02/Sep/10  Updated: 02/Sep/10  Resolved: 02/Sep/10

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: 2.0.0-BETA4
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Alexandr Torchenko Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None


 Description   

I've got error:
require(/var/www/betportal/dev.betportal.org/application/libraries/Doctrine/DBAL/Logging/EchoSqlLogger.php) [function.require]: failed to open stream: No such file or directory

Doctrine/DBAL/Logging/EchoSQLLogger.php should be renamed to EchoSqlLogger.php.



 Comments   
Comment by Benjamin Eberlei [ 02/Sep/10 ]

the class is named EchoSQLLogger.





[DBAL-46] Fix doctrine-dbal console command Created: 01/Sep/10  Updated: 02/Sep/10  Resolved: 02/Sep/10

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: 2.0.0-BETA4
Fix Version/s: 2.0.0-RC1-RC3

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

It still uses Symfony\Components with S.



 Comments   
Comment by Benjamin Eberlei [ 02/Sep/10 ]

fixed.





[DBAL-45] Add CLI tool that checks for Reserved Keywords Created: 31/Aug/10  Updated: 27/Feb/11  Resolved: 27/Feb/11

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

Type: New Feature Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Reference
is referenced by DBAL-96 Make approach towards identifier quot... Open

 Description   

Add a CLI tool that checks for reserved keywords in your current schema (for other databases vendors) to support cross vendor portability.



 Comments   
Comment by Benjamin Eberlei [ 27/Feb/11 ]

Implemented.





[DBAL-51] "No identifier/primary key specified for Entity" problem, Doctrine Beta 3 cannot find primary key Created: 31/Aug/10  Updated: 27/Nov/10  Resolved: 27/Nov/10

Status: Resolved
Project: Doctrine DBAL
Component/s: Schema Managers
Affects Version/s: 2.0.0-BETA4
Fix Version/s: 2.0.0-RC1-RC3

Type: Bug Priority: Major
Reporter: Minxuan GUO Assignee: Juozas Kaziukenas
Resolution: Fixed Votes: 0
Labels: None
Environment:

windows xp, sql server 2008, php 5.3



 Description   

when execute

php doctrine.php orm:convert-mapping --from-database annotation "Entities"

get error message

No identifier/primary key specified for Entity 'Classname(Tablename)'. Every Entity must have an identifier/primary key.

For resolving this problem
I've replaced the line

public function loadMetadataForClass($className, ClassMetadataInfo $metadata)
{
...
$indexes = $this->tables[$tableName]->getIndexes();
...
}

in function "loadMetadataForClass" in \\Doctrine\ORM\Mapping\Driver\DatabaseDriver.php by

public function loadMetadataForClass($className, ClassMetadataInfo $metadata)
{
...
$indexes = $this->_sm->listTableIndexes($tableName);
...
}

then the beta 3 works for my date base

It is because doctrine look for $indexes['prime'] to construit the primary key in entities. when we use "$this->tables[$tableName]>getIndexes()", the keys in $indexes are the real name of indexes of the data base, and in my database, the primary key indexes are named PK_TABLENAME. So I have to use $this>_sm->listTableIndexes($tableName) to pre-edit the indexes before get the list



 Comments   
Comment by Benjamin Eberlei [ 15/Sep/10 ]

This is an error in the MSSQL SchemaManager, it is not correctly setting the primary = true key in the index retrieve method. I move that issue to DBAL and reassign to juokaz

Comment by Juozas Kaziukenas [ 14/Nov/10 ]

I believe this is now fixed, but I'll test more https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Schema/MsSqlSchemaManager.php#L118

Comment by Benjamin Eberlei [ 27/Nov/10 ]

Fixed.





[DBAL-137] Setting empty host in PostgreSQL prevents connection to socket Created: 24/Jul/11  Updated: 24/Jul/11  Resolved: 24/Jul/11

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: 2.1
Fix Version/s: 2.1.1

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

Reported on https://github.com/symfony/symfony/issues/1788#issuecomment-1640104






[DBAL-136] OCI8 Driver MUST support connections by SERVICE_NAME Created: 19/Jul/11  Updated: 18/Aug/11  Resolved: 18/Aug/11

Status: Resolved
Project: Doctrine DBAL
Component/s: Drivers
Affects Version/s: 2.1
Fix Version/s: 2.1

Type: New Feature Priority: Major
Reporter: Daniel Lima Assignee: Benjamin Eberlei
Resolution: Duplicate Votes: 0
Labels: None

Issue Links:
Duplicate
duplicates DBAL-141 PDO Connection Failure through TNS - ... Resolved

 Description   

The existing oci8 driver connection only supports connections from database name configuraton.
It will be very good if is possible set a connection by service name.

Take a look in this DSN:

(DESCRIPTION= (ADDRESS= (PROTOCOL=TCP) (HOST=192.168.0.1) (PORT=1521) ) (CONNECT_DATA= (SERVICE_NAME=TH01) ) )

More info:
http://stackoverflow.com/questions/43866/how-sid-is-different-from-service-name-in-oracle-tnsnames-ora






[DBAL-135] Index::overrules() does not detect pks overruling unique indexes Created: 26/Jun/11  Updated: 26/Jun/11  Resolved: 26/Jun/11

Status: Resolved
Project: Doctrine DBAL
Component/s: Schema Managers
Affects Version/s: 2.0.6
Fix Version/s: 2.1

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Comments   
Comment by Benjamin Eberlei [ 26/Jun/11 ]

Fixed in https://github.com/doctrine/dbal/commit/2cb22496a732029373d98ff9e4d54a7187ee9bb8





[DBAL-134] Doctrine\DBAL\Connection::query() no logging Created: 24/Jun/11  Updated: 28/Jun/11  Resolved: 28/Jun/11

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: 2.0.6
Fix Version/s: 2.0.7, 2.1

Type: Bug Priority: Major
Reporter: Kirill chEbba Chebunin Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

Doctrine\DBAL\Connection::query() does not use SqlLogger.

I guess it may be fixed like this:

    public function query()
    {
        $this->connect();

        $args = func_get_args();

        $logger = $this->getConfiguration()->getSQLLogger();
        if ($logger) {
            $logger->startQuery($args[0]);
        }

        $statement = call_user_func_array(array($this->_conn, 'query'), $args);

        if ($logger) {
            $logger->stopQuery();
        }

        return $statement;
    }


 Comments   
Comment by Benjamin Eberlei [ 28/Jun/11 ]

Fixed





[DBAL-132] wrong mysql dump generation for foreign keys Created: 22/Jun/11  Updated: 31/Jul/11  Resolved: 31/Jul/11

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: 2.0.5
Fix Version/s: 2.0.7, 2.1.1

Type: Bug Priority: Major
Reporter: Stefan Zerkalica Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 1
Labels: None
Environment:

PHP 5.3.3-7+squeeze1 with Suhosin-Patch, Debian GNU/Linux 6.0.1 (squeeze)



 Description   

Problem in methods Doctrine\DBAL\Platforms\AbstractPlatform::getDropForeignKeySQL() and Doctrine\DBAL\Platforms\AbstractPlatform::getCreateForeignKeySQL()

This methods do not receive FK name and don't put it in sql dump. While executing dump, mysql autogenerate FK names, but at the migration generation moment doctrine knowns nothing about them.

I think, doctrine must generate this names and put it into the schema.

Autogenerated migrations in mysql with fk are unusable.

Doctrine migrations:migrate in current doctrine version:
up:
ALTER TABLE Catalog_Field ADD CONSTRAINT FOREIGN KEY (groupId) REFERENCES Catalog_FieldGroup(id)
down:
ALTER TABLE Catalog_Field DROP FOREIGN KEY

should be:
up:
ALTER TABLE Catalog_Field ADD CONSTRAINT Catalog_Field_ibfk_2 FOREIGN KEY (groupId) REFERENCES Catalog_FieldGroup(id)
down:
ALTER TABLE Catalog_Field DROP FOREIGN KEY catalog_Field_ibfk_2

see: https://github.com/doctrine/migrations/issues/32

https://github.com/doctrine/migrations/issues/35



 Comments   
Comment by Benjamin Eberlei [ 31/Jul/11 ]

Fixed





[ORACLE] Speed improvement of mechanism for limiting query results (DBAL-93)

[DBAL-130] Add tests for modify limit query functionality Created: 17/Jun/11  Updated: 17/Jun/11  Resolved: 17/Jun/11

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

Type: Sub-task Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None





[DBAL-128] Additional types are not registered in the platforms when creating a connection Created: 16/Jun/11  Updated: 16/Jun/11  Resolved: 16/Jun/11

Status: Resolved
Project: Doctrine DBAL
Component/s: Drivers
Affects Version/s: 2.0.5
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Christophe Coevoet Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None


 Description   

New types have to be registered in the platforms using registerDoctrineMappingType but the driver does not call this for type that are registered using Type::addType
This issue has been reported by some Symfony user here https://github.com/symfony/symfony/issues/1349 but the bug is indeed in DBAL.

Btw, this also affects the master branch but this project does not allow to select it (the ORM project does)



 Comments   
Comment by Benjamin Eberlei [ 16/Jun/11 ]

This is not a "bug". This methods have to called indepdentatly.

Comment by Christophe Coevoet [ 16/Jun/11 ]

When I asked you about this some times ago for the DoctrineBundle integration, you told me that calling Type:addType was enough

Comment by Benjamin Eberlei [ 16/Jun/11 ]

cant remember, i must have been tired sorry





[DBAL-126] schema-tool creates primary keys as unique constraints Created: 09/Jun/11  Updated: 26/Jun/11  Resolved: 26/Jun/11

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: 2.0.5
Fix Version/s: 2.0.7, 2.1

Type: Bug Priority: Major
Reporter: arnaud-lb Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

The schema tool calls AbstractPlatform::getCreateIndexSQL() to create new indexes. When the index is primary, this creates a unique key instead.



 Comments   
Comment by Karsten Dambekalns [ 25/Jun/11 ]

While the description here is very sparse, I think it is about the following problem.

When a primary key is to be created for MySQL, the statement generated is

ADD UNIQUE INDEX PRIMARY ON foo (bar)

This fails with MySQL stating primary is an invalid name. Since "ADD INDEX" is mapped to "ALTER TABLE" anyway, I just made that

ALTER TABLE foo ADD PRIMARY KEY (bar)

which works fine. Also

DROP INDEX primary ON foo

doesn't work, unless I quote primary (since it is a reserved word), but there

ALTER TABLE foo DROP PRIMARY KEY

seems better as well.

Comment by Benjamin Eberlei [ 26/Jun/11 ]

Fixed





[DBAL-120] MySql platform getAlterTableSQL does not quote existing column names Created: 13/May/11  Updated: 19/Jun/11  Resolved: 19/Jun/11

Status: Resolved
Project: Doctrine DBAL
Component/s: Platforms
Affects Version/s: 2.0.4
Fix Version/s: 2.0.4

Type: Bug Priority: Major
Reporter: Devon Weller Assignee: Benjamin Eberlei
Resolution: Duplicate Votes: 0
Labels: None

Attachments: Text File quote-mysql-change-colname.patch     Text File quote-mysql-change-keyname.patch    
Issue Links:
Duplicate
duplicates DBAL-96 Make approach towards identifier quot... Open

 Description   

When creating alter table SQL, the MySqlPlatform class does not quote names for columns of an existing table when building a CHANGE query. This can cause SQL errors.

It creates queries like this:

ALTER TABLE my_table CHANGE key `key` INTVARCHAR(255) DEFAULT '' NOT NULL';

Attached is a patch to fix this.

As an aside, is this the best way to contribute a patch? Or is a GitHub pull request better?



 Comments   
Comment by Devon Weller [ 13/May/11 ]

I also discovered a similar issue with key names. A second patch is attached.

Comment by Benjamin Eberlei [ 19/Jun/11 ]

This problem is a little more complicated, it will be fixed in DBAL-96 probably for 2.2





[DBAL-119] Outdated Console component Created: 11/May/11  Updated: 14/May/11  Resolved: 14/May/11

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: 2.0.4
Fix Version/s: 2.0.5

Type: Bug Priority: Major
Reporter: Christophe Coevoet Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

The DBAL submodule uses an outdated version of the Console component (before the switch to private properties). But the Migrations project defines its command using the latest interface which means that it cannot be used with the DBAL out-of-the-box as it calls the getApplication method which does not exist in the old version of the component.



 Comments   
Comment by Benjamin Eberlei [ 14/May/11 ]

Fixed for 2.0.x aswell





[DBAL-118] When speaking about security do not rely on default link in mysql_* function calls Created: 11/May/11  Updated: 14/May/11  Resolved: 14/May/11

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

Type: Documentation Priority: Major
Reporter: Ulf Wendel Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

The documentation about escaping reads:

"Consider the previous query, now parameterized to fetch only a single article by id. Using ext/mysql (still the primary choice of MySQL access for many developers) you had to escape every value passed into the query using mysql_real_escape_string() to avoid SQL injection:

<?php
$sql = "SELECT * FROM articles WHERE id = '" . mysql_real_escape_string($id) . "'";
$rs = mysql_query($sql);",
http://www.doctrine-project.org/docs/dbal/2.0/en/reference/data-retrieval-and-manipulation.html

Please, do not rely on MySQL default links when discussing security issues. One of major differences between the mysql and the later mysqli extension is that mysqli forces users to explicitly specify a connection handle. There is no concept of default links and magical global connection handles in mysqli any more. The convenience of not having to specify a connection handle has been removed from mysqli. This was done to increase security, for example, when escaping strings. Escaping needs to take the current charset of the connection into account. Thus, it is recommended to explicitly specify the connection and so not use default connection.

"string mysql_real_escape_string ( string $unescaped_string [, resource $link_identifier ] )",
http://de.php.net/mysql_real_escape_string

Please, change the example:

<?php
$sql = "SELECT * FROM articles WHERE id = '" . mysql_real_escape_string($id, $link) . "'";
$rs = mysql_query($sql);",

($link added)

Thanks!



 Comments   
Comment by Benjamin Eberlei [ 14/May/11 ]

Changed, the new docs will be rolled up sometime this weekend.





[DBAL-115] SchemaManager doesn't quote table names for MySQL Created: 28/Apr/11  Updated: 19/Jun/11  Resolved: 19/Jun/11

Status: Resolved
Project: Doctrine DBAL
Component/s: Schema Managers
Affects Version/s: 2.0.4
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Zoran Zaric Assignee: Benjamin Eberlei
Resolution: Duplicate Votes: 1
Labels: None
Environment:

Linux Kernel 2.6.38
MySQL 5.5.11
PHP 5.3.6



 Description   

Using a reserved word as a table name only works for schema creation not dropping.

Example Enity:
/**

  • @Entity
  • @Table(name="`call`")
    */

class Call {
/**

  • @Column(name="id", type="integer", nullable=false)
  • @Id
  • @GeneratedValue(strategy="IDENTITY")
  • @var integer $id
    */
    private $id;
    }

The table name is quoted. creation works, dropping doesn't even after changing the table name to a not reserved word.



 Comments   
Comment by Benjamin Eberlei [ 19/Jun/11 ]

This problem is a little more complicated, it will be fixed in DBAL-96 probably for 2.2





[DBAL-112] Sequence alteration does not alter. Created: 26/Apr/11  Updated: 19/Jun/11  Resolved: 19/Jun/11

Status: Resolved
Project: Doctrine DBAL
Component/s: Schema Managers
Affects Version/s: 2.0.4
Fix Version/s: 2.1

Type: Bug Priority: Major
Reporter: Thomas Lundquist Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

Linux & Postgesql



 Description   

When the schema diff decides there are differences between the existing SEQUENCE and the "new" one it alters the SEQUENCE by a DROP and then a CREATE.

The CREATE is done with the fromSchema as a base which results in a no-changed SEQUENCE.

Line 102 in Doctrine/DBAL/Schema/Comparator.php uses fromSchema but shuld have been using toSchema or just $sequence

This will fix the immediate issue but still require the sequence name being the same.



 Comments   
Comment by Benjamin Eberlei [ 19/Jun/11 ]

Fixed





[DBAL-110] No way to get platform specific values from old schema to schema create sql Created: 13/Apr/11  Updated: 13/Apr/11  Resolved: 13/Apr/11

Status: Resolved
Project: Doctrine DBAL
Component/s: Schema Managers
Affects Version/s: 2.0.4
Fix Version/s: None

Type: Improvement Priority: Major
Reporter: Peter Jasiulewicz Assignee: Benjamin Eberlei
Resolution: Won't Fix Votes: 0
Labels: None
Environment:

ubuntu 10.10 with php 5.3.3



 Description   

Even if I create custom types to support non-default types in Mysql (enum,set) I cant get the values from the schema manager to the type object due to encapsulation:

type declaration
<?php
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Platforms\AbstractPlatform;

class EnumType extends Type
{
const MYTYPE = 'Enum'; /
public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform)

{ return "ENUM(HERE IS THE PROBLEM)"; }

public function getName()

{ return self::MYTYPE; }

}
?>

db connection construction:
<?php
//...

\Doctrine\DBAL\Types\Type::addType('enum', 'CustomTypes\EnumType');
$conn->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'enum');

?>

There is no way to create even an extension to better support mysql databases, and since its a pretty commonly used rdbms this issue lowers the value of Doctrine2 for mysql (since you get errors by going by the reference guide).

related issues:
http://www.doctrine-project.org/jira/browse/DBAL-4
http://www.doctrine-project.org/jira/browse/DBAL-89



 Comments   
Comment by Benjamin Eberlei [ 13/Apr/11 ]

MySQL is a common database yes, people tend to use enums yes, but enums suck! They have tons of disadvantages that far outweight the simple benefit.

There is just no way to create a generic Enum type and never will be, you can only create one enum type per class of values as described here:

http://www.doctrine-project.org/docs/orm/2.0/en/cookbook/mysql-enums.html

Comment by Peter Jasiulewicz [ 13/Apr/11 ]

Yes I understad that ENUMs aren't the best possible but since enums are internally represented as numbers not strings "Solution 1: Mapping to Varchars" makes it even worse and can result in making a database huge and slow, and botch solutions with "Solution 2: Defining a Type" pretty much renders DBAL schema tools and Migrations useless (which is the main part I wanted to use)

I'm not saying that you should follow bad practices but if Doctrine wats to be a mature tool it should be also be highly extensible. Currently it just lacks the capability to truly abstract the thing it was written to be an abstraction layer of.

cheers,
Peter

Comment by Benjamin Eberlei [ 13/Apr/11 ]

Types are flyweight instances, this makes enum support impossible. So the choice for us was, have a highly customizable type system that doesnt support enums, or throw performance to hell. We picked one.

DBAL and Migrations firstly serve the ORM, then ship with their own features, SchemaTool was never designed to support every legacy application out there.

Btw: Mapping to varchars does not make the the database huge and slow, using columnDefinition this would still be a real ENUM. Just doctrine thinks its a string (aka varchar).

Comment by Peter Jasiulewicz [ 13/Apr/11 ]

Thanks for expalining, still I wanted to use it mainly as a schema creation/comparator tool so this does'nt help much. Will migrate to doctrine when the project has matured.

Cheers,
Peter





[DBAL-121] Mapping, decimal returns float. Created: 12/Apr/11  Updated: 14/May/11  Resolved: 14/May/11

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: 2.0.3
Fix Version/s: 2.0.5

Type: Bug Priority: Major
Reporter: Tom Van Looy Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

Linux Ubuntu 10.10 x86_64, PHP 5.3.3-1ubuntu9.3, mysql Ver 14.14 Distrib 5.1.49



 Description   

I have a Doctrine 2 entity and the value is mapped like this (with regular getter/setter):

 
/**
 * @Column(type="decimal", precision=40, scale=30)
 */
protected $someValue;

/**
 * @return decimal
 */
public function getSomeValue()
{
    return $this->someValue;
}

/**
 * @param decimal $someValue
 */
public function setSomeValue($someValue)
{
    $this->someValue = $someValue;
}

When I set that value from my code, the value gets written into the database correctly. But, and that is my problem, when I get the value (via getter or \Doctrine\Common\Util\Debug::dump()), it always gives me a number with maximum 14 digits, and it rounds the value. I read the record with the default findById().

eg: with value 1234567890.012345678901234567890123456789 I have 1234567890.0123
eg: with value 890.0123456789012345678901234567890123456 I have 890.01234567890

I of course want all digits, not just 14. The field in MySQL is declared like this:

 
    someValue decimal(40,30) NOT NULL,

When I get the value with raw PHP and mysql_query(), it returns correctly.

It seems like the problem is that Doctrine returns a float: ["someValue":protected]=> float(234567890.01235)

What's wrong, what should I check next, how to fix, any clues?
(also posted on http://stackoverflow.com/questions/5635500/doctrine-2-decimal-can-only-contain-14-digits)



 Comments   
Comment by Benjamin Eberlei [ 12/Apr/11 ]

ah yes, this is a bug.

Comment by Benjamin Eberlei [ 14/May/11 ]

fixed





[DBAL-107] Graphviz Schema Visitor Created: 07/Apr/11  Updated: 07/Apr/11  Resolved: 07/Apr/11

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

Type: New Feature Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

We should include a Graphviz Schema Visitor.

Features:

  • Display Tables and Columns
  • Highlight Primary Keys
  • Connect tables through foreign keys


 Comments   
Comment by Benjamin Eberlei [ 07/Apr/11 ]

Implemented





[DBAL-92] Timezones of DateTime instances are ignored when persisting dates Created: 16/Feb/11  Updated: 26/Feb/11  Resolved: 26/Feb/11

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

Type: Bug Priority: Major
Reporter: Bernhard Schussek Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None


 Description   

When a DateTime instance, e.g. "2011-02-16 00:00:00 America/New_York" is written into the DB, the timezone is ignored and only "2011-02-16" is persisted. When fetching the date, it is written into a DateTime with the server's timezone, resulting in for example "2011-02-16 00:00:00 Europe/Berlin" which is not correct!

To fix this issue, Doctrine should convert dates to the server's timezone (if their own timezone differs) before persisting them or before executing queries containing DateTime instances.



 Comments   
Comment by Benjamin Eberlei [ 26/Feb/11 ]

This would magically change the state of any DateTime instance upon "convertToDatabaseValue", i think this would be equally weird so better no changes at all.





[DBAL-88] MySqlPlatform not escaping table names Created: 10/Feb/11  Updated: 26/Feb/11  Resolved: 26/Feb/11

Status: Resolved
Project: Doctrine DBAL
Component/s: Platforms
Affects Version/s: 2.0
Fix Version/s: 2.0.2, 2.1

Type: Bug Priority: Major
Reporter: James Reed Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None

Attachments: File MySqlPlatform.php    
Issue Links:
Duplicate
duplicates DBAL-91 orm:convert-mapping SchemaException o... Resolved

 Description   

Methods in the MySql Platform that use the table name are not escaping the table name. This causes problems when your table name is the same as a reserved word in MySql. Example:

public function getListTableConstraintsSQL($table)

{ return 'SHOW INDEX FROM ' . $table; }

If my table name is User this method will fail and cause a SQL error because the word User is a reserved word in MySql. You need to escape the table name with backticks to prevent these errors. Example:

public function getListTableConstraintsSQL($table)

{ return 'SHOW INDEX FROM `' . $table . '`'; }

I encountered this problem while reverse engineering my existing MySql database. I've attached a fixed version that solved my reverse engineering problems.



 Comments   
Comment by Benjamin Eberlei [ 11/Feb/11 ]

Duplicate of DDC-976

Comment by Benjamin Eberlei [ 12/Feb/11 ]

This issue is not a duplicate, only related to DBAL-91.

Comment by Benjamin Eberlei [ 26/Feb/11 ]

Fixed





[DBAL-89] MySqlPlatform does not handle enum and set data types Created: 10/Feb/11  Updated: 10/Feb/11  Resolved: 10/Feb/11

Status: Resolved
Project: Doctrine DBAL
Component/s: Platforms
Affects Version/s: 2.0
Fix Version/s: None

Type: Bug Priority: Major
Reporter: James Reed Assignee: Benjamin Eberlei
Resolution: Won't Fix Votes: 0
Labels: None

Attachments: File MySqlPlatform.php    

 Description   

If you do a reverse engineer of an existing database that includes enum and set columns the reverse engineer will fail. Ideally there could be a separate Doctrine type for these fields, but at a minimum it seems they should be treated as string values. I solved my reverse engineering problem by modifying the initializeDoctrineTypeMappings in the MySqlPlatform.php file (attached):

protected function initializeDoctrineTypeMappings()

{ $this->doctrineTypeMapping = array( 'tinyint' => 'boolean', 'smallint' => 'smallint', 'mediumint' => 'integer', 'int' => 'integer', 'integer' => 'integer', 'bigint' => 'bigint', 'tinytext' => 'text', 'mediumtext' => 'text', 'longtext' => 'text', 'text' => 'text', 'varchar' => 'string', 'string' => 'string', 'char' => 'string', 'date' => 'date', 'datetime' => 'datetime', 'timestamp' => 'datetime', 'time' => 'time', 'float' => 'float', 'double' => 'float', 'real' => 'float', 'decimal' => 'decimal', 'numeric' => 'decimal', 'year' => 'date', 'enum' => 'string', 'set' => 'string', ); }

 Comments   
Comment by Benjamin Eberlei [ 10/Feb/11 ]

There is a method on the platform "regsiterDoctrineMappingType" that modifies this array.

Enums and Sets cannot be generically supported by architectural choice.

Comment by James Reed [ 10/Feb/11 ]

Ah, didn't know about the regsiterDoctrineMappingType. Good solution. Thanks!

Comment by James Reed [ 10/Feb/11 ]

Actually, after searching the code the method is "registerDoctrineTypeMapping"





[DBAL-85] Illegal quotes in SHOW FULL TABLES WHERE Table_type = "BASE TABLE" Created: 04/Feb/11  Updated: 11/Feb/11  Resolved: 11/Feb/11

Status: Resolved
Project: Doctrine DBAL
Component/s: Platforms
Affects Version/s: None
Fix Version/s: 2.0.2

Type: Bug Priority: Major
Reporter: Karsten Dambekalns Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None

Attachments: Text File base_table.patch    
Issue Links:
Duplicate
is duplicated by DDC-1019 Double quotation mark mysql query err... Resolved

 Description   

When trying to generate update SQL on MySQL running in ANSI SQL mode you get the error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'BASE TABLE' in 'where clause'

This is caused by the use of identifier quotes (") instead of literal quotes (') in the query
SHOW FULL TABLES WHERE Table_type = "BASE TABLE"

This is in MySqlPlatform#getListTablesSQL()



 Comments   
Comment by Bernhard Schlas [ 07/Feb/11 ]

Here is a temporary dirty patch for this problem. ONLY FOR TESTING PURPOSE!!!

Comment by Karsten Dambekalns [ 08/Feb/11 ]

Why not simply change MySqlPlatform#getListTablesSQL()?

Comment by Bernhard Schlas [ 08/Feb/11 ]

Because did this quick and dirty patch before i read this issue. Actually i've attached a better one,

Comment by Karsten Dambekalns [ 09/Feb/11 ]

With this change it works for me.

Comment by Benjamin Eberlei [ 11/Feb/11 ]

Fixed.





[DBAL-84] Long string fields are being silently changed to 255 characters in the schema Created: 31/Jan/11  Updated: 20/Feb/11  Resolved: 20/Feb/11

Status: Resolved
Project: Doctrine DBAL
Component/s: Schema Managers
Affects Version/s: 2.0, 2.0.1
Fix Version/s: 2.0.2, 2.1

Type: Bug Priority: Major
Reporter: Oleg Anashkin Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

I have an entity like this:

/**
 * @orm:Entity
 */
class Product
{
    /**
     * @orm:Id
     * @orm:Column(name="Merchant",type="string",length=50)
     */
    protected $merchant;

    /**
     * @orm:Column(name="Name",type="string",length=500)
     */
    protected $name;
}

When I change the length of $name field to 4000 it updates the schema like it is supposed to:

php.exe -f console doctrine:schema:update --dump-sql
ALTER TABLE product CHANGE Name Name VARCHAR(4000) NOT NULL

But when I change the length to 5000 it just silently without any warning uses value 255 instead:

php.exe -f console doctrine:schema:update --dump-sql
ALTER TABLE product CHANGE Name Name VARCHAR(255) NOT NULL

I had to look into actual table definition using mysql browser to find this issue because doctrine doesn't even warn about it. This could lead to some pretty serious bugs!



 Comments   
Comment by Benjamin Eberlei [ 20/Feb/11 ]

Fixed in master and 2.0.x





[DBAL-83] BigInt Type is returning string instead of integer Created: 28/Jan/11  Updated: 14/May/11  Resolved: 14/May/11

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

Type: Bug Priority: Major
Reporter: Miloslav "adrive" Kmet Assignee: Benjamin Eberlei
Resolution: Won't Fix Votes: 0
Labels: None


 Description   

I ran all tests with PostgreSQL and I got an error:

1) Doctrine\Tests\DBAL\Functional\TypeConversionTest::testIdempotentDataConversion with data set #3 ('bigint', 12345678, 'string')
The expected type from the conversion to and back from the database should be string
Failed asserting that <integer:12345678> is of type "string".

/usr/share/php/Doctrine2/dbal/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php:84

FAILURES!
Tests: 367, Assertions: 745, Failures: 1, Skipped: 8.

The BigInt Type is missing convertToPHPValue() method and returns string instead of int. I fixed this and also I fixed the test case for this. Patch will be availabe via github pull request.



 Comments   
Comment by Benjamin Eberlei [ 14/May/11 ]

Bigints have to be strings for int overflow reasons. PostgreSQL seems to detect 64 vs 32bit systems and casts correctly, this is unfortunate for the tests, i have to come up with a workdaround for this





[DBAL-82] orderBy(), setFirstResult() bug with MSSQL Server Created: 16/Jan/11  Updated: 31/Jul/11  Resolved: 31/Jul/11

Status: Resolved
Project: Doctrine DBAL
Component/s: Platforms
Affects Version/s: 2.0
Fix Version/s: 2.0.7, 2.1.1

Type: Bug Priority: Major
Reporter: Aaron DM Assignee: Juozas Kaziukenas
Resolution: Fixed Votes: 1
Labels: None
Environment:

Windows 7, Apache2, PHP 5.3.5, Microsoft SQL Server 2008



 Description   
QueryBuilder
		$query = $this->createQueryBuilder('account')
					  ->select('account')
					  ->orderBy('account.id', 'DESC')
					  ->getQuery();

                $result = $query->setMaxResults($this->resultsPerPage+1)
        							->setFirstResult($this->offset)
        							->getResult();

The above, when using "setFirstResult" and "orderBy" (like that), results in an error like so:

SQLSTATE[42000]: [Microsoft][SQL Server Native Client 10.0][SQL Server]The multi-part identifier "t0_.id" could not be bound.

With a statement that looks something like so:

WITH outer_tbl AS (SELECT ROW_NUMBER() OVER (ORDER BY t0_.id DESC) AS "doctrine_rownum",   ...

The reason the error is occurring is because you apparently need to use the "alias" (e.g, SELECT t0_.id AS id0) "id0" in the "ORDER BY" clause.

So query will run with no problems if t0_.id as id0

WITH outer_tbl AS (SELECT ROW_NUMBER() OVER (ORDER BY id0 DESC) AS "doctrine_rownum",   ...

It looks like this behavior might only occur with Microsoft SQL Server, but it is a bug.

---------------

If you go into:
Doctrine\DBAL\Platforms\MsSqlPlatform

Find:

$over = preg_replace('/\"[^,]*\".\"([^,]*)\"/i', '"inner_tbl"."$1"', $orderby);

Add before:

                    # Get Columns
                    $columns = array();
                    if(preg_match_all('/([a-zA-Z][0-9]+_\.[a-zA-Z0-9\-_]+)\sAS\s([a-zA-Z0-9\-\_]+)/', $query, $matched)) {
                        for($i=0; $i<count($matched[1]); ++$i)
                        {
                            $columns[$matched[1][$i]] = $matched[2][$i];
                        }
                    }
                    
                    # Replace columns with their alias in the "orderby" statement
                    if(preg_match_all('/([a-zA-Z][0-9]+_\.[a-zA-Z0-9\-_]+)\s/i', $orderby, $matches)) {
                        foreach($matches[1] as $column) 
                        {
                            $orderby = preg_replace('/'.$column.'/', $columns[$column], $orderby);
                        }
                    }

Obviously this is a really ugly hack, but this resolves it.



 Comments   
Comment by Aaron DM [ 16/Jan/11 ]

Added the ugly hack fix.

Comment by Benjamin Eberlei [ 23/Jan/11 ]

Assigned to Juozas.

Comment by Minxuan GUO [ 05/May/11 ]

Thanks Aaron DM

Your code works perfectly

Comment by Jean-Marc Fontaine [ 20/Jun/11 ]

I am experiencing this bug too. Is there a way to get it fixed anytime soon? Maybe in the 2.1 release.

Comment by Aaron DM [ 24/Jun/11 ]

Here is what I think, a proper fix for this.

I re-wrote the query however it works the same and is pretty much the exact same in performance (from couple of tests I've done looking at profiler) + it fixes the issues regarding this ticket.

    /**
     * Adds an adapter-specific LIMIT clause to the SELECT statement.
     *
     * @param string $query
     * @param mixed $limit
     * @param mixed $offset
     * @link http://lists.bestpractical.com/pipermail/rt-devel/2005-June/007339.html
     * @return string
     */
    protected function doModifyLimitQuery($query, $limit, $offset = null)
    {
        if ($limit > 0) {
            $count = intval($limit);
            $offset = intval($offset);

            if ($offset < 0) {
                throw new DBALException("LIMIT argument offset=$offset is not valid");
            }

            if ($offset == 0) {
                $query = preg_replace('/^SELECT\s/i', 'SELECT TOP ' . $count . ' ', $query);
            } else {
                $orderby = stristr($query, 'ORDER BY');

                if (!$orderby) {
                    $over = 'ORDER BY (SELECT 0)';
                } else {
                    $over = preg_replace('/\"[^,]*\".\"([^,]*)\"/i', '"inner_tbl"."$1"', $orderby);
                }

                // Remove ORDER BY clause from $query
                $query = preg_replace('/\s+ORDER BY(.*)/', '', $query);
                $query = preg_replace('/SELECT\s/', '', $query);

                $start = $offset + 1;
                $end = $offset + $count;

                // Limit query
                $query = "SELECT * FROM (SELECT ROW_NUMBER() OVER ($over) AS \"doctrine_rownum\", $query) AS doctrine_tbl WHERE \"doctrine_rownum\" BETWEEN $start AND $end";
            }
        }

        return $query;
    }

I had found this query a long time ago and found it to be fairly fast, however I'm not sure where exactly I found it.
I'm going to take a guess and assume it might be this comment:
http://josephlindsay.com/archives/2005/05/27/paging-results-in-ms-sql-server/comment-page-1/#comment-28594

Comment by Aaron DM [ 24/Jun/11 ]

Pull request: https://github.com/doctrine/dbal/pull/37

Comment by Benjamin Eberlei [ 31/Jul/11 ]

Fixed, merged pull request





[DBAL-91] orm:convert-mapping SchemaException on Postgres reserved words Created: 10/Jan/11  Updated: 12/Feb/11  Resolved: 12/Feb/11

Status: Resolved
Project: Doctrine DBAL
Component/s: Schema Managers
Affects Version/s: 2.0
Fix Version/s: 2.0.2, 2.1

Type: Bug Priority: Major
Reporter: Emil Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

CentOs 5.5, Postgres 8.1.22


Attachments: File test-creation.sql    
Issue Links:
Duplicate
is duplicated by DBAL-88 MySqlPlatform not escaping table names Resolved

 Description   

While execuiting

doctrine orm:convert-mapping --from-database yml /tmp/test.yml

I get presented an error

[Doctrine\DBAL\Schema\SchemaException]
Invalid index-name tablename_"input"_idx given, has to be [a-zA-Z0-9_]

The index "type" is quoted because this is a reserved word in Postgres. for example see the following definition:

FOREIGN KEY (something) REFERENCES somethings(id) ON UPDATE CASCADE
FOREIGN KEY (another) REFERENCES anothers(id) ON UPDATE CASCADE
FOREIGN KEY ("type") REFERENCES logtypes(id) ON UPDATE CASCADE

Only type will be quoted because it is a reserved word.



 Comments   
Comment by Benjamin Eberlei [ 10/Jan/11 ]

You have to quote with `` in Doctrine. That is translated to the underyling vendor quotation signs.

Comment by Emil [ 10/Jan/11 ]

@benjamin this considers a mapping error from database (Postgres) to YAML through the doctrine commandline tool, I do not think your comment is relevant for this issue.

Comment by Benjamin Eberlei [ 11/Jan/11 ]

@Emil it is, are you quoting the reserved word in the YML file using `` ? DBAL has some logic to fix escaping in these cases.

Comment by Emil [ 11/Jan/11 ]

@benjamin uhm, I might be baffled with the complexity of Doctrine or just plain wrong. But I'm trying to create a YML file from my database. How can I be making a mistake in the YML file with quotes?

The error message is presented because the Dcotrine ORM module tries to generate index names on columns, based on the database schema, but fails because the returned names (from the database schema) contain quotes (because they are reserved words).

Comment by Benjamin Eberlei [ 11/Jan/11 ]

Sorry, now i get it. I didnt relaize the usecase you were applying. Yes you are right

Comment by Benjamin Eberlei [ 23/Jan/11 ]

Can you give me an Example Postgresql Schema with DDL SQL that produces this error?

Comment by Emil [ 10/Feb/11 ]

These are the table creation for a test table which is able to reproduce the error.

Comment by Emil [ 10/Feb/11 ]

I hope this is enough information. The attached SQL reproduces the following error:

  1. doctrine orm:convert-mapping --from-database yml /tmp/test.yml

[Doctrine\DBAL\Schema\SchemaException]
Invalid index-name something_"input"_idx given, has to be [a-zA-Z0-9_]

orm:convert-mapping [--filter="..."] [--from-database] [-extend[="..."]] [-num-spaces[="..."]] [-h|--help] [-q|--quiet] [-v|--verbose] [-V|--version] [-a|--ansi] [-n|--no-interaction] command to-type dest-path

Comment by Benjamin Eberlei [ 12/Feb/11 ]

I can't reproduce it

Can you run the command with --verbose ? Additionally in lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php can you var_dump() $metadata after line 119?

Comment by Benjamin Eberlei [ 12/Feb/11 ]

Ok i could reproduce it now. Input is not a keyword for me though, type also not. Coudl reproduce it with "table"

Comment by Benjamin Eberlei [ 12/Feb/11 ]

Ok, this is a DBAL issue.

Comment by Benjamin Eberlei [ 12/Feb/11 ]

This is fixed and will be included in 2.0.2





[DBAL-79] Add Schema\Table::hasPrimaryKey method Created: 30/Dec/10  Updated: 26/Feb/11  Resolved: 26/Feb/11

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

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


 Description   

Currently the name of the primary key is internal to the Table instance so there is no way to check if the table has a primary key without getting all the indexes and iterating over them.



 Comments   
Comment by Benjamin Eberlei [ 26/Feb/11 ]

This is fixed in trunk.





[DBAL-78] Native support for parameter lists Created: 24/Dec/10  Updated: 05/Mar/11  Resolved: 05/Mar/11

Status: Resolved
Project: Doctrine DBAL
Component/s: Drivers
Affects Version/s: None
Fix Version/s: 2.1

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


 Description   

Prerequisites:

1. Detection of this mode has to be super-fast. It should not have an auto-detection but should be triggered explicitly.
2. This mode cannot be supported after $conn->prepare(). It is only viable for $conn->executeQuery() or $conn->executeUpdate().

Case 1: Positional

$stmt = $conn->executeQuery("SELECT a.id FROM articles a WHERE a.id IN (?) AND a.foo = ?",
    array($paramList, $foo), array( Connection::PARAM_ARRAY => PDO::PARAM_INT) , PDO:PARAM_STR ),
    Connection::FLAG_EXPAND_ARRAYS
);

Would internally, right before execution, be rewritten to:

$c = count($paramList); // 3!
"SELECT a.id FROM articles a WHERE a.id IN (?, ?, ?) AND a.foo = ?"

Case 2: Named

$stmt = $conn->executeQuery("SELECT a.id FROM articles a WHERE a.id IN (:id) AND a.foo = :bar",
    array('id' => $paramList, 'bar' => $foo),
    array( array(Connection::PARAM_ARRAY => PDO::PARAM_INT), PDO::PARAM_STR ),
    Connection::FLAG_EXPAND_ARRAYS
);

Would internally, right before execution, be rewritten to:

$c = count($paramList); // 3!
"SELECT a.id FROM articles a WHERE a.id IN (:id1, :id2, :id3) AND a.foo = :bar"


 Comments   
Comment by Benjamin Eberlei [ 05/Mar/11 ]

Implementing this for Named parameters is not really possible without re-parsing the query after every replacement just because the named parameters can occur more then once and this messes with the positions.

Comment by Benjamin Eberlei [ 05/Mar/11 ]

Using arrays as param list is a very bad idea performance wise (and also code handling).

Algorithm now:

1. New Constants Connection::PARAM_INT_ARRAY and PARAM_STR_ARRAY, being apart by Connection::ARRAY_TYPE_OFFSET from their PDO::PARAM_STR and PDO:PARAM_INT plain values.
2. Detect if there is one _ARRAY param. If not abort expansion (complexity O(T)) where T is the number of types.
3. Parse SQL statement for positional needle => character position
4. Iterate param list and inline arrays values

Comment by Benjamin Eberlei [ 05/Mar/11 ]

Implemented in https://github.com/doctrine/dbal/commit/df50f44a179028a3e30dcab02cd3ff33cc4f8498





[DBAL-74] OracleSchemaManager - incorrectly detected the length of the string columns Created: 07/Dec/10  Updated: 12/Dec/10  Resolved: 12/Dec/10

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: 2.0.0-RC1-RC3
Fix Version/s: 2.0-RC5

Type: Bug Priority: Major
Reporter: Miloslav "adrive" Kmet Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

When I create a VARCHAR2 column with the length specified in char units (VARCHAR2(10 CHAR)) instead of the default byte, the metadata stored in all_tab_columns -> data_length is not 10, but 40. It is better to use char_length instead of data_length. Char_length is the same wheter the size unit is in CHAR or BYTE.

It is neccessary for me to use CHAR instead of the default BYTE, because I am using unicode charset.



 Comments   
Comment by Miloslav "adrive" Kmet [ 07/Dec/10 ]

https://github.com/milokmet/dbal/commit/a5087e8e229bfd2cde947e1d387ebe2e2b122b85

Comment by Benjamin Eberlei [ 07/Dec/10 ]

Can I appoint you to Doctrine's Oracle specialist?

Thank you very much, I will merge that as soon as i have time.

Comment by Benjamin Eberlei [ 12/Dec/10 ]

Merged





[DBAL-73] Could not convert database value "b:0;" to Doctrine Type object Created: 06/Dec/10  Updated: 12/Dec/10  Resolved: 12/Dec/10

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: 2.0.0-RC1-RC3
Fix Version/s: 2.0-RC5

Type: Bug Priority: Major
Reporter: Marcus Speight Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None

Attachments: File Setting.php    

 Description   

The following class when value is set to false causes "Could not convert database value "b:0;" to Doctrine Type object" exception when loading the entity.

/** @orm:Entity */
class MyClass
{
/**

  • @orm:Column(name="value", type="object")
    */
    public $value;
    }


 Comments   
Comment by Benjamin Eberlei [ 06/Dec/10 ]

From the PHP manual about unserialize():

In case the passed string is not unserializeable, FALSE is returned and E_NOTICE is issued. 

The solution: Use NULL instead of false

Comment by Marcus Speight [ 06/Dec/10 ]

But the string "b:0;" is unserializable it returns false. Also from the php manual on unserialize

FALSE is returned both in the case of an error and if unserializing the serialized FALSE value. 
It is possible to catch this special case by comparing str with serialize(false) or by catching the issued E_NOTICE. 

I've submitted a pull request that handles it correctly.

Comment by Benjamin Eberlei [ 06/Dec/10 ]

I know, but this type is called "object", so setting it to false makes no sense. Setting it to null makes sense though.

I know that b:0; is false, but why do you set it to false anyways? Objects are either null or an instance of the object. Never false.

Comment by Marcus Speight [ 06/Dec/10 ]

I'm storing settings in a database. using a Namespace, Key => Value triplet. I don't know what might be stored in the value part. Currently strings, NULL and boolean data are stored. Using object seem to be the best approach. (ArrayTypes have the same problem).

If you think a different type would be better then please let me know.

Comment by Benjamin Eberlei [ 06/Dec/10 ]

how is such a triplet only b:0; ? or is your entity the tripplet and the variable that fails is the value?

Comment by Marcus Speight [ 06/Dec/10 ]

I've added my entity. The entity is the triplet. And it is the value that fails if false is stored.
It allows me to store the value(false) but the throws an exception on loading the entity. It should allow the loading of the value(false) or disallow the storing of a false value.

Comment by Benjamin Eberlei [ 12/Dec/10 ]

Although this should really be just array and object, not strange false types i added this patch to prevent future reports of this as a problem. The loosely typed language PHP can go with null or false, so why throw people stones in their way.





[DBAL-72] doctrine entities generation has a bug for OneToMany setter type Created: 06/Dec/10  Updated: 12/Dec/10  Resolved: 12/Dec/10

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: 2.0.0-BETA4
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Amaury Leroux de Lens Assignee: Benjamin Eberlei
Resolution: Won't Fix Votes: 0
Labels: None
Environment:

Apache2 + PHP5.3.3 on macosx (via macport)



 Description   

http://trac.symfony-project.org/ticket/9272

assuming i've this model :

class TaskList

{ /** *@Id *@Column(type="integer") *@GeneratedValue(strategy="AUTO") */ private $id; /** *@Column(type="string", length="255") */ protected $name; /** *@OneToMany(targetEntity="Task", mappedBy="TaskList") */ protected $Tasks; }

AND

class Task{

/**
*@Id
*@Column(type="integer")
*@GeneratedValue?(strategy="AUTO")
*/
protected $id;

/**
*@Column(type="string", length="255")
*@Validation(

{ @NotBlank }

)
*/
protected $name;

/**
*@Column(type="boolean")
*/
protected $done = false;

/**
*@ManyToOne(targetEntity="TaskList", inversedBy="Tasks")
*@JoinColumn(name="task_list_id", referencedColumnName="id")
*/
protected $TaskList;

}

in symfony2

the ./console doctrine:generate:entities will create a setter in each class :

public function setTaskList(\TaskList $taskList) {
$this->TaskList = $taskList;
}

AND

public function addTasks(\Task $tasks) {
$this->Tasks[] = $tasks;
}

the " \ " before the setter function's parameter type is wrong here we should have

public function setTaskList(TaskList $taskList) {
$this->TaskList = $taskList;
}

AND

public function addTasks(Task $tasks) {
$this->Tasks[] = $tasks;
}

this lead ./console doctrine:generate:proxies to throw a hardly understandable error:

[ReflectionException]
Class Bundle\ToDoListBundle\Entity\TaskList does not exist

if you typed

/**
*@OneToMany?(targetEntity="\Bundle\myBundle\Entity\Task", mappedBy="TaskList?")
*/

the doctrine:generate:entities do not create this problem.
(my apologizes for inacurrate english)



 Comments   
Comment by Benjamin Eberlei [ 06/Dec/10 ]

This was fixed in the RC1 release. Can you verify this bug does not occour with RC1 anymore?

Comment by Amaury Leroux de Lens [ 06/Dec/10 ]

i'll do asap,
was just migrating this issue from symfony2 trac

Comment by Benjamin Eberlei [ 12/Dec/10 ]

Closed, no feedback and this issue was fixed with RC1.





missing column type "float" (DBAL-41)

[DBAL-70] MySql Platform is missing FloatType mappings Created: 02/Dec/10  Updated: 12/Dec/10  Resolved: 12/Dec/10

Status: Resolved
Project: Doctrine DBAL
Component/s: Platforms
Affects Version/s: 2.0.0-RC1-RC3
Fix Version/s: 2.0-RC4

Type: Sub-task Priority: Major
Reporter: Steffen Vogel Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

All other platforms are mapping double precission columns to the FloatType type. MySql not...

https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php



 Comments   
Comment by Benjamin Eberlei [ 12/Dec/10 ]

This was fixed in RC4.





[DBAL-67] OCI8: schema-tool:update is modifying not null boolean - NUMBER(1) columns to not null Created: 24/Nov/10  Updated: 29/Nov/10  Resolved: 29/Nov/10

Status: Resolved
Project: Doctrine DBAL
Component/s: Schema Managers
Affects Version/s: 2.0.0-RC1-RC3
Fix Version/s: 2.0-RC4

Type: Bug Priority: Major
Reporter: Miloslav "adrive" Kmet Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

Oracle - Oci8



 Description   

When I have a boolean column(s) in my entities and I want to update schema with schema tool, I get an exception:

My entity:

/** @Entity @Table(name='st_node') */
class Node
{
    /** @Id @Column(type="integer") @GeneratedValue */
    protected $id;
    
    /** @Column(type="string", length="255") */
    protected $title;
    
    /** @Column(type="boolean", nullable=false) */
    protected $is_published;
    
    /** @Column(type="boolean") */
    protected $is_sticky;
    
    /** @Column(type="integer", length=4) */
    protected $hits;
    
    /** @Column(type="decimal", precision=4, scale=2) */
    protected $score;
}
./doctrine orm:schema-tool:update --force
Entities\Address
Entities\Node
Entities\Article
Entities\User
Entities\Page
Updating database schema...

  [Doctrine\DBAL\Driver\OCI8\OCI8Exception]                         
  ORA-01442: column to be modified to NOT NULL is already NOT NULL  
            

The same with --dump-sql option:

./doctrine orm:schema-tool:update --dump-sql
Entities\Address
Entities\Node
Entities\Article
Entities\User
Entities\Page
ALTER TABLE ST_NODE MODIFY (is_published  NUMBER(1) NOT NULL, is_sticky  NUMBER(1) NOT NULL)

The columns are already not nulls, but schema-tool can't recognize that.

This is the DQL of the table:

CREATE TABLE "DOCTRINE"."ST_NODE"
  (
    "ID"           NUMBER(10,0) NOT NULL ENABLE,
    "TITLE"        VARCHAR2(255 BYTE) NOT NULL ENABLE,
    "DISCR"        VARCHAR2(255 BYTE) NOT NULL ENABLE,
    "IS_PUBLISHED" NUMBER(1,0) NOT NULL ENABLE,
    "HITS"         NUMBER(10,0) NOT NULL ENABLE,
    "SCORE"        NUMBER(4,2) NOT NULL ENABLE,
    "IS_STICKY"    NUMBER(1,0) NOT NULL ENABLE,
    PRIMARY KEY ("ID")
);


 Comments   
Comment by Miloslav "adrive" Kmet [ 24/Nov/10 ]

Fixed in https://github.com/milokmet/dbal/commits/DBAL-67

Comment by Benjamin Eberlei [ 27/Nov/10 ]

Btw, with regard to the comment on the Fix on your repository.

What has the commit to do with the NULL / NOT NULL issue? it seems the changes are entirely unrelated to this?

Comment by Miloslav "adrive" Kmet [ 29/Nov/10 ]

Hi Benjamin, No the changes are not unrelated to this, but I discover, what the problem was.

The problem was, thet the changed function didn't map correctly the database column types to the doctrine's types.

Therefor, when I have is_published column of doctrine's boolean type, it is mapped to oracle's NUMBER(1), but when I want to update the schema, doctrine schema managers thinks, that existing column in the database is integer with precision 1, and tries to modify the column to boolean -> number(1), but the column already is number(1) and oracle complains.

The same is also with bigint and smallint.

Comment by Benjamin Eberlei [ 29/Nov/10 ]

Fixed





[DBAL-177] Have Schema Assets handle "foo.bar" syntax correctly. Created: 31/Oct/11  Updated: 16/Nov/11  Resolved: 16/Nov/11

Status: Resolved
Project: Doctrine DBAL
Component/s: Schema Managers
Affects Version/s: 2.1.3
Fix Version/s: 2.2
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None





[DBAL-176] DBAL logging doesnt work correctly with Prepared Statements Created: 29/Oct/11  Updated: 30/Oct/11  Resolved: 30/Oct/11

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: 2.1.3
Fix Version/s: 2.2
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None





[DBAL-173] PDO Exception 17 database schema has changed Created: 28/Sep/11  Updated: 29/Jul/12  Resolved: 29/Jul/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: 2.1.3
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Mathieu Rochette Assignee: Benjamin Eberlei
Resolution: Won't Fix Votes: 0
Labels: None
Environment:

PHP 5.3 / SQLITE



 Description   

in a script initializing a database (creating tables and inserting rows into) i have this exception :

PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 17 database schema has changed' in /home/mathieu/projects/no-pair/library/vendor/doctrine2/lib/vendor/doctrine-dbal/lib/Doctrine/DBAL/Connection.php:618
Stack trace:
#0 /home/mathieu/projects/no-pair/library/vendor/doctrine2/lib/vendor/doctrine-dbal/lib/Doctrine/DBAL/Connection.php(618): PDO->query('SELECT name FRO...')
#1 /home/mathieu/projects/no-pair/library/vendor/doctrine2/lib/vendor/doctrine-dbal/lib/Doctrine/DBAL/Connection.php(571): Doctrine\DBAL\Connection->executeQuery('SELECT name FRO...', Array)
#2 /home/mathieu/projects/no-pair/library/vendor/doctrine2/lib/vendor/doctrine-dbal/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php(198): Doctrine\DBAL\Connection->fetchAll('SELECT name FRO...')
#3 /home/mathieu/projects/no-pair/library/vendor/doctrine2/lib/vendor/doctrine-dbal/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php(210): Doctrine\DBAL\Schema\AbstractSchemaManager->listTableNames()
#4 /home/mathieu/projects/no-pa in /home/mathieu/projects/no-pair/library/vendor/doctrine2/lib/vendor/doctrine-dbal/lib/Doctrine/DBAL/Connection.php on line 618

it's working well with mysql or postgresql.

I don't think it's up to the developper using doctrine to take care of this probem.

As I understand it, when this error happend doctrine should "check for this error and re-execute the query as necessary." ( https://bugs.php.net/bug.php?id=43942 )

apparently it could also be solved in pdo_sqlite by using sqlite3_prepare_v2 instead of sqlite3_prepare. maybe I should fill a bug here too

I'll provide a script reproducing the problem asap
but I don't know if it's better to solve it in doctrine or in pdo-sqlite



 Comments   
Comment by Benjamin Eberlei [ 14/Mar/12 ]

ARe you using two pdo connections in this initialization script?

Comment by Lukas Kahwe [ 19/Jul/12 ]

we seem to be experiencing the same issue https://github.com/jackalope/jackalope-doctrine-dbal/pull/46#discussion_r1185862

Comment by Benjamin Eberlei [ 29/Jul/12 ]

Its up to the developer to fix this issue imho, there is no way for Doctrine to solve this issue generically without making the code overly complex.

The use-case is rather minimal, running a testsuite and changing the db schema using more than one connection in the same request. I don't think we should change the core for this.





[DBAL-174] Table without index Created: 29/Sep/11  Updated: 09/Jan/12  Resolved: 09/Jan/12

Status: Resolved
Project: Doctrine DBAL
Component/s: Platforms, Schema Managers
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Romulo Prandini Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

Ubuntu 10.10, php 5.3, Sql Server 2008 (FreeTDS)



 Description   

The /Doctrine/DBAL/Schema/AbstractSchemaManager->listTableIndexes() method returns SQL, that causes the following error:

PDOException: SQLSTATE[IMSSP]: The active result for the query contains no fields. in C:\wamp\www\pemtic2.0\lib\Doctrine\DBAL\Connection.php on line 571
Call Stack

  1. Time Memory Function Location
    1 0.0004 379552 {main}

    ( ) ..\postInstall.php:0
    2 0.0297 3860720 Doctrine\ORM\Mapping\ClassMetadataFactory->getMetadataFor( ) ..\postInstall.php:25
    3 0.0297 3860840 Doctrine\ORM\Mapping\ClassMetadataFactory->loadMetadata( ) ..\ClassMetadataFactory.php:177
    4 0.0331 4270440 Doctrine\ORM\Mapping\Driver\DatabaseDriver->loadMetadataForClass( ) ..\ClassMetadataFactory.php:281
    5 0.0331 4270552 Doctrine\ORM\Mapping\Driver\DatabaseDriver->reverseEngineerMappingFromDatabase( ) ..\DatabaseDriver.php:154
    6 5.9540 5021400 Doctrine\DBAL\Schema\AbstractSchemaManager->listTableDetails( ) ..\DatabaseDriver.php:116
    7 6.4029 5029072 Doctrine\DBAL\Schema\MsSqlSchemaManager->listTableIndexes( ) ..\AbstractSchemaManager.php:231
    8 6.5440 5029360 Doctrine\DBAL\Connection->fetchAll( ) ..\MsSqlSchemaManager.php:182
    9 6.6588 5031120 PDOStatement->fetchAll( ) ..\Connection.php:571



 Comments   
Comment by Benjamin Eberlei [ 09/Jan/12 ]

This was fixed in 2.1 somewhen.





[DBAL-170] Add mysqli driver Created: 25/Sep/11  Updated: 21/Nov/11  Resolved: 21/Nov/11

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: 2.2
Security Level: All

Type: New Feature Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

Add a mysqli driver



 Comments   
Comment by Benjamin Eberlei [ 21/Nov/11 ]

Implemented





[DBAL-172] QueryBuilder joins are omitted if the table alias is not present in the "from" clause Created: 26/Sep/11  Updated: 30/Oct/11  Resolved: 30/Oct/11

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: 2.1
Fix Version/s: 2.1.5
Security Level: All

Type: Bug Priority: Major
Reporter: Anush Ramani Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

MySQL



 Description   

When using the QueryBuilder, joins that refer to table aliases from other joins get omitted. Only those joins that refer to table aliases from the "from" clause get included.

See http://stackoverflow.com/questions/7331117/doctrines-dbal-query-builder-omitts-some-joins



 Comments   
Comment by Anush Ramani [ 27/Sep/11 ]

Just realized that there is a way to solve the issue with omitted joins. Essentially, we'd always need to use one of the FROM table aliases as the $fromAlias for the join() methods. While this works quite well, it seems un-intuitive.

If this is expected behavior, I can close the ticket, but again, seems a bit un-intuitive.

Comment by Benjamin Eberlei [ 30/Oct/11 ]

fixed.

An exception is now thrown when this occurs with details on how to fix it.





[DBAL-169] PostgreSQL Session init Created: 24/Sep/11  Updated: 24/Sep/11  Resolved: 24/Sep/11

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: 2.2
Security Level: All

Type: New Feature Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

During PostgreSQL Session init it may be interesting to set the search path to a different value than the default.



 Comments   
Comment by Benjamin Eberlei [ 24/Sep/11 ]

Implemented a generic SQLSessionInit listener that executes a single sql command after connection initializtion.

Example usage:

$evm->addEventListener(new SQLSessionInit("SET SEARCH_PATH TO foo, public, TIMEZONE TO 'Europe/Berlin'"));
$conn = DriverManager::getConnection($params, $config $evm);




[DBAL-166] Table Encoding on generation table creation query Created: 14/Sep/11  Updated: 01/Apr/12  Resolved: 01/Apr/12

Status: Resolved
Project: Doctrine DBAL
Component/s: Schema Managers
Affects Version/s: 2.1.2
Fix Version/s: 2.3
Security Level: All

Type: Bug Priority: Major
Reporter: Punin Nicolay G. Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 1
Labels: None
Environment:

mysql


Attachments: File docrine-dbal-patch.php    

 Description   

Can not set charset options for table creation.
Now I am fix thix problem in patch.
File: doctrine-dbal/lib/Doctrine/DBAL/Schema/Schema.php

#!/usr/bin/php
<?php
/**

  • Doctrine DBAL Patch
  • fix table creation query encode
  • (c) _Nicolay
    */
    system ('cp ./vendor/doctrine-dbal/lib/Doctrine/DBAL/Schema/Schema.php ./vendor/doctrine-dbal/lib/Doctrine/DBAL/Schema/Schema.php.Orig');

$data = file_get_contents('./vendor/doctrine-dbal/lib/Doctrine/DBAL/Schema/Schema.php');
$data = str_replace("new Table(\$tableName);",
"new Table(\$tableName,array(),array(),array(),0,array('charset'=>'utf8','collate'=>'utf8_general_ci'));",
$data);
file_put_contents('./vendor/doctrine-dbal/lib/Doctrine/DBAL/Schema/Schema.php', $data);



 Comments   
Comment by Stepan Tanasiychuk [ 20/Oct/11 ]

Guys, it's real problem for me too! (:

My test suite (in symfony2 project) always creates tables with "latin1_swedish_ci" collation. I want set "utf8_general_ci". But I don't want do it's in mysql.ini.

I tried setting it in MysqlSessionInit __construct, but it's not solved my problem.

In MySqlPlatform I found next code (https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php#L420):

        if (isset($options['charset'])) {
            $optionStrings['charset'] = 'DEFAULT CHARACTER SET ' . $options['charset'];
            if (isset($options['collate'])) {
                $optionStrings['charset'] .= ' COLLATE ' . $options['collate'];
            }
        }

But any options don't set in this call
https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Tools/SchemaTool.php#L133

Comment by Benjamin Eberlei [ 01/Apr/12 ]

Implemented this as a new feature on Schema. Also defaulting to UTF-8 now.





[DBAL-164] Quoting allows SQL injections Created: 10/Sep/11  Updated: 25/Sep/11  Resolved: 13/Sep/11

Status: Resolved
Project: Doctrine DBAL
Component/s: Drivers
Affects Version/s: 2.1.2
Fix Version/s: 2.0.9, 2.1.3
Security Level: All

Type: Bug Priority: Major
Reporter: Oliver Mueller Assignee: Guilherme Blanco
Resolution: Fixed Votes: 0
Labels: None
Environment:

OCI8 Driver
IBMDB" Driver



 Description   

$test = "foo ' bar";
$quoted = $conn->quote( $test );
echo $quoted;

RESULT: 'foo ' bar'
EXPECTED: 'foo \' bar'



 Comments   
Comment by Guilherme Blanco [ 13/Sep/11 ]

Fixed in https://github.com/doctrine/dbal/commit/82cc921447fde697bf3d9f5285d0f0b8587303d8

Comment by Benjamin Eberlei [ 25/Sep/11 ]

Backported to 2.0.9

Comment by Benjamin Eberlei [ 25/Sep/11 ]

Fix was modified to use the Zend Framework code for quoting OCI input: https://github.com/doctrine/dbal/commit/97638edc0fef0e08ce7db631eb130fde950844d7

This code is now in DBAL 2.1.4 and 2.0.9 and i have added some tests to very some simple SQL Injection vectors don't work on any supported platform.





[DBAL-171] PARAM_INT_ARRAY / PARAM_STR_ARRAY depends of parameter order Created: 11/Sep/11  Updated: 18/Nov/11  Resolved: 18/Nov/11

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: 2.1.1
Fix Version/s: 2.1.5
Security Level: All

Type: Bug Priority: Major
Reporter: arnaud-lb Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 1
Labels: None


 Description   

Named parameters appears to be treated as ordered parameters, when using PARAM_INT_ARRAY or PARAM_STR_ARRAY:

$query = $em->createQuery('
SELECT f FROM Foo f
WHERE a = :a
AND b IN (:b)
');

$query->setParameters(array(
    'b' => array(1,2,3),
    'a' => 1,
));

Notice that in the query the parameter :a appears before :b. And I call ->setParameters() with :b before :a.

When running this, I get an error from Doctrine/DBAL/SQLParserUtils::expandListParameters:119 saying that the second parameter of array_merge() is not an array.

When setting the parameters in the same order than they appear in the query, it works:

$query->setParameters(array(
    'a' => 1,
    'b' => array(1,2,3),
));

This is unexpected, as I'm using named parameters; the order should not matter.



 Comments   
Comment by Patrick Schwisow [ 27/Sep/11 ]

I'm getting this issue too.

Doctrine\ORM\Query::_doExecute() does a ksort on $sqlParams, but does not sort $types. Doctrine\DBAL\SQLParserUtils::expandListParameters() assumes that $params and $types are in the same order.

As a workaround, I added ksort($types) in _doExecute(), but I'm not sure if this is the proper way to handle this.

Comment by Benjamin Eberlei [ 18/Nov/11 ]

Fixed





[DBAL-161] Character Set of Database not UTF-8 Created: 07/Sep/11  Updated: 20/Nov/12  Resolved: 05/May/12

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

Type: Bug Priority: Major
Reporter: Hari K T Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

Ubuntu



 Description   

Hi Guys,

I was working with symfony command line and created the database with the app/console doctrine:create:database

Though the characterset I specified was UTF-8 , it created Latin character set .

@elliot was right too, the create database is not using any character set https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php#L328

You can see the issue created at https://github.com/symfony/symfony/issues/2044 and later Fabien confirmed the bug is related to Doctrine .

I am not sure its a Bug or a feature I am asking .

Thanks



 Comments   
Comment by Benjamin Eberlei [ 05/May/12 ]

Yes these are not connected, however we changed the default collation to UTF-8 for DBAL 2.3

Comment by Ivan Borzenkov [ 20/Nov/12 ]

not fixed or broken now
doctrine:create:database still create database whis latin1 charset

https://github.com/doctrine/DoctrineBundle/issues/49





[DBAL-160] Github-PR-51 by jheth: OCI8Statement doesn't support first query parameter being null Created: 30/Aug/11  Updated: 30/Aug/11  Resolved: 30/Aug/11

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: 2.1.3
Security Level: All

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


 Description   

This issue is created automatically through a Github pull request on behalf of jheth:

Url: https://github.com/doctrine/dbal/pull/51

Message:

Patch for OCI8Statement to support param[0] being null. Switched isset to array_key_exists. Added test that demonstrates the bug and confirms the fix.






[DBAL-158] Sqlite Platform doesn't set a proper mapping for "double precision" to act as float. Created: 24/Aug/11  Updated: 30/Oct/11  Resolved: 30/Oct/11

Status: Resolved
Project: Doctrine DBAL
Component/s: Platforms
Affects Version/s: 2.1
Fix Version/s: 2.1.5

Type: Bug Priority: Major
Reporter: Doron Gutman Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 1
Labels: None
Environment:

Ubuntu Linux 11.04
PHP 5.3.5


Attachments: Text File 0001-Fix-for-DBAL-158-where-double-precision-was-not-work.patch    

 Description   

I have a column in an entity, defined as "float" type.
When I run my phpunit tests (which are defined to use sqlite, whereas my production and development environment uses mysql), I get the following exception:

Doctrine\DBAL\DBALException: Unknown database type double precision requested, Doctrine\DBAL\Platforms\SqlitePlatform may not support it

Looking at AbstractPlatform.php, line 1972, function "getFloatDeclarationSQL" returns 'DOUBLE PRECISION'.
Where other platforms have in their "initializeDoctrineTypeMappings" method a mapping such as:

'double precision' => 'float',

, SqlitePlatform.php doesn't have such a mapping.



 Comments   
Comment by Steven Rosato [ 11/Oct/11 ]

I have encountered the same issue while using sqlite. I have made a simple fix in the platform class, as seen in the patch I provided which hopefully fixes the issue.

Comment by Benjamin Eberlei [ 30/Oct/11 ]

Was fixed





[DBAL-152] Github-PR-49 by juokaz: Ignore sysdiagrams table from a list Created: 21/Aug/11  Updated: 22/Nov/11  Resolved: 22/Nov/11

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

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


 Description   

This issue is created automatically through a Github pull request on behalf of

{username}

:

Url: https://github.com/doctrine/dbal/pull/49

Message:

Fix for the http://www.doctrine-project.org/jira/browse/DBAL-114



 Comments   
Comment by Christophe Coevoet [ 22/Nov/11 ]

This PR has been merged





[DBAL-151] Github-PR-50 by dteoh: Made custom Oracle NLS_DATE_FORMAT more compatible with Doctrine. Created: 21/Aug/11  Updated: 22/Nov/11  Resolved: 22/Nov/11

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

Type: Improvement Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Won't Fix Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of

{username}

:

Url: https://github.com/doctrine/dbal/pull/50

Message:



 Comments   
Comment by Christophe Coevoet [ 22/Nov/11 ]

The corresponding PR has been closed





[DBAL-148] Foreign key creation fails with MySQL 5.1.54 Created: 16/Aug/11  Updated: 18/Aug/11  Resolved: 18/Aug/11

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

Type: Bug Priority: Major
Reporter: Frej Connolly Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

MySQL 5.1.54, PHP 5.3.5, Ubuntu 11.04, Zend Framework 1.11.10


Attachments: Text File git_commit_9242fb332baaaeb81be4.txt     File Job.php     Text File orm_schema-tool_create--dump-sql.txt     File Position.php    

 Description   

doctrine orm:schema-tool:create

returns

[PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1064 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 'Position(id)' at line 1

The problem seem to be that the create commande creates the following SQL syntax
ALTER TABLE Job ADD FOREIGN KEY (position_id) REFERENCES Position(id);

which doesn't work. If I use the following (added a space between Postion and (id) in the end) it works.
ALTER TABLE Job ADD FOREIGN KEY (position_id) REFERENCES Position (id);

Patch for AbstractPlatform.php attached.



 Comments   
Comment by Benjamin Eberlei [ 18/Aug/11 ]

Fixed and merged 2.1.x





[DBAL-147] PostgreSqlSchemaManager fails to set foreign key onDelete/Update option properly if table has 'SET NULL' or 'SET DEFAULT' foreign key constraints Created: 15/Aug/11  Updated: 27/Aug/11  Resolved: 27/Aug/11

Status: Resolved
Project: Doctrine DBAL
Component/s: Schema Managers
Affects Version/s: 2.1
Fix Version/s: 2.1.2

Type: Bug Priority: Major
Reporter: Payam Hekmat Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 1
Labels: None


 Description   

This table structure:
CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY(id));
CREATE TABLE t2 (id INT NOT NULL, fk_id INT DEFAULT NULL);
ALTER TABLE t2 ADD FOREIGN KEY (fk_id) REFERENCES t1(id) ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE;

will cause the listTableForeignKeys to produce incorrect results for the onDelete/Update constraints (the 'DEFAULT' or 'NULL' in 'SET DEFAULT' or 'SET NULL' respectively gets cut off).

This looks to be fixed in the main branch.



 Comments   
Comment by Kenny Millington [ 26/Aug/11 ]

Seems to be fixed in:-

https://github.com/doctrine/dbal/commit/208f995607a544f9606c83d36752a9fd96ed9e64

Would definitely be nice to have that ported to the 2.1.x branch.

Comment by Benjamin Eberlei [ 27/Aug/11 ]

Fixed and merged for 2.1.2





[DBAL-146] Mssql platform TOP and DISTINCT ordering issue Created: 10/Aug/11  Updated: 09/Jan/12  Resolved: 09/Jan/12

Status: Resolved
Project: Doctrine DBAL
Component/s: Platforms
Affects Version/s: 2.1
Fix Version/s: 2.1.6, 2.2

Type: Bug Priority: Major
Reporter: Karl Southern Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

Windows 2008 R2 SqlSrv 2008 R2 IIS 7.5, fully patched


Attachments: Text File FixDisctinctTopOrderingIssue.patch    

 Description   

When doing a limit and a distinct query, DBAL generates an SQL statement in the form of SELECT TOP X DISTINCT, which SqlSrv does not like at all. Simply moving the the DISTINCT back to the start fixes this issue.

As far as I can see this is caused by the preg_replace in doModifyLimitQuery. Attached is a patch that makes it slightly more aware. There may be other phrases to check for, but none that I've come across yet.

Patch attached.



 Comments   
Comment by Benjamin Eberlei [ 09/Jan/12 ]

Fixed





[DBAL-142] Mapping Driver for Oracle does not know what to do with blobs, throws DBAL Exception for types "blob" and "long raw". Created: 02/Aug/11  Updated: 13/Mar/12  Resolved: 30/Oct/11

Status: Resolved
Project: Doctrine DBAL
Component/s: Platforms
Affects Version/s: 2.1
Fix Version/s: 2.2

Type: Bug Priority: Major
Reporter: Ed Anderson Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

CentOS 5.0, PHP 5.3.6, Oracle 11g EE, Symfony 2.0, Doctrine 2.1


Issue Links:
Duplicate
duplicates DBAL-6 MySQL BLOB datatypes throw DoctrineEx... Resolved

 Description   

When attempting to reverse engineer an existing Oracle 11g database an exception is thrown (by DBAL) complaining that the type blob is unknown. I believe this is coming from AbstractPlatform.php. I attempted to solve the problem by add a type mapping for blob in PDOOracle\Driver.php (blob => text) and it now complains that "long raw" is unknown.

[Doctrine\DBAL\DBALException]
Unknown database type long raw requested, Doctrine\DBAL\Platforms\OraclePlatform may not support it.



 Comments   
Comment by Benjamin Eberlei [ 30/Oct/11 ]

Implemented blob support

Comment by Sergio Andres Diaz Oviedo [ 13/Mar/12 ]

Sorry. i am new in it, i am developing and app in symfony 2, and when i try to import the entities from the database i get the error:

[Doctrine\DBAL\DBALException]
Unknown database type blob requested, Doctrine\DBAL\Platform may not support it.

i am using oracle 11g, i did try (blob => 'text') in oraclepatform.php but is later send me more errors, i cant understand, i want know how can i fix it i anyway to at least can import the entities, thank you





[DBAL-141] PDO Connection Failure through TNS - PDOOracle/Driver.php line 56 Created: 01/Aug/11  Updated: 30/Oct/11  Resolved: 30/Oct/11

Status: Resolved
Project: Doctrine DBAL
Component/s: Platforms
Affects Version/s: 2.1
Fix Version/s: 2.2

Type: Bug Priority: Major
Reporter: Ed Anderson Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

CentOS 6.0, Symfony 2.0.0 (RC), PHP 5.3.6, Oracle 11g Enterprise, Oracle InstantClient 11.0.2


Issue Links:
Duplicate
is duplicated by DBAL-136 OCI8 Driver MUST support connections ... Resolved

 Description   

On line 56 of the file ./vendor/doctrine-dbal/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php:

The line reads:
$dsn .= '))(CONNECT_DATA=(SID=' . $params['dbname'] . ')))'; should read $dsn .= '))(CONNECT_DATA=(SERVICE_NAME=' . $params['dbname'] . ')))';

If both SID and SERVICE_NAME need to be available for use, then logic should be inserted to determine which method is being used.



 Comments   
Comment by Benjamin Eberlei [ 18/Aug/11 ]

Whats the difference? the Use of SID works for me.

Comment by Daniel Lima [ 18/Aug/11 ]

Hi Benjamin,

There are some Oracle connections that are setup from SERVICE_NAME (without a SID).
In my company we always use SERVICE_NAME to setup a connection and we needed to modify the OCI connection driver from Doctrine to works fine in our environment

Take a look in: http://stackoverflow.com/questions/43866/how-sid-is-different-from-service-name-in-oracle-tnsnames-ora

Comment by Ed Anderson [ 19/Aug/11 ]

There's a subtle difference between SID and SERVICE_NAME and I think the code should somehow account for the difference. Here's why... An SID points to a physical instance at the database level (Service Identifier). If you ask for a SID you only get one shot at the connection (and hopefully the database is up). That's the legacy method of connecting to Oracle.

However, for environments that have HA installations of Oracle using RAC, the SERVICE_NAME is what is used to point to a database instance (instead of a physical Service ID). If a given database instance is down and you're using SID - meaning you're looking to connect to a specific database, the connection fails. If you're in an environment with multiple instances of the target database, then RAC figures out where to send you if you're using SERVICE_NAME and you will land on an useable instance. This is the typical way to connect when Oracle is load-balanced and in a high-availability environment.

Comment by Benjamin Eberlei [ 04/Sep/11 ]

How can we solve this issue in a BC way? I wouldn't know if I can just change it the way suggested and it will work for everyone.

Comment by Benjamin Eberlei [ 30/Oct/11 ]

Fixed by adding a new parameter 'service' which has to be true to use SERVICE_NAME instead of SID.





[DBAL-144] Oracle tables without indices are not handled during convert - this behavior should be tolerant since Oracle does not require indicies. Created: 02/Aug/11  Updated: 14/Nov/11  Resolved: 14/Nov/11

Status: Resolved
Project: Doctrine DBAL
Component/s: Platforms
Affects Version/s: 2.1
Fix Version/s: 2.1.5

Type: Bug Priority: Major
Reporter: Ed Anderson Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

CentOS 5.0, PHP 5.3.6, Oracle 11g EE, Symfony 2.0 Doctrine 2.1



 Description   

While it is good practice to always have at least one index defined on every table, in some cases (such as temporary tables) indices are not necessary. Oracle does not enforce creating indices for every table, and it is common to create some tables without them. The Table.php (line 556) method throws an exception if an index is not found for a given table. It's obvious there are ramifications for findByPK( ) auto-generated methods - these should be generated for every case where PK exists to accommodate Oracle and tolerate variances from accepted best-practices with most other database platforms.



 Comments   
Comment by Benjamin Eberlei [ 30/Oct/11 ]

When does this error happen?

This method is called through Table::getPrimaryKey(). Does this happen during the "doctrine:schema*" toolchain?

Comment by Ed Anderson [ 30/Oct/11 ]

This happens in the doctrine:schema toolchain.

Comment by Benjamin Eberlei [ 14/Nov/11 ]

Fixed.





[DBAL-140] Problem with null-length string comparison in Schema Created: 31/Jul/11  Updated: 31/Jul/11  Resolved: 31/Jul/11

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: 2.1
Fix Version/s: 2.1.1

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

If you compare a column with a string type and length of null to its database value with the default length then Comparator reports a difference. It should automatically convert NULL to 255 (default for all platforms).



 Comments   
Comment by Benjamin Eberlei [ 31/Jul/11 ]

Fixed.





[DBAL-138] Connection::quote should convert non PDO types Created: 25/Jul/11  Updated: 31/Jul/11  Resolved: 31/Jul/11

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

Type: Improvement Priority: Major
Reporter: Alexander Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

It currently doesn't so $connection->quote('foo', Type::STRING) doesn't work.



 Comments   
Comment by Alexander [ 25/Jul/11 ]

PR on github for this: https://github.com/doctrine/dbal/pull/39.

Comment by Benjamin Eberlei [ 31/Jul/11 ]

Merged PR into master





[DBAL-379] [GH-225] Fix SQLServerPlatform adds unique constraint to ADD PRIMARY KEY statement Created: 09/Nov/12  Updated: 12/Nov/12  Resolved: 12/Nov/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: 2.3.1
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of CraigMason:

Url: https://github.com/doctrine/dbal/pull/225

Message:

Currently when executing an ALTER TABLE statement with SQL Server, the query will be:

This will happen when adding primary keys via ALTER TABLE.

`ALTER TABLE foo ADD PRIMARY KEY (id) WHERE id IS NOT NULL`

should be

`ALTER TABLE foo ADD PRIMARY KEY (id)`






[DBAL-380] [GH-226] Fix for decimal fields with precision. Created: 12/Nov/12  Updated: 23/Dec/12  Resolved: 23/Dec/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: 2.3.2
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 1
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of bobdenotter:

Url: https://github.com/doctrine/dbal/pull/226

Message:

These fields have no spaces in the length, so the 'explode' fails. Omit the space from the code, and it works. Even if there were a space, it would still work, because of the `array_map("trim", ..)`.

arr(7)
[
"cid" => str(2) "11"
"name" => str(6) "nummer"
"type" => str(7) "DECIMAL"
"notnull" => str(1) "1"
"dflt_value" => str(1) "0"
"pk" => str(1) "0"
"length" => str(4) "18,9"
]



 Comments   
Comment by Bob den Otter [ 07/Dec/12 ]

bump

Not trying to be annoying, but I think this is an issue, that can be resolved quickly, without any consequences for other functionality. If it could be squeezed into 2.3.2 or 2.4, i'd be very grateful.





[DBAL-378] [GH-224] default table option not working Created: 08/Nov/12  Updated: 09/Nov/12  Resolved: 09/Nov/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: 2.3.1
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of Steffen-99:

Url: https://github.com/doctrine/dbal/pull/224

Message:

  • Fixing issue, key name corrected


 Comments   
Comment by Benjamin Eberlei [ 08/Nov/12 ]

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





[DBAL-374] [GH-222] Escape primary field name in create table sql query Created: 30/Oct/12  Updated: 13/Nov/12  Resolved: 13/Nov/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: 2.3.1
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of Genokilller:

Url: https://github.com/doctrine/dbal/pull/222

Message:

Fixes primary fields name in CreateTableSQL for Abstract Platform



 Comments   
Comment by Benjamin Eberlei [ 13/Nov/12 ]

Only fixed for primary key columns now, the other will be much more messy, requires refactoring.





[DBAL-370] [GH-220] Added support for alter table, foreign keys and autoincrement detection to Sqlite platform and schema Created: 20/Oct/12  Updated: 02/Jan/13  Resolved: 23/Dec/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: 2.4
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of hason:

Url: https://github.com/doctrine/dbal/pull/220

Message:



 Comments   
Comment by Martin Hasoň [ 22/Oct/12 ]

Solves http://www.doctrine-project.org/jira/browse/DDC-1232

Comment by Marco Pivetta [ 02/Jan/13 ]

Martin Hasoň this does not solve DDC-1232, since `getAlterTableSQL` still just throws an exception.

This PR currently breaks my functional test suites using the ORM and the SchemaTool in conjunction with the PDOSqlite driver.





[DBAL-365] [GH-217] Remember to close temporary connection in PostgreSqlSchemaManager::dropD... Created: 11/Oct/12  Updated: 12/Oct/12  Resolved: 12/Oct/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: 2.3.1
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of kimhemsoe:

Url: https://github.com/doctrine/dbal/pull/217

Message:

...atabase() and PostgreSqlSchemaManager::createDatabase()

Fixes my problem with not to be able to run all tests.



 Comments   
Comment by Benjamin Eberlei [ 12/Oct/12 ]

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





[DBAL-364] [GH-216] Fixed SQL placeholder parsing Created: 11/Oct/12  Updated: 19/Jan/13  Resolved: 19/Jan/13

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: 2.3.3
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of a-nik:

Url: https://github.com/doctrine/dbal/pull/216

Message:

Fixed comment on 'getPlaceholderPositions' method
Fixed error on escaped quote mark inside an SQL expression



 Comments   
Comment by Fabio B. Silva [ 19/Jan/13 ]

Closed in favor of GH-113

Comment by Benjamin Eberlei [ 19/Jan/13 ]

Fixed in 2.3.3





[DBAL-363] [GH-215] Remove unneeded use statement Created: 09/Oct/12  Updated: 05/Nov/12  Resolved: 05/Nov/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of jsjohns:

Url: https://github.com/doctrine/dbal/pull/215

Message:



 Comments   
Comment by Benjamin Eberlei [ 09/Oct/12 ]

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

Comment by Fabio B. Silva [ 05/Nov/12 ]

Closed





[DBAL-366] [GH-218] [MySQL] Fixed bug with comments not adding quotes for tables Created: 11/Oct/12  Updated: 06/Jan/13  Resolved: 06/Jan/13

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: 2.4
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of okovalov:

Url: https://github.com/doctrine/dbal/pull/218

Message:

Title describes everything... =)



 Comments   
Comment by Benjamin Eberlei [ 15/Oct/12 ]

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





[DBAL-359] [GH-211] Fix dropping foreign key multiple times with test Created: 04/Oct/12  Updated: 05/Oct/12  Resolved: 05/Oct/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of sdepablos:

Url: https://github.com/doctrine/dbal/pull/211

Message:

In some cases the Comparator class returns multiple drops for the same foreign key.
Specifically, in case you have two tables, A & B, with A having a foreign key FK
referencing B, if you drop table B, the resulting diff shows this FK twice,
once on the diff->orphanedForeignKeys array as we're deleting B, and another on
the diff->changedTables array as table A is also being modified. As a result of this you
get the DROP FOREIGN KEY instruction twice in the final SQL.

I'm not really sure if this change should be done in the Comparator clas or if it's better to
receive the full diff, even with duplicated drops for FK and later, when generating the final
SQL, drop the unnecessary ones



 Comments   
Comment by Benjamin Eberlei [ 04/Oct/12 ]

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





[DBAL-355] [GH-208] Optimize autoload prefix in composer.json Created: 28/Sep/12  Updated: 05/Oct/12  Resolved: 05/Oct/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: 2.4
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of Slamdunk:

Url: https://github.com/doctrine/dbal/pull/208

Message:

By having more specific autoload prefixes it is possible to reduce the number of stat calls made.



 Comments   
Comment by Benjamin Eberlei [ 05/Oct/12 ]

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





[DBAL-354] [GH-207] Removed Unsigned Integer Support in SQL Server Created: 28/Sep/12  Updated: 05/Oct/12  Resolved: 05/Oct/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: 2.3.1
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of datiecher:

Url: https://github.com/doctrine/dbal/pull/207

Message:

Removed unsigned integer test as SQL Server doesn't support unsigned integers.



 Comments   
Comment by Benjamin Eberlei [ 05/Oct/12 ]

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





[DBAL-351] [GH-206] Set minimum PHP version to 5.3.6 Created: 24/Sep/12  Updated: 05/Oct/12  Resolved: 05/Oct/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of nicolas-grekas:

Url: https://github.com/doctrine/dbal/pull/206

Message:

Since ->setCharset() has been removed, minimum PHP version has to be raised to 5.3.6: the new way of doing charset, throught the DSN, works only after bug https://bugs.php.net/bug.php?id=47802 has been fixed.



 Comments   
Comment by Benjamin Eberlei [ 05/Oct/12 ]

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





[DBAL-349] [GH-203] Delete always content from table master_slave_table between tests. Created: 23/Sep/12  Updated: 05/Oct/12  Resolved: 05/Oct/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: 2.3.1
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of kimhemsoe:

Url: https://github.com/doctrine/dbal/pull/203

Message:

Fixes that we are currently failing master slave tests.



 Comments   
Comment by Benjamin Eberlei [ 05/Oct/12 ]

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





[DBAL-350] [GH-205] Added exit code for dbal:reserved-words command Created: 24/Sep/12  Updated: 05/Oct/12  Resolved: 05/Oct/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: 2.4
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of hason:

Url: https://github.com/doctrine/dbal/pull/205

Message:



 Comments   
Comment by Benjamin Eberlei [ 05/Oct/12 ]

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





[DBAL-347] [GH-201] fix some phpdoc Created: 20/Sep/12  Updated: 05/Oct/12  Resolved: 05/Oct/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of KonstantinKuklin:

Url: https://github.com/doctrine/dbal/pull/201

Message:



 Comments   
Comment by Benjamin Eberlei [ 21/Sep/12 ]

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





[DBAL-346] Generated schema fails on MySQL (BLOB/TEXT cant have DEFAULT value) Created: 19/Sep/12  Updated: 20/Sep/12  Resolved: 20/Sep/12

Status: Resolved
Project: Doctrine DBAL
Component/s: Schema Managers
Affects Version/s: 2.2.2
Fix Version/s: 2.3
Security Level: All

Type: Bug Priority: Major
Reporter: Sascha Ahmann Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: Cli, schematool
Environment:

Symfony 2.1.x (dev/master), Doctrine 2.2.3, MySQL 5.5.x



 Description   

In my symfony 2.1 project i was including JMSPaymentCoreBundle and did the vanilla installation.

After that i ran

php app/console doctrine:schema:update --dump-sql
php app/console doctrine:schema:update --force

A lot of schema updates were done. I ran it again, and two schema updates were still showing up.
Running the command again, and they still show up.

I then tried to run the two schema updates against my database and MySQL complains with the following error:

Error: 1101 - BLOB/TEXT column 'extended_data' can't have a default value

According to the Documentation BLOB/TEXT indeed cannot have default values. I am not sure why Doctrine thinks it has to set this default value.

The statements look like this:

sascha@debian:/var/www/myproject/Symfony$ php app/console doctrine:schema:update --dump-sql
ALTER TABLE payment_instructions CHANGE extended_data extended_data LONGTEXT NOT NULL COMMENT '(DC2Type:extended_payment_data)';
ALTER TABLE financial_transactions CHANGE extended_data extended_data LONGTEXT DEFAULT NULL COMMENT '(DC2Type:extended_payment_data)'

I already reported this problem in the JMSPaymentCoreBundle Issue Queue where i then was referred to over here.

Also, i am not sure if Doctrine DBAL is the best match for this issue, so if it is wrong please move it to the right project issue queue.

Thank you very much and best of Regards!
Sascha






[DBAL-343] [GH-199] fixed unquoted oldColumnName when changing column definition in MySQL Created: 14/Sep/12  Updated: 25/Oct/12  Resolved: 25/Oct/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Can't Fix Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of lutzportela:

Url: https://github.com/doctrine/dbal/pull/199

Message:

before:
```ALTER TABLE AlertCondition CHANGE fulltext `fulltext` VARCHAR(255) DEFAULT NULL``` failed.

after:
```ALTER TABLE AlertCondition CHANGE `fulltext` `fulltext` VARCHAR(255) DEFAULT NULL``` passes.



 Comments   
Comment by Fabio B. Silva [ 25/Oct/12 ]

Closed





[DBAL-344] [GH-200] params not passed from execute to logger Created: 16/Sep/12  Updated: 17/Sep/12  Resolved: 17/Sep/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: 2.4
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of robap:

Url: https://github.com/doctrine/dbal/pull/200

Message:

When parameters are passed to Doctrine\DBAL\Statement::execute, they are not passed to any enabled logger(s).



 Comments   
Comment by Benjamin Eberlei [ 17/Sep/12 ]

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





[DBAL-342] [GH-198] Change default MySQL table collation to utf8_unicode_ci Created: 14/Sep/12  Updated: 12/Nov/12  Resolved: 17/Sep/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: 2.3
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of VladanStef:

Url: https://github.com/doctrine/dbal/pull/198

Message:

I think default table collation should be changed to `utf8_unicode_ci`, as it handles properly a much wider array of characters (Cyrillic, for example) at a generally negligible cost of performance.

`utf8_general_ci` simply does not work properly with too many languages and should be avoided as a default.



 Comments   
Comment by Benjamin Eberlei [ 17/Sep/12 ]

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

Comment by Benjamin Eberlei [ 17/Sep/12 ]

Merged into 2.3

Comment by William Knak [ 12/Nov/12 ]

What about leaving default collate empty? So it will inherit database default collation / charset. I've just created a ticket suggesting that #DDC-2139 . Because we're experiencing trouble using Symfony2 commands to create database, than create schema/tables/fields, always use "utf8_unicode_ci" instead of our database default collate.





[DBAL-341] [GH-197] Bugfix for DDC-2013 Created: 13/Sep/12  Updated: 17/Sep/12  Resolved: 17/Sep/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: 2.3
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of naitsirch:

Url: https://github.com/doctrine/dbal/pull/197

Message:

Bugfix DDC-2013 - Default Session Value ".," for "NLS_NUMERIC_CHARACTERS". This is needed because Oracle uses other characters for decimal separation depending on the servers locale.

See http://www.doctrine-project.org/jira/browse/DDC-2013



 Comments   
Comment by Benjamin Eberlei [ 17/Sep/12 ]

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





[DBAL-340] [GH-196] Fixed mini-typo Created: 11/Sep/12  Updated: 17/Sep/12  Resolved: 17/Sep/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: 2.4
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of pborreli:

Url: https://github.com/doctrine/dbal/pull/196

Message:



 Comments   
Comment by Benjamin Eberlei [ 11/Sep/12 ]

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





[DBAL-338] Typo in AbstractPlatform for GUID type declaration Created: 04/Sep/12  Updated: 05/Sep/12  Resolved: 05/Sep/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: 2.3
Security Level: All

Type: Bug Priority: Major
Reporter: Marijn Huizendveld Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

has been fixed in 3f5fda98299acdcda9965e8e797cbcd0490f0dcc, however it's not merged into 2.3.






[DBAL-345] When inserting decimals into Oracle, getting ORA-01722: invalid number Created: 04/Sep/12  Updated: 17/Sep/12  Resolved: 17/Sep/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: 2.2.2
Fix Version/s: 2.3
Security Level: All

Type: Bug Priority: Major
Reporter: Christian Stoller Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: decimal, number, oracle, separator
Environment:

Windows 7 (German), Oracle XE 11.2.0, Doctrine 2.2.2, Symfony 2.0.15



 Description   

When I insert decimals into database I get the following error message:

ORA-01722: invalid number

Oracle wants decimals (e.g. NUMBER(5,2)) separated by comma instead of a dot. I think the reason is that I use the german version of Windows. I tried to modify the following method of \Doctrine\DBAL\Driver\OCI8\OCI8Statement::bindValue() just for testing of course:

    public function bindValue($param, $value, $type = null)
    {
        if (is_float($value)) {
            $value = str_replace('.', ',', (string) $value); // <--
        }
        return $this->bindParam($param, $value, $type);
    }

With this modification I do not get the error anymore.
It would be great if a solution could be found. The strange thing is, if I query "SELECT * from nls_database_parameters where PARAMETER='NLS_NUMERIC_CHARACTERS'" I get ".," which means that a dot is already used as decimal separator. Maybe Oracle preferes the Locale of the OS?!
Maybe you could provide a setting which defines what separator should be used for decimals.

I found some Links that might be interesting regarding this issue:



 Comments   
Comment by Christian Stoller [ 04/Sep/12 ]

I found out that the database session has the parameter 'NLS_NUMERIC_CHARACTERS', too.
When I query it by the following SQL query:

SELECT parameter,value FROM v$nls_parameters WHERE parameter = 'NLS_NUMERIC_CHARACTERS'

I get this result:

,.

With doctrine I can get the parameter with this (in Symfony2):

$conn = $this->getDoctrine()->getEntityManager()->getConnection(); /* @var $conn \Doctrine\DBAL\Connection */
$query = $conn->executeQuery("SELECT parameter,value FROM v\$nls_parameters WHERE parameter = 'NLS_NUMERIC_CHARACTERS'"); /* @var $query \Doctrine\DBAL\Driver\OCI8\OCI8Statement */
$result = $query->fetchAll(\PDO::FETCH_ASSOC);
print_r($result);

In this case I get this output:

Array
(
[0] => Array
(
[PARAMETER] => NLS_NUMERIC_CHARACTERS
[VALUE] => ,.
)

)

And with

ALTER SESSION SET NLS_NUMERIC_CHARACTERS = '. '

I can change the parameter.

When I execute the above query before I do my insert with decimal values, everything works as expected
But it would be nicer if I could do that with a configuration.

Comment by Benjamin Eberlei [ 05/Sep/12 ]

There is an Oci8SessionInitListener inside Doctrine DBAL. It does not yet contain the numeric character change. Can you open a pull request on Github DBAL to add this?

Comment by Christian Stoller [ 13/Sep/12 ]

Hi Benjamin.
I have opened a pull request on Githup: https://github.com/doctrine/dbal/pull/197
I hope everything is correct, because this is my first Pull-Request

Comment by Benjamin Eberlei [ 17/Sep/12 ]

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





[DBAL-337] Column types are truncated when mapping PostGIS types Created: 04/Sep/12  Updated: 07/Sep/12  Resolved: 05/Sep/12

Status: Resolved
Project: Doctrine DBAL
Component/s: Platforms, Schema Managers
Affects Version/s: 2.2.1
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Jonathan Derrough Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: postgis
Environment:

Linux Debian Stable, Symfony 2.0, Doctrine 2.2.1, PostgreSQL, PostGIS



 Description   

When performing a doctrine schema update with Symfony2 ('php app/console doctrine:schema:update --force --verbose') using a custom PostGIS type mapping, column type descriptions are truncated.

How to reproduce:

1) add a custom 'point' type to Doctrine's type mapping

in a controller's boot method
$em = $this->container->get('doctrine.orm.default_entity_manager');
$conn = $em->getConnection();
if (!Type::hasType('point')) {
  Type::addType('point', 'Demo\GeoBundle\Lib\Type\PointType');
  $conn->getDatabasePlatform()->registerDoctrineTypeMapping('point', 'point');
}
PointType.php
<?php

namespace Demo\GeoBundle\Lib\Type;

use Demo\GeoBundle\Lib\Point;

use Doctrine\DBAL\Types\Type; 
use Doctrine\DBAL\Platforms\AbstractPlatform;

class PointType extends Type {

  const POINT = 'point';

  /**
   *
   * @param array $fieldDeclaration
   * @param AbstractPlatform $platform
   * @return string 
   */
  public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
  {
    return 'geography(POINT,'.Point::$SRID.')';
  }

  /**
   *
   * @param type $value
   * @param AbstractPlatform $platform
   * @return Point 
   */
  public function convertToPHPValue($value, AbstractPlatform $platform)
  {
    return Point::fromGeoJson($value);
  }

  public function getName()
  {
    return self::POINT;
    //return 'geography(POINT,'.Point::$SRID.')';
  }

  public function convertToDatabaseValue($value, AbstractPlatform $platform)
  {
    return $value->toWKT();
  }

  public function canRequireSQLConversion()
  {
    return true;
  }

  public function convertToPHPValueSQL($sqlExpr, $platform)
  {
    return 'ST_AsGeoJSON('.$sqlExpr.') ';
  }

  public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform)
  {
    return $sqlExpr;
  }

}

?>
Point.php
<?php

namespace Demo\GeoBundle\Lib;

use Demo\GeoBundle\Lib\GeoException;

class Point {
  private $lat;
  private $lon;
  public static $SRID = '4326';

  private function __construct($lon, $lat) {
    $this->lat = $lat;
    $this->lon = $lon;
  }
  
  public function setLongitude($lon) {
    $this->lon = $lon;
  }
  
  public function getLongitude() {
    return $this->lon;
  }

  public function setLatitude($lat) {
    $this->lat = $lat;
  }

  public function getLatitude() {
    return $this->lat;
  }

  public function toGeoJson(){
    $array = array("type" => "Point", "coordinates" => array ($this->lon, $this->lat));
    return \json_encode($array);
  }

  /**
   *
   * @return string 
   */
  public function toWKT() {
    return 'SRID='.self::$SRID.';POINT('.$this->lon.' '.$this->lat.')';
  }

  /**
   *
   * @param string $geojson
   * @return Point 
   */
  public static function fromGeoJson($geojson) 
  {
    $a = json_decode($geojson);
    //check if the geojson string is correct
    if ($a == null or !isset($a->type) or !isset($a->coordinates)){
      throw GeoException::badJsonString();
    }

    if ($a->type != "Point"){
      throw GeoException::badGeoType();
    } else {
      $lon = $a->coordinates[0];
      $lat = $a->coordinates[1];
      return Point::fromLonLat($lon, $lat);
    }

  }
  
  /**
   *
   * @return string
   */
  public function __toString() {
    return $this->lon . ' ' . $this->lat;
  }

  /**
   *
   * @return array
   */
  public function toArray() {
    return array($this->lon, $this->lat);
  }

  public static function fromLonLat($lon, $lat)
  {
    if (($lon > -180.0 && $lon < 180.0) && ($lat > -90.0 && $lat < 90.0))
    {
      return new Point($lon, $lat);
    } else {
      throw GeoException::badCoordinates($lon, $lat);
    }
  }
}

?>
GeoException.php
<?php

namespace Demo\GeoBundle\Lib;

class GeoException extends \RuntimeException
{
    public function __construct($message = null, \Exception $previous = null, $code = 0)
    {
        parent::__construct($message, $code, $previous);
    }

    public static function badJSonString()
    {
      return new GeoException("Bad JSon string");
    }

    public static function badGeoType()
    {
      return new GeoException("Bad geo type");
    }

    public static function badCoordinates($lon, $lat)
    {
      return new GeoException("Bad coordinates: " . $lon . " " . $lat);
    }
}

2) with Symfony2, create a simple entity using the Point type:

TestPoint.php
<?php

namespace Demo\TestBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="test_points")
 */
class TestPoint
{
  /**
   * @ORM\Id
   * @ORM\Column(type="integer")
   * @ORM\GeneratedValue(strategy="AUTO")
   */
  protected $id;

  /**
   * @ORM\Column(type="point")
   */
  protected $coordinates;

  /**
   * Get id
   *
   * @return integer 
   */
  public function getId()
  {
    return $this->id;
  }

  /**
   * Set coordinates
   *
   * @param point $coordinates
   * @return Partner
   */
  public function setCoordinates($coordinates)
  {
    $this->coordinates = $coordinates;
    return $this;
  }

  /**
   * Get coordinates
   *
   * @return point 
   */
  public function getCoordinates()
  {
    return $this->coordinates;
  }
  
  public function setLongitude($lon)
  {
    if ($this->coordinates == null)
    {
      $this->coordinates = Point::fromLonLat($lon, 0);
    }
    else
    {
      $this->coordinates->setLongitude($lon);
    }
  }
  
  public function getLongitude()
  {
    return $this->coordinates == null ? 0 : $this->coordinates->getLongitude();
  }
  
  public function setLatitude($lat)
  {
    if ($this->coordinates == null)
    {
      $this->coordinates = Point::fromLonLat(0, $lat);
    }
    else
    {
      $this->coordinates->setLatitude($lat);
    }
  }
  
  public function getLatitude()
  {
    return $this->coordinates == null ? 0 : $this->coordinates->getLatitude();
  }
}

3) use the update script to create the table:

php app/console doctrine:schema:update --force --verbose

4) run it again to update:

php app/console doctrine:schema:update --force --verbose

Errors should ensue:

Errors

[Doctrine\DBAL\DBALException]
Unknown database type geography requested, Doctrine\DBAL\Platforms\PostgreSqlPlatform may not support it.

Exception trace:
() at /.../Symfony/vendor/doctrine-dbal/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php:261
Doctrine\DBAL\Platforms\AbstractPlatform->getDoctrineTypeMapping() at /.../Symfony/vendor/doctrine-dbal/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php:285
Doctrine\DBAL\Schema\PostgreSqlSchemaManager->_getPortableTableColumnDefinition() at /.../Symfony/vendor/doctrine-dbal/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php:672
Doctrine\DBAL\Schema\AbstractSchemaManager->_getPortableTableColumnList() at /.../Symfony/vendor/doctrine-dbal/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php:159
Doctrine\DBAL\Schema\AbstractSchemaManager->listTableColumns() at /.../Symfony/vendor/doctrine-dbal/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php:254
Doctrine\DBAL\Schema\AbstractSchemaManager->listTableDetails() at /.../Symfony/vendor/doctrine-dbal/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php:242
Doctrine\DBAL\Schema\AbstractSchemaManager->listTables() at /.../Symfony/vendor/doctrine-dbal/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php:830
Doctrine\DBAL\Schema\AbstractSchemaManager->createSchema() at /.../Symfony/vendor/doctrine/lib/Doctrine/ORM/Tools/SchemaTool.php:689
Doctrine\ORM\Tools\SchemaTool->getUpdateSchemaSql() at /.../Symfony/vendor/doctrine/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php:103
Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand->executeSchemaCommand() at /.../Symfony/vendor/doctrine/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php:59
Doctrine\ORM\Tools\Console\Command\SchemaTool\AbstractCommand->execute() at /.../Symfony/vendor/symfony/src/Symfony/Bundle/DoctrineBundle/Command/Proxy/UpdateSchemaDoctrineCommand.php:62
Symfony\Bundle\DoctrineBundle\Command\Proxy\UpdateSchemaDoctrineCommand->execute() at /.../Symfony/vendor/symfony/src/Symfony/Component/Console/Command/Command.php:226
Symfony\Component\Console\Command\Command->run() at /.../Symfony/vendor/symfony/src/Symfony/Component/Console/Application.php:194
Symfony\Component\Console\Application->doRun() at /.../Symfony/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:76
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /.../Symfony/vendor/symfony/src/Symfony/Component/Console/Application.php:118
Symfony\Component\Console\Application->run() at /.../Symfony/app/console:22

doctrine:schema:update [--complete] [--dump-sql] [--force] [--em[="..."]]

What seems to be happening is that the returned type for the column holding the points is truncated. "Full" type is 'geography(Point,4326)', returned type from Doctrine is 'geography' (missing the specifics).
Adding other custom mappings for PostGIS types, LineString for example, will result with the exact same error although the full type is 'geography(LineString,4326)'. The above test case would still be erroneous with the full type returned as the mapping specifies a 'dbType' known as 'point' or 'linestring' and not 'geography(Point,4326)' or 'geography(LineString,4326)', adjustments should be made there.



 Comments   
Comment by Jonathan Derrough [ 04/Sep/12 ]

Further investigation showed that the truncation makes sense in a general context as types (ex: varchar) are simplifications of complete types (ex: character varying (255)). But it still presents a problem for PostGIS users.

A quick workaround would be to change the mapping to:

in a controller's boot method
$em = $this->container->get('doctrine.orm.default_entity_manager');
$conn = $em->getConnection();
if (!Type::hasType('point')) {
  Type::addType('point', 'Demo\GeoBundle\Lib\Type\PointType');
  $conn->getDatabasePlatform()->registerDoctrineTypeMapping('geography', 'point');
}

It seems to work fine with several custom PostGIS types mapped but it wasn't fully tested.

Comment by Benjamin Eberlei [ 05/Sep/12 ]

The way you do it its actually a workaround, but Doctrine Bundle has a way to configure the registerDoctrineMappingType() calls via configuration.

Check with "php app/console config:dump-reference DoctrineBundle"

Comment by Jonathan Derrough [ 05/Sep/12 ]

Yes, I am aware of the mapping configuration with the config file. I tested it again:

config.yml
# Doctrine Configuration
doctrine:
    dbal:
        driver:   %database_driver%
        host:     %database_host%
        port:     %database_port%
        dbname:   %database_name%
        user:     %database_user%
        password: %database_password%
        charset:  UTF8
        types:
            point: Demo\GeoBundle\Lib\Type\PointType
            linestring: Demo\GeoBundle\Lib\Type\LineStringType
    orm:
        auto_generate_proxy_classes: %kernel.debug%
        auto_mapping: true

But the issue here remains, the same error is outputed:

[Doctrine\DBAL\DBALException]
Unknown database type geography requested, Doctrine\DBAL\Platforms\PostgreSqlPlatform may not suppo
rt it.

As I detailed previously, the fetched type of a geography column is truncated. So my workaround to avoid the errors during update was to register my custom types with 'geography' as db-type. It doesn't seem to be the right way since only one doctrine-type can be map a db-type (so here, 'geography' would be associated with either 'point' or 'linestring').

Comment by Benjamin Eberlei [ 05/Sep/12 ]

Thats only half the picture, see "mapping_types" here http://symfony.com/doc/current/reference/configuration/doctrine.html

Comment by Jonathan Derrough [ 07/Sep/12 ]

With the updated config.yml:

config.yml
# Doctrine Configuration
doctrine:
    dbal:
        driver:   %database_driver%
        host:     %database_host%
        port:     %database_port%
        dbname:   %database_name%
        user:     %database_user%
        password: %database_password%
        charset:  UTF8
        types:
            point: Demo\GeoBundle\Lib\Type\PointType
            linestring: Demo\GeoBundle\Lib\Type\LineStringType
        mapping_types:
            geography(point,4326): point
            geography(linestring,4326): linestring
    orm:
        auto_generate_proxy_classes: %kernel.debug%
        auto_mapping: true

errors are still showing.

Using:

config.yml
        mapping_types:
            geography: point
            geography: linestring

errors are gone but I guess it is the same as:

$conn->getDatabasePlatform()->registerDoctrineTypeMapping('geography', 'point');
$conn->getDatabasePlatform()->registerDoctrineTypeMapping('geography', 'linestring');

and I don't see how it would be right since the 'linestring' mapping would replace the 'point' mapping.

I'm affraid I don't get it.





[DBAL-339] setFetchMode arguments exception Created: 03/Sep/12  Updated: 05/Sep/12  Resolved: 05/Sep/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: 2.3
Fix Version/s: 2.3
Security Level: All

Type: Bug Priority: Major
Reporter: tim glabisch Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

PDO_MySql



 Description   

i have this error in version 2.3.0-RC1

in DBAL/STatement.php on aound line 191 you will find:

public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)

{ return $this->stmt->setFetchMode($fetchMode, $arg2, $arg3); }

the problem is that php throws me a Exception:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: fetch mode doesn't allow any extra arguments'

the reason for the exception is that setFetchMode doesnt support null as second/third argument.

somebody also described it in the php issue tracker:
https://bugs.php.net/bug.php?id=54545



 Comments   
Comment by Benjamin Eberlei [ 05/Sep/12 ]

Fixed





[DBAL-336] [GH-195] Removed duplicate table check so that ManyToMany relationships can have two owning entities Created: 02/Sep/12  Updated: 05/Sep/12  Resolved: 05/Sep/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of intrepion:

Url: https://github.com/doctrine/dbal/pull/195

Message:

Whenever there is a ManyToMany relationship with both entities needing ownership, running doctrine:schema:update throws an exception due to a duplicate table definition when, in fact, it is the same table.



 Comments   
Comment by Benjamin Eberlei [ 04/Sep/12 ]

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





[DBAL-335] Is MasterSlaveConnection implemented correctly - seems to overwrite master connection on transaction methods? Created: 31/Aug/12  Updated: 22/Sep/12  Resolved: 17/Sep/12

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

Type: Bug Priority: Major
Reporter: Jonathan Ingram Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

Forgive me to doubt, but I think there may be a bug in MasterSlaveConnection.

It's easier to understand what I'm saying by debugging and tracing the flow, but I'll illustrate it with gists.

First, here is a simple service method to create a user. It opens up a transaction, persists the user, commits and returns. On error, if there is an active transaction, rollback. Here is the gist:

https://gist.github.com/3547674

The "$conn->beginTransaction();" line is where we trace through (the remainder of the service method is now irrelevant). Looking into MasterSlaveConnection.php, we see the method tries to connect to the master connection (call this point ###):

https://gist.github.com/3547720

Now looking in the next gist, we see what happens when "$this->connect('master');" is called. At this point it's not that interesting, the internal "$this->_conn" property is set to "master".

https://gist.github.com/3547750

Now here lies the bug I believe. "parent::beginTransaction();" is called. When looking into this method, we see that another call is made to connect but this time without "master" as the argument (i.e. connect to slave). This call to connect is made before incrementing the transaction nesting level.

https://gist.github.com/3547808

Now, I won't do another gist for "MasterSlaveConnection::connect", but if you refer to the file at line 13 https://gist.github.com/3547750#file_master_slave_connection.php, you will see that it checks the transaction nesting level and if it is there, forces master. However, we don't increment the level until after the method returns, so the slave is used. Ultimately, this results in the internal "$this->_conn" property set to the "slave" connection which violates our original action at ### above where we said we want to connect to "master".

Am I missing something here? Here is a gist the is a basic attempt at fixing this one method. It simply copies the code from the parent method except does not connect twice. I believe the same would have to occur for all the other methods unless it can be fixed once at the "MasterSlaveConnection::connect" level.

https://gist.github.com/3547880

I've just fleshed out "beginTransaction", "commit" and "rollBack" in "MasterSlaveConnection" by basically copying and pasting the code from the parent class and for my failing use case, this fixes the issue. However, it did require updating "Connection" slightly so that I had access to some private variables.



 Comments   
Comment by Lars Strojny [ 31/Aug/12 ]

This looks indeed like a bug. From a first glimpse the fix would be to use master, if master is already connected.

Comment by Benjamin Eberlei [ 05/Sep/12 ]

This only happens when "keepSlave" = true, because then the master is not written into the slave property aswell:

   } else {
     $this->connections['slave'] = $this->_conn = $this->connectTo($connectionName);
   } 

Are you using keepSlave = true?

Comment by Jonathan Ingram [ 05/Sep/12 ]

Yes I am. Does that render this moot or still a bug?

Comment by Benjamin Eberlei [ 06/Sep/12 ]

Its still a bug, but it helps to know why this happens.

Comment by Benjamin Eberlei [ 17/Sep/12 ]

Fixed in master and 2.3, can you test it?

Comment by Jonathan Ingram [ 19/Sep/12 ]

Thanks for doing this. I will test it shortly.

Comment by Ivan Andric [ 22/Sep/12 ]

Hi,

not sure if you managed to test this but now test on mysql database fails with results below.
Probably some typo.

There was 1 error:

1) Doctrine\Tests\DBAL\Functional\MasterSlaveConnectionTest::testKeepSlaveBeginTransactionStaysOnMaster
Exception: [Doctrine\DBAL\DBALException] An exception occurred while executing 'INSERT INTO master_slave_table (test_int) VALUES ' with params

{"1":30}

:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '30' for key 'PRIMARY'

With queries:
2. SQL: 'CREATE TABLE master_slave_table (test_int INT NOT NULL, PRIMARY KEY(test_int)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB' Params:

Trace:
/home/ivan/git/dbal2/dbal/lib/Doctrine/DBAL/Connection.php:793
/home/ivan/git/dbal2/dbal/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php:231
/home/ivan/git/dbal2/dbal/lib/Doctrine/DBAL/Connection.php:539
/home/ivan/git/dbal2/dbal/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php:285
/home/ivan/git/dbal2/dbal/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php:92

/home/ivan/git/dbal2/dbal/tests/Doctrine/Tests/DbalFunctionalTestCase.php:73
/home/ivan/git/dbal2/dbal/lib/Doctrine/DBAL/Connection.php:793
/home/ivan/git/dbal2/dbal/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php:231
/home/ivan/git/dbal2/dbal/lib/Doctrine/DBAL/Connection.php:539
/home/ivan/git/dbal2/dbal/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php:285
/home/ivan/git/dbal2/dbal/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php:92

Caused by
Doctrine\DBAL\DBALException: An exception occurred while executing 'INSERT INTO master_slave_table (test_int) VALUES ' with params

{"1":30}

:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '30' for key 'PRIMARY'

/home/ivan/git/dbal2/dbal/lib/Doctrine/DBAL/DBALException.php:47
/home/ivan/git/dbal2/dbal/lib/Doctrine/DBAL/Connection.php:786
/home/ivan/git/dbal2/dbal/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php:231
/home/ivan/git/dbal2/dbal/lib/Doctrine/DBAL/Connection.php:539
/home/ivan/git/dbal2/dbal/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php:285
/home/ivan/git/dbal2/dbal/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php:92

Caused by
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '30' for key 'PRIMARY'

/home/ivan/git/dbal2/dbal/lib/Doctrine/DBAL/Connection.php:786
/home/ivan/git/dbal2/dbal/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php:231
/home/ivan/git/dbal2/dbal/lib/Doctrine/DBAL/Connection.php:539
/home/ivan/git/dbal2/dbal/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php:285
/home/ivan/git/dbal2/dbal/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php:92





[DBAL-334] [GH-194] Small test fixes for PostgreSQL Created: 29/Aug/12  Updated: 05/Sep/12  Resolved: 05/Sep/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: 2.3
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of posulliv:

Url: https://github.com/doctrine/dbal/pull/194

Message:

When running the test suite against a clean PostgreSQL install on a 64-bit system I hit 2 issues:

  • dropDatabase calls fail unless a database is manually created
  • TypeConversionTest::testIdempotentDataConversion fails expecting bigint type to be converted to a string. PostgreSQL seems to detect 32 vs 64 bit systems and casts correctly for bigint types.

This small patch allows the test suite to run successfully for me against clean MySQL & PostgreSQL installs.



 Comments   
Comment by Benjamin Eberlei [ 05/Sep/12 ]

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

Comment by Benjamin Eberlei [ 05/Sep/12 ]

Fixed





[DBAL-329] [GH-190] Fix DDC-1978 Created: 26/Aug/12  Updated: 29/Aug/12  Resolved: 29/Aug/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: 2.2.3, 2.3
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of FabioBatSilva:

Url: https://github.com/doctrine/dbal/pull/190

Message:

Fix DDC-1978

http://www.doctrine-project.org/jira/browse/DDC-1978



 Comments   
Comment by Benjamin Eberlei [ 29/Aug/12 ]

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





[DBAL-331] [GH-192] ExpressionBuilder in and notIn methods Created: 27/Aug/12  Updated: 29/Aug/12  Resolved: 29/Aug/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: 2.4
Security Level: All

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


 Description   

This issue is created automatically through a Github pull request on behalf of Xobb:

Url: https://github.com/doctrine/dbal/pull/192

Message:

ExpressionBuilder is missing *in* and *not in* methods to produce these statements.



 Comments   
Comment by Benjamin Eberlei [ 29/Aug/12 ]

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





[DBAL-326] [GH-187] Quote column names during insert, if necessary Created: 20/Aug/12  Updated: 29/Aug/12  Resolved: 29/Aug/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Won't Fix Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of dobesv:

Url: https://github.com/doctrine/dbal/pull/187

Message:

This fixes an issue I ran into where if I tried to insert something with a column name that required quoting, I would have to manually quote it myself.



 Comments   
Comment by Benjamin Eberlei [ 29/Aug/12 ]

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





[DBAL-323] [GH-185] Add schema changes for length for postgres Created: 17/Aug/12  Updated: 06/Oct/12  Resolved: 06/Oct/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: 2.2.3, 2.3.1
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of mvrhov:

Url: https://github.com/doctrine/dbal/pull/185

Message:






[DBAL-322] Change Detection fails when 'unsigned' is used in MySQL Schema Created: 14/Aug/12  Updated: 14/Aug/12  Resolved: 14/Aug/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: 2.2
Fix Version/s: 2.2, 2.3
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Comments   
Comment by Marcus Stöhr [ 14/Aug/12 ]

This has been already fixed in https://github.com/doctrine/dbal/commit/e44a6c36a8d9e0aa8d8abb2c91c443ced5a6e39e.





[DBAL-316] Incorrect parameter SERVICE_NAME Created: 07/Aug/12  Updated: 10/Feb/13  Resolved: 10/Feb/13

Status: Resolved
Project: Doctrine DBAL
Component/s: Drivers
Affects Version/s: 2.3
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Leandro Guimarães Fernandes Assignee: Alexander
Resolution: Invalid Votes: 0
Labels: oracle
Environment:

Windows 7, ZendServer-CE-php-5.4.0-5.6.0-Windows_x86 and Oracle 10



 Description   

At line 63, the driver PDOOracle, the parameter SERVICE_NAME is receiving the value of 'dbname' and not 'service'.

Sorry, my English is bad!



 Comments   
Comment by Alexander [ 10/Feb/13 ]

This is not a bug. Read the code. It checks if the parameter is set and if it's "true".





[DBAL-315] [GH-182] Added a missing method in the Constraint interface Created: 06/Aug/12  Updated: 14/Aug/12  Resolved: 14/Aug/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: 2.3
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Alexander
Resolution: Fixed Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of stof:

Url: https://github.com/doctrine/dbal/pull/182

Message:

This adds a missing method in the Constraint interface. The method is already defined in AbstractAsset which is extended by both classes implementing the interface. the AbstractPlatform is calling this method on objects after checking they are implementing the interface. So either the method should be part of the interface, or all places using the interface as typehint should be refactored to check for the classes (examples can be found [here](https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php#L1029) and [there](https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php#L1254)).

Adding a method in an interface is technically a BC break but this method is not really a public extension point. what do you think @beberlei ?



 Comments   
Comment by Benjamin Eberlei [ 14/Aug/12 ]

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





[DBAL-317] [GH-183] Fix unsigned columns in MySql Created: 08/Aug/12  Updated: 14/Aug/12  Resolved: 14/Aug/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Duplicate Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of acasademont:

Url: https://github.com/doctrine/dbal/pull/183

Message:

Unsigned column properties were never set. In consequence all migrations diff were trying to change the column definition when it was already changed. See symfony/symfony#3560

Would it be also nice to add some test to avoid regressions, but i don't know where it would be a nice place to put them.



 Comments   
Comment by Benjamin Eberlei [ 08/Aug/12 ]

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

Comment by Alexander [ 14/Aug/12 ]

Duplicate of http://www.doctrine-project.org/jira/browse/DBAL-322





[DBAL-314] [GH-180] Fixed some phpdoc Created: 06/Aug/12  Updated: 14/Aug/12  Resolved: 14/Aug/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: 2.3
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of stof:

Url: https://github.com/doctrine/dbal/pull/180

Message:

This fixes some phpdoc in the AbstractPlatform and in some child classes. I haven't checked all child classes to ensure that all phpdoc is right now, but the abstract one is now accurate (but a bunch of method are missing their phpdoc altogether)



 Comments   
Comment by Benjamin Eberlei [ 14/Aug/12 ]

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





[DBAL-311] [GH-179] Added missing type mappings for postgres Created: 31/Jul/12  Updated: 14/Aug/12  Resolved: 14/Aug/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of jkrems:

Url: https://github.com/doctrine/dbal/pull/179

Message:

We had problems running the migrations-commands with an existing database. Seems like some type-mappings are just missing. This patch fixed the problem for us.






[DBAL-227] Driver for PostgreSQL: DBAL fails to list foreign keys if multiple tables with the same name exist, each in a different schema Created: 23/Feb/12  Updated: 05/Mar/12  Resolved: 05/Mar/12

Status: Resolved
Project: Doctrine DBAL
Component/s: Drivers
Affects Version/s: 2.2.1
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Peter Hopfgartner Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None
Environment:

Ubuntu 10.04



 Description   

PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[21000]: Cardinality violation: 7 ERROR: more than one row returned by a subquery used as an expression' in /usr/share/php/Doctrine/DBAL/Connection.php:620
Stack trace:
#0 /usr/share/php/Doctrine/DBAL/Connection.php(620): PDO->query('SELECT r.connam...')
#1 /usr/share/php/Doctrine/DBAL/Connection.php(571): Doctrine\DBAL\Connection->executeQuery('SELECT r.connam...', Array)
#2 /usr/share/php/Doctrine/DBAL/Schema/AbstractSchemaManager.php(262): Doctrine\DBAL\Connection->fetchAll('SELECT r.connam...')
#3 /usr/share/php/Doctrine/DBAL/Schema/AbstractSchemaManager.php(229): Doctrine\DBAL\Schema\AbstractSchemaManager->listTableForeignKeys('logs')
#4 /usr/share/php/Doctrine/DBAL/Schema/AbstractSchemaManager.php(214): Doctrine\DBAL\Schema\AbstractSchemaManager->listTableDetails('logs')
#5 /usr/share/php/Doctrine/DBAL/Schema/AbstractSchemaManager.php(764): Doctrine\DBAL\Schema\AbstractSchemaManager->listTables()
#6 /home/phopfgartner/devel/doctrine_tests/conn.php in /usr/share/php/Doctrine/DBAL/Connection.php on line 620

The failing SQL statement is:

SELECT r.conname, pg_catalog.pg_get_constraintdef(r.oid, true) as condef
FROM pg_catalog.pg_constraint r
WHERE r.conrelid =
(
SELECT c.oid
FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n
WHERE n.nspname NOT IN ('pg_catalog', 'information_schema', 'pg_toast') AND c.relname = 'logs' AND n.oid = c.relnamespace
)
AND r.contype = 'f'

Indeed, if I execute:

SELECT c.relname, n.nspname
FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n
WHERE n.nspname NOT IN ('pg_catalog', 'information_schema', 'pg_toast') AND c.relname = 'logs' AND n.oid = c.relnamespace

I get:

relname | nspname
===============
logs | sbr_stats
logs | public

Regards,

Peter



 Comments   
Comment by Benjamin Eberlei [ 03/Mar/12 ]

Are you sure you are on 2.2.1? Because for me the query there is:

SELECT r.conname, pg_catalog.pg_get_constraintdef(r.oid, true) as condef
                  FROM pg_catalog.pg_constraint r
                  WHERE r.conrelid =
                  (
                      SELECT c.oid
                      FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n
                      WHERE n.nspname NOT IN ('pg_catalog', 'information_schema', 'pg_toast') AND c.relname = 'ddc227logs' AND n.nspname = ANY(string_to_array((select setting from pg_catalog.pg_settings where name = 'search_path'),',')) AND n.oid = c.relnamespace
                  )
                  AND r.contype = 'f'"

Which gives the correct result.

Comment by Peter Hopfgartner [ 05/Mar/12 ]

Your're right! It was version 2.1. With 2.2 it's perfectly fine.

Sorry the noise,

Peter

Comment by Benjamin Eberlei [ 05/Mar/12 ]

There won't be another DBAL 2.1 release so i am closing this, please update your library.





[DBAL-224] Allow drop index and pk from table instance Created: 13/Feb/12  Updated: 13/Feb/12  Resolved: 13/Feb/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: 2.3
Security Level: All

Type: New Feature Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Comments   
Comment by Benjamin Eberlei [ 13/Feb/12 ]

Implemented





[DBAL-220] Some platforms require specific index handling Created: 13/Feb/12  Updated: 29/Jan/13  Resolved: 13/Feb/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: 2.2
Fix Version/s: 2.3
Security Level: All

Type: New Feature Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   
  • SQL Server/Azure for example requires strict differentiation between CLUSTERED/NON-CLUSTERED indexes.
  • MySQL can create full text indexes
  • etcetc.


 Comments   
Comment by Benjamin Eberlei [ 13/Feb/12 ]

Implemented.

Comment by Benjamin Eberlei [ 13/Feb/12 ]

SQL Server can now create clustered or non-clustered indexes like:

$table->setPrimaryKey(array("id"));
$table->getIndex('primary')->addFlag('nonclustered');
$table->addIndex(array("column1"), "name");
$table->getIndex("name")->addFlag("clustered");
Comment by Steve Müller [ 29/Jan/13 ]

Is there any way to define the flags via class metadata? Shouldn't there be the possibility to pass the flags to a class metadata index/id definition?





[DBAL-223] Add DBAL TableGenerator Created: 13/Feb/12  Updated: 13/Feb/12  Resolved: 13/Feb/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: 2.3
Security Level: All

Type: New Feature Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Dependency
is required for DDC-450 Add TableGenerator Implementation Reopened

 Description   
/**
 * Table ID Generator for those poor languages that are missing sequences.
 *
 * WARNING: The Table Id Generator clones a second independent database
 * connection to work correctly. This means using the generator requests that
 * generate IDs will have two open database connections. This is necessary to
 * be safe from transaction failures in the main connection. Make sure to only
 * ever use one TableGenerator otherwise you end up with many connections.
 *
 * TableID Generator does not work with SQLite.
 *
 * The TableGenerator does not take care of creating the SQL Table itself. You
 * should look at the `TableGeneratorSchemaVisitor` to do this for you.
 * Otherwise the schema for a table looks like:
 *
 * CREATE sequences (
 *   sequence_name VARCHAR(255) NOT NULL,
 *   sequence_value INT NOT NULL DEFAULT '1',
 *   sequence_increment_by INT NOT NULL DEFAULT '1',
 *   PRIMARY KEY (table_name)
 * );
 *
 * Technically this generator works as follows:
 *
 * 1. Use a robust transaction serialization level.
 * 2. Open transaction
 * 3. Acquire a read lock on the table row (SELECT .. FOR UPDATE)
 * 4. Increment current value by one and write back to database
 * 5. Commit transaction
 *
 * If you are using a sequence_increment_by value that is larger than one the
 * ID Generator will keep incrementing values until it hits the incrementation
 * gap before issuing another query.
 *
 * If no row is present for a given sequence a new one will be created with the
 * default values 'value' = 1 and 'increment_by' = 1
 *
 * @author Benjamin Eberlei <kontakt@beberlei.de>
 */


 Comments   
Comment by Benjamin Eberlei [ 13/Feb/12 ]

Implemented under the DDC-450 label, will get into ORM through this implementation.





[DBAL-222] Add Azure Platform Created: 13/Feb/12  Updated: 13/Feb/12  Resolved: 13/Feb/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: 2.3
Security Level: All

Type: New Feature Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

SQL Azure has some platform specific SQL on top of SQL Server 2008 mainly to support Federations



 Comments   
Comment by Benjamin Eberlei [ 13/Feb/12 ]

Implemented.





[DBAL-216] Add ext/sqlsrv support Created: 05/Feb/12  Updated: 13/Feb/12  Resolved: 13/Feb/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: 2.3
Security Level: All

Type: Task Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

Currently we only have support for PDO_SQLSRV, however some of the Azure/Advanced functionality strictly needs the sqlsrv extension.



 Comments   
Comment by Benjamin Eberlei [ 13/Feb/12 ]

Implemented.





[DBAL-237] schema:update fails when changing from ManyToOne to OneToOne Created: 02/Feb/12  Updated: 14/Mar/12  Resolved: 14/Mar/12

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: 2.1.6
Fix Version/s: 2.2.2
Security Level: All

Type: Bug Priority: Major
Reporter: Matt Lehner Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

Symfony 2.0.9



 Description   

If a relation is changed from ManyToOne to OneToOne a Mysql exception 1025 is thrown because schema:update attempts to drop the indexes without first dropping the foreign keys. This seems to happen since the foreign keys are not deleted from the entity.. but the indexes change type (from index to unique).

Incorrect output from --dump-sql

DROP INDEX IDX_9AFB9A3755EB82D0 ON tapi_phone;
DROP INDEX IDX_9AFB9A37A6A12EC1 ON tapi_phone;
ALTER TABLE tapi_phone ADD location_id INT DEFAULT NULL, CHANGE extension extension VARCHAR(255) DEFAULT NULL, CHANGE protocol protocol VARCHAR(255) DEFAULT NULL;
ALTER TABLE tapi_phone ADD CONSTRAINT FK_9AFB9A3764D218E FOREIGN KEY (location_id) REFERENCES tapi_location(id);
CREATE UNIQUE INDEX UNIQ_9AFB9A37F85E0677 ON tapi_phone (username);
CREATE UNIQUE INDEX UNIQ_9AFB9A37B728E969 ON tapi_phone (mac_address);
CREATE UNIQUE INDEX UNIQ_9AFB9A3755EB82D0 ON tapi_phone (default_user_id);
CREATE INDEX IDX_9AFB9A3764D218E ON tapi_phone (location_id);
CREATE UNIQUE INDEX UNIQ_9AFB9A37A6A12EC1 ON tapi_phone (registered_user_id)

Expected output from --dump-sql

ALTER TABLE tapi_phone DROP FOREIGN KEY FK_9AFB9A3755EB82D0;
DROP INDEX IDX_9AFB9A3755EB82D0 ON tapi_phone;
ALTER TABLE tapi_phone DROP FOREIGN KEY FK_9AFB9A37A6A12EC1;
DROP INDEX IDX_9AFB9A37A6A12EC1 ON tapi_phone;
ALTER TABLE tapi_phone ADD location_id INT DEFAULT NULL, CHANGE extension extension VARCHAR(255) DEFAULT NULL, CHANGE protocol protocol VARCHAR(255) DEFAULT NULL;
ALTER TABLE tapi_phone ADD CONSTRAINT FK_9AFB9A3764D218E FOREIGN KEY (location_id) REFERENCES tapi_location(id);
ALTER TABLE tapi_phone ADD CONSTRAINT FK_9AFB9A3755EB82D0 FOREIGN KEY (default_user_id) REFERENCES tapi_user (id);
ALTER TABLE tapi_phone ADD CONSTRAINT FK_9AFB9A37A6A12EC1 FOREIGN KEY (registered_user_id) REFERENCES tapi_user (id);
CREATE UNIQUE INDEX UNIQ_9AFB9A37F85E0677 ON tapi_phone (username);
CREATE UNIQUE INDEX UNIQ_9AFB9A37B728E969 ON tapi_phone (mac_address);
CREATE UNIQUE INDEX UNIQ_9AFB9A3755EB82D0 ON tapi_phone (default_user_id);
CREATE INDEX IDX_9AFB9A3764D218E ON tapi_phone (location_id);
CREATE UNIQUE INDEX UNIQ_9AFB9A37A6A12EC1 ON tapi_phone (registered_user_id);



 Comments   
Comment by