Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

OraclePlatform sequence naming for primary keys #278

Merged
merged 3 commits into from Mar 12, 2013

Conversation

Projects
None yet
4 participants
Contributor

jrjohnson commented Mar 2, 2013

Change Oracle sequence generation to match what is being created by ORM and other platforms in the form of $table_$column_SQL instead of $table_SEQ

This is a solution for doctrine/migrations#112

Change Oracle sequence generation to match what is being created by O…
…RM and other platforms in the form of $table_$column_SQL instead of $table_SEQ

Hello,

thank you for positing this Pull Request. I have automatically opened an issue on our Jira Bug Tracker for you with the details of this Pull-Request. See the Link:

http://doctrine-project.org/jira/browse/DBAL-455

Owner

beberlei commented Mar 3, 2013

This code needs tests, i am not sure this is the right change. Shouldnt the sequence name be reused in the Trigger definition later in the method?

Owner

guilhermeblanco commented Mar 3, 2013

First, it's missing test.
Second, is this really a bug? Doctrine atm only supports 1 sequence per entity.

Contributor

jrjohnson commented Mar 4, 2013

I have no idea if this is the right path. Duplicating my report to migrations we're dealing with this problem, and I'm hoping that this is the solution. If I'm on the wrong path here and someone can point me in the right direction I will dig deeper somewhere else.

I'm getting different results from doctrine ORM and doctrine migrations for creating auto incrementing id columns in oracle.

Migrations is missing the column name in the pattern {dbname}_{column}_seq. It looks like there are two different strategies for generating sequence names between ORM and DBAL/Platform/OraclePlatform.

Creating my entity in PHP annotations like:

/**
 * @Entity
 * @Table(name="types")
 * */
class Type
{

    /**
     * @Id
     * @Column(type="bigint")
     * @GeneratedValue(strategy="AUTO")
     */
    private $id;
}

and running schema-tool:update --dump-sql results in:

CREATE SEQUENCE types_id_seq START WITH 1 MINVALUE 1 INCREMENT BY 1

doing this in doctrine migrations:

public function up(\Doctrine\DBAL\Schema\Schema $schema)
{
  $table = $schema->createTable('types');
  $table->addColumn('id', 'bigint', array('autoincrement' => true));
  $table->setPrimaryKey(array('id'), 'primary');
}

results in:

CREATE SEQUENCE TYPES_SEQ START WITH 1 MINVALUE 1 INCREMENT BY 1
Contributor

jrjohnson commented Mar 4, 2013

@guilhermeblanco is this what you meant by re-using the sequence name? It did need to be forced uppercase.

beberlei added a commit that referenced this pull request Mar 12, 2013

Merge pull request #278 from jrjohnson/master
OraclePlatform sequence naming for primary keys

@beberlei beberlei merged commit f69a44e into doctrine:master Mar 12, 2013

1 check passed

default The Travis build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment