#1645: Oracle sequence not being used
--------------------------+-------------------------------------------------
  Reporter:  tchakkapark  |       Owner:  romanb               
      Type:  defect       |      Status:  new                  
  Priority:  blocker      |   Milestone:  1.0.4                
 Component:  Record       |     Version:  1.1-DEV              
Resolution:               |    Keywords:  oracle sequence      
  Has_test:  0            |    Mystatus:  Pending Core Response
 Has_patch:  0            |  
--------------------------+-------------------------------------------------
Old description:

> Using Symfony 1.1, sfDoctrinePlugin with 1.1 libraries from latest SVN (I
> update it every day).
>
> ----
> Edit: Just realized there is a Doctrine_Sequence_Oracle, and the
> definitions look right, I wonder if the wrong method is being called?
> ----
>
> I have the following definition in my schema:
>

> {{{
> EVENT_ATTENDEES:
>   tableName: EVENT_ATTENDEES
>   columns:
>     group_id:
>       notnull: true
>       type: integer(12)
>     event_attendee_id:
>       notnull: true
>       type: integer(12)
>       primary: true
>       sequence: event_attendee_id
>
> And, also tried
>
> EVENT_ATTENDEES:
>   tableName: EVENT_ATTENDEES
>   columns:
>     group_id:
>       notnull: true
>       type: integer(12)
>     event_attendee_id:
>       notnull: true
>       type: integer(12)
>       primary: true
>       sequence: [event_attendee_id, sequence]
> }}}
>
> In my database, I have a sequence defined called event_attendee_id, and
> it's currently at 98682. However, when I create an object and save it:
>
> {{{
>       $register                = new EVENT_ATTENDEES();
>       $register->group_id      = $contact["group_id"];
>       $register->save();
> }}}
>
> It actually sets the $register->event_attendee_id to 1, 2, 3, etc in
> normal sequence. I'm unsure where it's getting the values from, but it
> needs to use the event_attendee_id sequence.
>
> In oracle, to get this sequence, you do a:
>
> {{{
>
> SQL> select event_attendee_id.nextval FROM dual;
>
>    NEXTVAL
> ----------
>      98682
>
> SQL> select event_attendee_id.nextval FROM dual;
>
>    NEXTVAL
> ----------
>      98683
> }}}
>
> The NEXTVAL column contains the next sequence number. "Dual" is a dummy
> table of sorts that is common on all installations of Oracle where one
> can run any kind of Oracle function against for an output.
>
> To create sequences in Oracle, one would do the following
>
> {{{
> CREATE SEQUENCE EVENT_ATTENDEE_ID  MINVALUE 1 MAXVALUE
> 999999999999999999999999999 INCREMENT BY 1
> }}}

New description:

 Using Symfony 1.1, sfDoctrinePlugin with 1.1 libraries from latest SVN (I
 update it every day).

 ----
 Edit: Just realized there is a Doctrine_Sequence_Oracle, and the
 definitions look right, I wonder if the wrong method is being called?
 ----

 I have the following definition in my schema:


 {{{
 EVENT_ATTENDEES:
   tableName: EVENT_ATTENDEES
   columns:
     group_id:
       notnull: true
       type: integer(12)
     event_attendee_id:
       notnull: true
       type: integer(12)
       primary: true
       sequence: event_attendee_id

 And, also tried

 EVENT_ATTENDEES:
   tableName: EVENT_ATTENDEES
   columns:
     group_id:
       notnull: true
       type: integer(12)
     event_attendee_id:
       notnull: true
       type: integer(12)
       primary: true
       sequence: [event_attendee_id, sequence]
 }}}

 In my database, I have a sequence defined called event_attendee_id, and
 it's currently at 98682. However, when I create an object and save it:

 {{{
       $register                = new EVENT_ATTENDEES();
       $register->group_id      = $contact["group_id"];
       $register->save();
 }}}

 It actually sets the $register->event_attendee_id to 1, 2, 3, etc in
 normal sequence. I'm unsure where it's getting the values from, but it
 needs to use the event_attendee_id sequence.

 In oracle, to get this sequence, you do a:

 {{{

 SQL> select event_attendee_id.nextval FROM dual;

    NEXTVAL
 ----------
      98682

 SQL> select event_attendee_id.nextval FROM dual;

    NEXTVAL
 ----------
      98683
 }}}

 The NEXTVAL column contains the next sequence number. "Dual" is a dummy
 table of sorts that is common on all installations of Oracle where one can
 run any kind of Oracle function against for an output.

 To create sequences in Oracle, one would do the following

 {{{
 CREATE SEQUENCE EVENT_ATTENDEE_ID  MINVALUE 1 MAXVALUE
 999999999999999999999999999 INCREMENT BY 1
 }}}

Comment (by tchakkapark):

 Got myself a debugger to see what's going on. It seems to be ignoring the
 custom sequence column alltogether when it's using getSequenceName.

 The input of $seqName is "event_attendee_id", but the output from:

 {{{
 $sequenceName =
 $this->conn->quoteIdentifier($this->conn->formatter->getSequenceName($seqName),
 true);
 }}}

 $sequenceName becomes "event_attendee_id'''_seq'''". From what I
 understand in the documentation, there should be no postfixed string
 appended:

 {{{
 In the following example we do not wish to change global configuration
 '''we just want to make the id column to use
 sequence table called book_sequence'''. It can be done as follows:

 Listing .120

 <?php

 class Book extends Doctrine_Record {
     public function setTableDefinition()
     {
         $this->hasColumn('id', 'integer', null, array('primary',
 'sequence' => 'book_sequence'));
         $this->hasColumn('name', 'string');
     }
 }

 ?>

 Listing .121

 ---
 Book:
   columns:
     id:
       type: integer
       primary: true
       sequence: book_sequence
     name: string
 }}}

 The problem seems to be specifically line 235 (\Doctrine\Formatter.php),
 as when I come out of the return statement, the $sqn gets postfix'd:

 {{{
     public function getSequenceName($sqn)
     {
         return
 sprintf($this->conn->getAttribute(Doctrine::ATTR_SEQNAME_FORMAT),
             preg_replace('/[^a-z0-9_\$.]/i', '_', $sqn));
     }
 }}}

 However, if a sequence name is specified like I have it in my schema def,
 it should completely be skipping that function.

-- 
Ticket URL: <http://trac.doctrine-project.org/ticket/1645#comment:6>
Doctrine <http://www.phpdoctrine.org>
PHP Doctrine Object Relational Mapper
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"doctrine-svn" group.
 To post to this group, send email to [email protected]
 To unsubscribe from this group, send email to [EMAIL PROTECTED]
 For more options, visit this group at 
http://groups.google.co.uk/group/doctrine-svn?hl=en-GB
-~----------~----~----~----~------~----~------~--~---

Reply via email to