<commit_before>var scanner = require("./scanner"), identifier = 0, __slice = [].slice;

function die () {
  console.log.apply(console, __slice.call(arguments, 0));
  process.exit(1);
}

function say () { console.log.apply(console, __slice.call(arguments, 0)) }

function extend (to, from) {
  for (var key in from) to[key] = from[key];
  return to;
}

// Too many flavors of signature, only one necesary.
exports.update = function(definition) {
  var splat = __slice.call(arguments, 1), operation, key, object, update, where, star;
  if (typeof definition === "object" && splat.length === 0) {
    operation = { type: "update" };
    for (key in definition) {
      operation[key] = definition[key];
    }
  } else {
    update = scanner.mutation(definition, true);
    if (splat.length === 2) {
      where = splat[0], object = splat[1];
    } else {
      object = where = splat[0];
    }
    operation = {
      type: "update",
      schema: update.schema,
      table: update.table,
      literals: update.literals,
      parameters: {},
      where: {}
    };
    update.where.forEach(function (column) {
      operation.where[column] = where[column];
    });
    if (update.columns.length == 0) {
      star = Object.keys(operation.literals).length == 0;
    } else {
      update.columns.forEach(function (column) {
        if (column === "*") {
          star = true;
        } else {
          operation.parameters[column] = object[column];
        }
      });
    }
    if (star) {
      for (key in object) {
        if (update.where.indexOf(key) == -1) {
          operation.parameters[key] = object[key];
        }
      }
    }
  }
  return operation;
};

exports["delete"] = function(definition, object) {
  var key, operation, mutation;
  if (typeof definition === "object") {
    operation = {
      type: "delete"
    };
    for (key in definition) {
      operation[key] = definition[key];
    }
  } else {
    mutation = scanner.mutation(definition);
    operation = {
      type: "delete",
      schema: mutation.schema,
      table: mutation.table,
      where: {}
    };
    if (mutation.where.length === 0) {
      for (key in object) {
        operation.where[key] = object[key];
      }
    } else {
      mutation.where.forEach(function (key) {
        operation.where[key] = object[key];
      });
    }
  }
  return operation;
};<commit_msg>Fix missing schema in by object mutations.<commit_after>var scanner = require("./scanner"), identifier = 0, __slice = [].slice;

function die () {
  console.log.apply(console, __slice.call(arguments, 0));
  process.exit(1);
}

function say () { console.log.apply(console, __slice.call(arguments, 0)) }

function extend (to, from) {
  for (var key in from) to[key] = from[key];
  return to;
}

// Too many flavors of signature, only one necesary.
exports.update = function(definition) {
  var splat = __slice.call(arguments, 1), operation, key, object, update, where, star;
  if (typeof definition === "object" && splat.length === 0) {
    operation = { type: "update" };
    for (key in definition) {
      operation[key] = definition[key];
    }
    if (!operation.schema) operation.schema = 'public';
  } else {
    update = scanner.mutation(definition, true);
    if (splat.length === 2) {
      where = splat[0], object = splat[1];
    } else {
      object = where = splat[0];
    }
    operation = {
      type: "update",
      schema: update.schema,
      table: update.table,
      literals: update.literals,
      parameters: {},
      where: {}
    };
    update.where.forEach(function (column) {
      operation.where[column] = where[column];
    });
    if (update.columns.length == 0) {
      star = Object.keys(operation.literals).length == 0;
    } else {
      update.columns.forEach(function (column) {
        if (column === "*") {
          star = true;
        } else {
          operation.parameters[column] = object[column];
        }
      });
    }
    if (star) {
      for (key in object) {
        if (update.where.indexOf(key) == -1) {
          operation.parameters[key] = object[key];
        }
      }
    }
  }
  return operation;
};

exports["delete"] = function(definition, object) {
  var key, operation, mutation;
  if (typeof definition === "object") {
    operation = {
      type: "delete"
    };
    for (key in definition) {
      operation[key] = definition[key];
    }
    if (!operation.schema) operation.schema = 'public';
  } else {
    mutation = scanner.mutation(definition);
    operation = {
      type: "delete",
      schema: mutation.schema,
      table: mutation.table,
      where: {}
    };
    if (mutation.where.length === 0) {
      for (key in object) {
        operation.where[key] = object[key];
      }
    } else {
      mutation.where.forEach(function (key) {
        operation.where[key] = object[key];
      });
    }
  }
  return operation;
};
{'fraction_non_alphanumeric': 0.15468141774226593, 'fraction_numerical': 0.005736529399713174, 'mean_word_length': 2.4526166902404527, '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': '7074457', 'n_tokens_mistral': 1546, 'n_tokens_neox': 1512, 'n_words': 358}