Changeset 932

Show
Ignore:
Timestamp:
08/07/08 23:50:46 (20 months ago)
Author:
mpaschal
Message:

Use INSERT with conflict resolution keywords where available
BugzID: 80826

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/LinkedEntryCustomFields/plugins/LinkedEntryCustomFields/lib/LinkedEntryCustomFields/Convert.pm

    r931 r932  
    2626    radio    => [ 'choices' ], 
    2727    entry    => [ qw( weblog category_ids ) ], 
     28); 
     29 
     30my %insert_statement_for_ddl_class = ( 
     31    'MT::ObjectDriver::DDL::mysql'  => 'INSERT IGNORE INTO', 
     32    'MT::ObjectDriver::DDL::SQLite' => 'INSERT OR IGNORE INTO', 
    2833); 
    2934 
     
    284289                  ; 
    285290 
    286     # TODO: we should ignore fields that are already set, using INSERT IGNORE 
    287     # on mysql or INSERT OR IGNORE on sqlite. but if we can't support it on 
    288     # the other drivers, should we bother? should we delete conflicting data 
    289     # first from mt_entry_meta so the insert should succeed? 
     291    # TODO: should we instead delete conflicting data from mt_entry_meta so 
     292    # an INSERT without IGNORE should succeed? 
    290293    # TODO: generic multidatabase support with ORM loop? 
    291     my $insert_sql = join q{ }, 'INSERT INTO', $meta_table, 
     294    my $insert_stmt = $insert_statement_for_ddl_class{ $dbd->ddl_class } 
     295        || 'INSERT INTO';  # we'll have to error if we can't ignore conflicts 
     296    my $insert_sql = join q{ }, $insert_stmt, $meta_table, 
    292297        '(', join(q{, }, @meta_fields), ')', 
    293298        'SELECT', $id_col, q{,}, q{?}, q{,},