Changeset 264


Ignore:
Timestamp:
06/25/09 21:44:34 (3 years ago)
Author:
sambauers
Message:

Fix SQL parser issues brought about by [262]

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/class.bp-sql-schema-parser.php

    r262 r264  
    1717                } 
    1818 
     19                $null = ''; 
    1920                if ( $column_data['Null'] == 'NO' ) { 
    2021                        $null = 'NOT NULL'; 
    21                 } else { 
    22                         $null = ''; 
    2322                } 
    2423 
     
    137136                                                'Seq_in_index' => (string) ( $_index_columns_index + 1 ), 
    138137                                                'Column_name'  => $_matches_column[1], 
    139                                                 'Sub_part'     => isset($_matches_column[2]) ? $_matches_column[2] : null, 
     138                                                'Sub_part'     => ( isset( $_matches_column[2] ) && $_matches_column[2] ) ? $_matches_column[2] : null, 
    140139                                                'Index_type'   => ( 'FULLTEXT KEY' == $_index_type ) ? 'FULLTEXT' : 'BTREE' 
    141140                                        ); 
     
    147146 
    148147                                // Tidy the NOT NULL 
    149                                 $_matches[5] = isset($_matches[5]) ? strtoupper( preg_replace( '@\s+@', ' ', trim( $_matches[5] ) ) ) : null; 
     148                                $_matches[5] = isset( $_matches[5] ) ? strtoupper( preg_replace( '@\s+@', ' ', trim( $_matches[5] ) ) ) : ''; 
    150149 
    151150                                $_columns[$_matches[1]] = array( 
    152151                                        'Field'   => $_matches[1], 
    153                                         'Type'    => ( isset($_matches[4]) ?( is_numeric( $_matches[3] ) ) ? $_matches[2] . '(' . $_matches[3] . ')' . ( ( strtolower( $_matches[4] ) == 'unsigned' ) ? ' unsigned' : '' ) : $_matches[2] : null), 
     152                                        'Type'    => ( is_numeric( $_matches[3] ) ) ? $_matches[2] . '(' . $_matches[3] . ')' . ( ( isset( $_matches[4] ) && strtolower( $_matches[4] ) == 'unsigned' ) ? ' unsigned' : '' ) : $_matches[2], 
    154153                                        'Null'    => ( 'NOT NULL' == strtoupper( $_matches[5] ) ) ? 'NO' : 'YES', 
    155                                         'Default' => ( isset($_matches[7]) ? ( 'default' == strtolower( $_matches[7] ) && 'NULL' !== strtoupper( $_matches[8] ) ) ? trim( $_matches[8], "'" ) : null : null), 
    156                                         'Extra'   => ( isset($_matches[6]) ? ( 'auto_increment' == strtolower( $_matches[6] ) ) ? 'auto_increment' : '' : null) 
     154                                        'Default' => ( isset( $_matches[7] ) && 'default' == strtolower( $_matches[7] ) && 'NULL' !== strtoupper( $_matches[8] ) ) ? trim( $_matches[8], "'" ) : null, 
     155                                        'Extra'   => ( isset( $_matches[6] ) && 'auto_increment' == strtolower( $_matches[6] ) ) ? 'auto_increment' : '' 
    157156                                ); 
    158157                        } 
Note: See TracChangeset for help on using the changeset viewer.