Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#62 Metrics data download broken in 1.9.4-rc2 with SQL Server

closed-fixed
nobody
None
5
2007-09-25
2007-09-17
Steve Kinsman
No

1.9.4-rc2 introduced some calls to LOWER() in Metrics.pm that don't work with SQL Server as LOWER() works only on varchar or data types that implicitly convert to varchar. See:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_la-lz_1pki.asp

topichistory.reviewers and topichistory.cc are of type ntext(16) so require explicit casting.
In sub _get_topic_history_rows() this seems to work for me:
'LOWER(CAST(topichistory.reviewers AS varchar(16))), ' .
'LOWER(CAST(topichistory.cc AS varchar(16))), ' .

but I'm not very familiar with this stuff so I can't be sure this is right.

Also there are many other new LOWER() calls in this version of Metrics.pm that I haven't checked - I've just hacked a workaround for the problem I found.

Discussion

  • David Sitsky
    David Sitsky
    2007-09-25

    Logged In: YES
    user_id=208928
    Originator: NO

    This has been fixed now - in fact there is an easier solution. Around line 800 in Metrics.pm, remove the use of LOWER(), and simply call the lc() perl function further below. The other uses of LOWER() in the code are fine, since they operate on nvarchar() fields. Thanks for your report.

    # Setup the prepared statements.
    my $select_topic = $dbh->prepare_cached('SELECT topichistory.author, ' .
    'topichistory.title, ' .
    'topichistory.description, ' .
    'topichistory.state, ' .
    'topichistory.modified_ts, ' .
    'topichistory.version, ' .
    'topichistory.repository, ' .
    'project.name, ' .
    'topichistory.reviewers, ' .
    'topichistory.cc, ' .
    'topichistory.modified_by_user ' .
    'FROM topichistory, project ' .
    'WHERE topichistory.topicid = ? AND ' .
    'topichistory.projectid = project.id ' .
    'ORDER BY topichistory.version');

    $select_topic->execute($self->{topicid});

    while ( my @row_array = $select_topic->fetchrow_array) {
    my ($author,$title,$description,$state,$modified_ts, $version,
    $repository,$project,$reviewers,$cc, $modified_by) = @row_array;

    my %entry = (
    author=>$author,
    title=>decode_utf8($title),
    description=>decode_utf8($description),
    state=>$state,
    modified_ts=>$modified_ts,
    version=>$version,
    repository=>$repository,
    project=>decode_utf8($project),
    reviewers=>lc($reviewers),
    cc=>lc($cc),
    modified_by=>lc($modified_by)
    );

     
  • David Sitsky
    David Sitsky
    2007-09-25

    • status: open --> closed-fixed