Skip to content

Loading…

DBAL-67: OCI8: schema-tool:update is modifying not null boolean - NUMBER(1) columns to not null #1890

Closed
doctrinebot opened this Issue · 5 comments

2 participants

@doctrinebot

Jira issue originally created by user adrive:

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")
);
@doctrinebot

Comment created by @beberlei:

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?

@doctrinebot

Comment created by adrive:

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.

@doctrinebot

Comment created by @beberlei:

Fixed

@doctrinebot

Issue was closed with resolution "Fixed"

@doctrinebot doctrinebot added the Bug label
@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.0-RC4 milestone
@doctrinebot doctrinebot closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.