Not signed in (Sign In)
Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
    • CommentAuthorsuthern
    • CommentTimeMar 6th 2008 edited
     

    Howdy! While poking through the code to do a createTable, I discovered that you can not specify index names through a 'createTable' function.

    Here's what I propose.
    Around line 291 of AkInstaller.php replace this if(isset($column_options['index_columns'])){ $this->addIndex($table_name, $column_options['index_columns']); } with this: if(isset($column_options['index_columns'])){ if(is_array($column_options['index_columns'])) { foreach($column_options['index_columns'] as $index_column => $index_name) { $this->addIndex($table_name, $index_column, $index_name); } } ELSE { $this->addIndex($table_name, $column_options['index_columns']); } } It is also backwards compatible! Now in our installers, we can put something like this: $this->createTable('index_name_test', array('columns' => 'id,'. // reqular PRIMARY 'ListID,'. // my UNIQUE ID 'wID', // another UNIQUE 'index_columns' => array( 'ListID UNIQUE' => 'idx_ListID', 'wID UNIQUE' => 'idx_wID' ) ) ); The cool thing is that it actually works! So my question is: If this is a worthy patch, would someone who knows how create a patch?

    • CommentAuthorKaste
    • CommentTimeMar 6th 2008
     

    looks interesting. how-to create a patch depends on your client/OS. some IDEs can do this.

    svn di -r head . 
    

    in your akelos-lib-root.

    • CommentAuthorsuthern
    • CommentTimeMar 7th 2008
     

    Ok, would this be correct then? (I'm not sure how to submit it to the patch system): for AkInstaller.php

    @@ -323,11 +287,17 @@
         foreach ($columns_to_index as $column_to_index => $index_type){
             $this->addIndex($table_name, $column_to_index.($index_type != 'INDEX' ? ' '.$index_type : ''));
         }
    -
    + 
         if(isset($column_options['index_columns'])){
    -            $this->addIndex($table_name, $column_options['index_columns']);
    -
    +            if(is_array($column_options['index_columns'])) {
    +                foreach($column_options['index_columns'] as $index_column => $index_name) {
    +                    $this->addIndex($table_name, $index_column, $index_name);
    +                }
    +            } ELSE {
    +                $this->addIndex($table_name, $column_options['index_columns']);
    +            }
         }
    +
    
    • CommentAuthorKaste
    • CommentTimeMar 7th 2008
     

    looks like a patch. save it > *.diff. then login into TRAC->New ticket->attach file->Thank you ;-)

    • CommentAuthorKaste
    • CommentTimeMar 7th 2008 edited
     

    ah, the header of the diff is missing. like:

    --- lib/....php    (Revision 505)
    +++ lib/....php    (working copy)
    

    etc.

    • CommentAuthorsuthern
    • CommentTimeMar 7th 2008 edited
     

    Hmm, there are a lot of other changes inside AkInstaller.php (that I didn't make) besides just the one I listed above. Do I post the whole thing, or just this change? I'm kinda new to this whole patch system. Thanks for the patience!

    I've created a ticket http://trac.akelos.org/ticket/133 with just the text below attached as a .diff file. I hope it gets implemented! ;-)

    Index: AkInstaller.php
    ===================================================================
    --- AkInstaller.php (revision 505)
    +++ AkInstaller.php (working copy)
    @@ -323,11 +287,17 @@
         foreach ($columns_to_index as $column_to_index => $index_type){
             $this->addIndex($table_name, $column_to_index.($index_type != 'INDEX' ? ' '.$index_type : ''));
         }
    -
    + 
         if(isset($column_options['index_columns'])){
    -            $this->addIndex($table_name, $column_options['index_columns']);
    -
    +            if(is_array($column_options['index_columns'])) {
    +                foreach($column_options['index_columns'] as $index_column => $index_name) {
    +                    $this->addIndex($table_name, $index_column, $index_name);
    +                }
    +            } ELSE {
    +                $this->addIndex($table_name, $column_options['index_columns']);
    +            }
         }
    + 
         if($column_options['sequence_table'] || $this->_requiresSequenceTable($column_string)){
             $this->createSequence($table_name);
         }
    
    • CommentAuthorKaste
    • CommentTimeMar 7th 2008
     

    attach what you posted here. often there are some whitespace/line-endings changed.

    • CommentAuthorsuthern
    • CommentTimeMar 7th 2008
     

    Did it. Thanks! (and thank you to whoever corrected the spelling in 'column' in my ticket title.) ;-)

    • CommentAuthorKaste
    • CommentTimeMar 7th 2008
     

    You can see here that TRAC parsed your patch correctly.

    wonderful

Add your comments
    Username Password
  • Format comments as