[DBAL-289] Wrong diff between Oracle 'Date' type and Metadata 'Date' type Created: 30/May/12  Updated: 24/Dec/13  Resolved: 24/Dec/13

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

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

Oracle Express 11g and doctrine-dbal 2.2.2



 Description   

Hi,
I want to update my schema but I am getting the following error message:

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

--dump-sql says:

ALTER TABLE CONSIGNMENTS MODIFY (SDGDATE  DATE DEFAULT NULL);

The current table structure looks like that:

Column Name Data Type Nullable Default Primary Key
SDGDATE DATE Yes NULL

Mapping definition:

/**
 * @ORM\Column(name="SDGDATE",type="date",nullable=true)
 */
private $sdgdate;

I think there is a problem with the comparison between Oracles 'Date' type and the Metadata 'Date' type. I am used to use MySQL as DBMS but our customer uses Oracle. MySQL's 'datetime' and Oracle's 'date' type are store the same data.

I am not sure what should be done here. Because this could lead to confusion for all Oracle user.

Maybe there could be a request to the platform in the Schema Comparator here:

public function diffColumn(Column $column1, Column $column2)
{
    $changedProperties = array();
    if ( $column1->getType() != $column2->getType() ) {
        $changedProperties[] = 'type';
    }
    // ...
}


 Comments   
Comment by Christian S. [ 30/May/12 ]

When I put a breakpoint on the second line of the diffColumn method in my IDE and stop there during debugging I have those variable values:

$this				Doctrine\DBAL\Schema\Comparator		
$changedProperties		array[0]		
$column1			Doctrine\DBAL\Schema\Column		
  _type				Doctrine\DBAL\Types\DateTimeType	<-- datetime
  _precision			integer		10	
  _scale			integer		0	
  _unsigned			boolean		0	
  _fixed			boolean		0	
  _notnull			boolean		0	
  _autoincrement		boolean		0	
  _platformOptions		array[0]		
  _comment			string		""	
  _customSchemaOptions		array[0]		
  _name				string		"SDGDATE"	
  _quoted			boolean		0	
$column2			Doctrine\DBAL\Schema\Column		
  _type				Doctrine\DBAL\Types\DateType		<-- date
  _precision			integer		0	
  _scale			integer		0	
  _unsigned			boolean		0	
  _fixed			boolean		0	
  _notnull			boolean		0	
  _autoincrement		boolean		0	
  _platformOptions		array[1]		
  _customSchemaOptions		array[0]		
  _name				string		"SDGDATE"	
  _quoted			boolean		0	

You see that there are different types. But it would be nice if the comparison would say: "Theay are equal - no diff"

Comment by Benjamin Eberlei [ 08/Jul/12 ]

This issue can't be fixed. Doctrine has this type abstraction here which prevents a special case fix here. The solution in this case is obvious, set the type to "datetime" on Oracle.

Comment by Christian S. [ 22/Aug/12 ]

Sorry, this issue commes up again.

Shipment:
  type: entity
  fields:
    id:
      type: integer
      id: true
      generator:
        strategy: AUTO
    pickupDate:
      type: date
      column: pickup_date
    pickupTimeFrom:
      type: time
      column: pickup_time_from
  lifecycleCallbacks: {  }

When I update my schema with the above YAML mapping, I always get the following error although I haven't changed anything at the mapping.


C:\projects\xyz\trunk>php app\console doctrine:schema:update --force
Updating database schema...
Der Befehl "stty" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.

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

C:\projects\osl\trunk>php app\console doctrine:schema:update --dump-sql
ALTER TABLE SHIPMENT MODIFY (pickup_date DATE NOT NULL, pickup_time_from DATE NOT NULL)

Okay, I could change the types to 'datetime', but what if I have to move to MySQL? I just want to store 'date' and 'time', not 'datetime'.

Comment by Steve Müller [ 21/Nov/13 ]

I think the problem is not the types used but the ALTER TABLE statement generated for Oracle. I think this has been fixed in the current master.

See: https://github.com/doctrine/dbal/commit/eee502c9ef34322c12607dafb4e1ef1ee8ea8daa

Can you please have a look if this still occurrs with current master?

Comment by Christian S. [ 21/Nov/13 ]

Sorry, I can't test it anymore, because the project is not set up anymore. But the change seems to be the solution
I think the issue could be closed.

Comment by Steve Müller [ 23/Dec/13 ]

Christian S. This ticket is somehow in status "Awaiting Feedback". I cannot resolve this. Can you please check if you can do anything about the status. Otherwise this ticket will still show up as unresolved.

Comment by Christian S. [ 23/Dec/13 ]

Sorry, I have no permissions to close the bug. I'll contact Benjamin

Comment by Benjamin Eberlei [ 24/Dec/13 ]

Was fixed in another ticket

Generated at Fri Oct 24 13:06:32 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.