<commit_before>'use strict';

class Transaction {
    /**
     * @param {Object} connection
     */
    constructor(connection) {
        this.connection = connection;
    }

    /**
     * @param {Function} callback
     */
    begin(callback) {
        this.connection.query('START TRANSACTION', callback);
    }

    /**
     * @param {Function} callback
     */
    commit(callback) {
        this.connection.query('COMMIT', (err) => {
            if (err) return callback(err);
            this.connection.release();
            return callback(null);
        });
    }

    /**
     * @param {Function} callback
     */
    rollback(callback) {
        this.connection.query('ROLLBACK', (err) => {
            if (err) return callback(err);
            this.connection.release();
            return callback(null);
        });
    }

    /**
     * @param {string} sql
     * @param {Function} callback
     */
    query(sql, callback) {
        this.connection.query(sql, callback);
    }
}

module.exports = Transaction;<commit_msg>Always release connection during commit/rollback<commit_after>'use strict';

class Transaction {
    /**
     * @param {Object} connection
     */
    constructor(connection) {
        this.connection = connection;
    }

    /**
     * @param {Function} callback
     */
    begin(callback) {
        this.connection.query('START TRANSACTION', callback);
    }

    /**
     * @param {Function} callback
     */
    commit(callback) {
        this.connection.query('COMMIT', (err) => {
            this.connection.release();
            if (err) return callback(err);
            return callback(null);
        });
    }

    /**
     * @param {Function} callback
     */
    rollback(callback) {
        this.connection.query('ROLLBACK', (err) => {
            this.connection.release();
            if (err) return callback(err);
            return callback(null);
        });
    }

    /**
     * @param {string} sql
     * @param {Function} callback
     */
    query(sql, callback) {
        this.connection.query(sql, callback);
    }
}

module.exports = Transaction;
{'fraction_non_alphanumeric': 0.14420803782505912, 'fraction_numerical': 0.0, 'mean_word_length': 1.8907103825136613, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '464923', 'n_tokens_mistral': 597, 'n_tokens_neox': 584, 'n_words': 113}