DBAL-289: Wrong diff between Oracle 'Date' type and Metadata 'Date' type #1468

Closed
doctrinebot opened this Issue May 30, 2012 · 9 comments

2 participants

@doctrinebot

Jira issue originally created by user naitsirch:

Hi,
I want to update my schema but I am getting the following error message:
{quote}
[Doctrine\DBAL\Driver\OCI8\OCI8Exception]
ORA-01442: column to be modified to NOT NULL is already NOT NULL
{quote}

--dump-sql says:
sqlALTER 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';
    }
    // ...
}
@doctrinebot

Comment created by naitsirch:

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"

@doctrinebot

Comment created by @beberlei:

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.

@doctrinebot

Comment created by naitsirch:

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.

{quote}{color:red}
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 (pickupdate DATE NOT NULL, pickup_timefrom DATE NOT NULL)
{color}{quote}

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'.

@doctrinebot

Comment created by @deeky666:

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: eee502c

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

@doctrinebot

Comment created by naitsirch:

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.

@doctrinebot

Comment created by @deeky666:

[~naitsirch] 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.

@doctrinebot

Comment created by naitsirch:

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

@doctrinebot

Comment created by @beberlei:

Was fixed in another ticket

@doctrinebot

Issue was closed with resolution "Fixed"

@doctrinebot doctrinebot added the Bug label Dec 6, 2015
@beberlei beberlei was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment