<commit_before>"use strict";

/* norm (no-are-em)
 *
 * A SQL builder that pastes SQL together without
 * getting too fancy.
 *
 * Example Typical Usage:
 *
 * var nsql = norm().select("u.id").from("users u").where("u.id = ?", 5);
 * db.query(nsql.sql(), nsql.binds(), callback);
 *
 * Building Two Related Queries:
 *
 * var nsql = norm().select("u.id").from("users u").where("u.id > ?", 5);
 * var nsql2 = nsql.clone().where("u.id < ?", 100);
 *
 * Author: <NAME>
 * Date: March 2015
 */

function processArguments (fn, args, conjunction) {
	args.forEach(function (stmt) {
		if (Array.isArray(stmt)) {
			fn = (function (fn, sql_binds) {
				var sql = stmt[0];

				// for idempotency: must not modify statement, slice makes a copy
				var stmt_binds = stmt.slice(1);
				stmt_binds.reverse();
				stmt_binds.forEach(function (bnd) {
					if (typeof(bnd.sql) === 'function') {
						var result = bnd.sqlAndBinds();
						result.binds.reverse(); // since we're going to reverse them again...

						sql = sql.replace(/\?/, result.sql);
						
						sql_binds.push.apply(sql_binds, result.binds);
					}
					else { 
						if (!Array.isArray(bnd)) {
							bnd = [bnd];
						}

						var bndstring = bnd.map(function () { return '¿' }).join(",");
						sql = sql.replace(/\?/, bndstring);

						var bndcpy = bnd.slice(0);
						bndcpy.reverse();

						sql_binds.push.apply(sql_binds, bndcpy);
					}<commit_msg>Added comment about inverted question marks.<commit_after>"use strict";

/* norm (no-are-em)
 *
 * A SQL builder that pastes SQL together without
 * getting too fancy.
 *
 * Example Typical Usage:
 *
 * var nsql = norm().select("u.id").from("users u").where("u.id = ?", 5);
 * db.query(nsql.sql(), nsql.binds(), callback);
 *
 * Building Two Related Queries:
 *
 * var nsql = norm().select("u.id").from("users u").where("u.id > ?", 5);
 * var nsql2 = nsql.clone().where("u.id < ?", 100);
 *
 * Author: <NAME>
 * Date: March 2015
 */

function processArguments (fn, args, conjunction) {
	args.forEach(function (stmt) {
		if (Array.isArray(stmt)) {
			fn = (function (fn, sql_binds) {
				var sql = stmt[0];

				// for idempotency: must not modify statement, slice makes a copy
				var stmt_binds = stmt.slice(1);
				stmt_binds.reverse();
				stmt_binds.forEach(function (bnd) {
					if (typeof(bnd.sql) === 'function') {
						var result = bnd.sqlAndBinds();
						result.binds.reverse(); // since we're going to reverse them again...

						sql = sql.replace(/\?/, result.sql);
						
						sql_binds.push.apply(sql_binds, result.binds);
					}
					else { 
						if (!Array.isArray(bnd)) {
							bnd = [bnd];
						}

						// using '¿' to mark already processed '?'
						var bndstring = bnd.map(function () { return '¿' }).join(",");
						sql = sql.replace(/\?/, bndstring);

						var bndcpy = bnd.slice(0);
						bndcpy.reverse();

						sql_binds.push.apply(sql_binds, bndcpy);
					}
{'fraction_non_alphanumeric': 0.18053645116918846, 'fraction_numerical': 0.008940852819807428, 'mean_word_length': 2.7828348504551363, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2284639', 'n_tokens_mistral': 1257, 'n_tokens_neox': 1025, 'n_words': 241}