Show
Ignore:
Timestamp:
23.10.2018 15:33:31 (8 weeks ago)
Author:
ak19
Message:

1. bugfix to GS SQLPlugout: recursive call didn't go through self variable, noticed only when processing a doc with structure (subsections). 2. Being more explicit about the params passed to gssql.pm constructor. 3. MySQL didn't let me create a table with hyphens in the tablename. So collection names that contain hyphens need to first be adjusted for use in table names.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/gssql.pm

    r32530 r32531  
    6363    # the GSDL_LIBRARY_URL env var is useful when running cmdline buildcol.pl in the linux package manager versions of GS3 
    6464     
    65     # https://stackoverflow.com/questions/7083453/copying-a-hashref-in-perl 
    66     #my $self = {'db_driver' => $params_map{'db_driver'}, 
    67     #... 
    68     #}; 
    69     # Making a shallow copy     
    70     my $self = $params_map; 
     65    # https://stackoverflow.com/questions/7083453/copying-a-hashref-in-perl  
     66    # Making a shallow copy works, and can handle unknown params: 
     67    #my $self = $params_map; 
     68 
     69    # but being explicit for class params needed for MySQL: 
     70    my $self = { 
     71    'collection_name' => $params_map->{'collection_name'}, 
     72    'db_encoding' => $params_map->{'db_encoding'} 
     73    }; 
     74 
     75    # (My)SQL doesn't like tables with - (hyphens) in their names 
     76    my $coll_name = $params_map->{'collection_name'}; 
     77    $coll_name =~ s/-/_/g; 
     78    $self->{'tablename_prefix'} = $coll_name; 
    7179 
    7280    return bless($self, $class); 
     
    350358sub get_metadata_table_name { 
    351359    my $self= shift (@_); 
    352     my $table_name = $self->{'collection_name'} . "_metadata"; 
     360    my $table_name = $self->{'tablename_prefix'} . "_metadata"; 
    353361    return $table_name; 
    354362} 
     
    358366sub get_fulltext_table_name { 
    359367    my $self= shift (@_); 
    360     my $table_name = $self->{'collection_name'} . "_fulltxt"; 
     368    my $table_name = $self->{'tablename_prefix'} . "_fulltxt"; 
    361369    return $table_name; 
    362370} 
     371 
    363372 
    364373# I can get my version of table_exists to work, but it's not so ideal