src-d / gitbase

SQL interface to git repositories, written in Go. https://docs.sourced.tech/gitbase
Apache License 2.0
2.07k stars 123 forks source link

LOC function is returning external library object that might change #927

Closed ajnavarro closed 5 years ago

ajnavarro commented 5 years ago

This query from the documentation:

SELECT
    LANGUAGE(file_path, blob_content) as lang,
    SUM(JSON_EXTRACT(LOC(file_path, blob_content), '$.Code')) as code,
    SUM(JSON_EXTRACT(LOC(file_path, blob_content), '$.Comments')) as comments,
    SUM(JSON_EXTRACT(LOC(file_path, blob_content), '$.Blanks')) as blanks,
    COUNT(1) as files
FROM commit_files
NATURAL JOIN refs
NATURAL JOIN blobs
WHERE ref_name='HEAD'
GROUP BY lang;

Actually is not working.

After updating goloc (a library that is used under the hood), they changed the output struct and instead of Code the output now is code and so on.

We should wrap that output struct to be sure that output JSON won't change if library changes.