<commit_before>"use strict";

var log = require('./log');
var db = require('./DatabaseManager');
var qb = require('./QueryBuilder');
var compare = require('./Compare');
var generator = require('./IDGenerator');

var dbm = new db.DatabaseManager();


/** DBRow
 ** This object is capable of querying the database to retrieve a row, or multiple rows, from the database
 ** The retrieved row(s) cannot be directly accessed, you must use obj.getValue
 ** All querying methods must be used with promises or else the row may not be set when it is accessed.
 **
 ** table: The table name of the table the row you want to access is on
**/
exports.DBRow = function(table) {
	var querySort = "";
	var returnLimit = "";
	var currentIndex = -1;
	var rows = [];
	var currentRow = {}; // left as an empty object in case we are creating a new row

	if (!table){
		log.error("No table was specified for the DB row, all queries will fail!! Object instantiation terminated.");
		return;
	}

	/******************* Querying Methods *******************/

	/** getRow(systemId)
	 ** systemID: the id of the row you want returned
	 ** Resolves if the query is sucessful, rejects with the error if the query has an error
	 **
	 ** getRow() gets the single row from the table specified by using the ID of the row
	 **
	 ** Note: if a row does not match this ID, underfined will be returned and the promise is not rejected.
	**/
	this.getRow = function(systemId) {
		log.log("GET for table '" + table + "' with id: '" + currentRow.id + "'");
		var qs = qb.get(table, systemId);
		return new Promise(function(resolve, reject) {
			dbm.query(qs).then(function(row){
				rows = row;
				currentIndex = 0;
				currentRow = rows[currentIndex];
				resolve();
			}, function(err){
				currentRow = {};
				rows = [];
				reject(err);
			});
		});
	}<commit_msg>FIX: Id is properly logged in delete queries<commit_after>"use strict";

var log = require('./log');
var db = require('./DatabaseManager');
var qb = require('./QueryBuilder');
var compare = require('./Compare');
var generator = require('./IDGenerator');

var dbm = new db.DatabaseManager();


/** DBRow
 ** This object is capable of querying the database to retrieve a row, or multiple rows, from the database
 ** The retrieved row(s) cannot be directly accessed, you must use obj.getValue
 ** All querying methods must be used with promises or else the row may not be set when it is accessed.
 **
 ** table: The table name of the table the row you want to access is on
**/
exports.DBRow = function(table) {
	var querySort = "";
	var returnLimit = "";
	var currentIndex = -1;
	var rows = [];
	var currentRow = {}; // left as an empty object in case we are creating a new row

	if (!table){
		log.error("No table was specified for the DB row, all queries will fail!! Object instantiation terminated.");
		return;
	}

	/******************* Querying Methods *******************/

	/** getRow(systemId)
	 ** systemID: the id of the row you want returned
	 ** Resolves if the query is sucessful, rejects with the error if the query has an error
	 **
	 ** getRow() gets the single row from the table specified by using the ID of the row
	 **
	 ** Note: if a row does not match this ID, underfined will be returned and the promise is not rejected.
	**/
	this.getRow = function(systemId) {
		log.log("GET for table '" + table + "' with id: '" + systemId + "'");
		var qs = qb.get(table, systemId);
		return new Promise(function(resolve, reject) {
			dbm.query(qs).then(function(row){
				rows = row;
				currentIndex = 0;
				currentRow = rows[currentIndex];
				resolve();
			}, function(err){
				currentRow = {};
				rows = [];
				reject(err);
			});
		});
	}
{'fraction_non_alphanumeric': 0.14223669923995658, 'fraction_numerical': 0.0010857763300760044, 'mean_word_length': 3.6004993757802746, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '728193', 'n_tokens_mistral': 1127, 'n_tokens_neox': 1037, 'n_words': 453}