<commit_before>package br.tptfc.sdbc

import java.sql._
import scala.Some
import scala.Array

/**
 * Created by tptfc on 4/5/14.
 *
 */
object SQL {
  /**
   * insert SQL command
   * @param sql sql insert query
   * @param args query args
   * @param c JDBC connection
   * @return insert unique id
   */
  def insert(sql:String, args:(String,Any)*)(implicit c:Connection):Option[Long] = {
    val (query,params) = convert(sql,args:_*)
    val pStmt = c.prepareStatement(query, Statement.RETURN_GENERATED_KEYS)

    try {
      addParams(pStmt, params)
      pStmt.executeUpdate()

      val rs:ResultSet = pStmt.getGeneratedKeys

      if (rs != null && rs.next()) {
        Some(rs.getLong(1))
      } else {
        None
      }
    } finally {
      pStmt.close()
    }
  }

  /**
   * update SQL command
   *
   * @param sql sql update query
   * @param args query arguments
   * @param c connection
   * @return number of changed rows
   */
  def update(sql:String, args:(String,Any)*)(implicit c:Connection):Int = {
    val (query,params) = convert(sql,args:_*)
    val pStmt = c.prepareStatement(query)
    try {
      addParams(pStmt,params)
      pStmt.executeUpdate()
    } finally {
      pStmt.close()
    }
  }

  /**
   * execute sql
   * @param sql general sql
   * @param args query arguments
   * @param c sql connection
   */
  def execute(sql:String, args:(String,Any)*)(implicit c:Connection):Unit = {
    val (query,params) = convert(sql,args:_*)
    val pStmt = c.prepareStatement(query)

    try {
      addParams(pStmt,params)<commit_msg>[na] changed update result from Int to Long<commit_after>package br.tptfc.sdbc

import java.sql._
import scala.Some
import scala.Array

/**
 * Created by tptfc on 4/5/14.
 *
 */
object SQL {
  /**
   * insert SQL command
   * @param sql sql insert query
   * @param args query args
   * @param c JDBC connection
   * @return insert unique id
   */
  def insert(sql:String, args:(String,Any)*)(implicit c:Connection):Option[Long] = {
    val (query,params) = convert(sql,args:_*)
    val pStmt = c.prepareStatement(query, Statement.RETURN_GENERATED_KEYS)

    try {
      addParams(pStmt, params)
      pStmt.executeUpdate()

      val rs:ResultSet = pStmt.getGeneratedKeys

      if (rs != null && rs.next()) {
        Some(rs.getLong(1))
      } else {
        None
      }
    } finally {
      pStmt.close()
    }
  }

  /**
   * update SQL command
   *
   * @param sql sql update query
   * @param args query arguments
   * @param c connection
   * @return number of changed rows
   */
  def update(sql:String, args:(String,Any)*)(implicit c:Connection):Long = {
    val (query,params) = convert(sql,args:_*)
    val pStmt = c.prepareStatement(query)
    try {
      addParams(pStmt,params)
      pStmt.executeUpdate()
    } finally {
      pStmt.close()
    }
  }

  /**
   * execute sql
   * @param sql general sql
   * @param args query arguments
   * @param c sql connection
   */
  def execute(sql:String, args:(String,Any)*)(implicit c:Connection):Unit = {
    val (query,params) = convert(sql,args:_*)
    val pStmt = c.prepareStatement(query)

    try {
      addParams(pStmt,params)
{'fraction_non_alphanumeric': 0.12852168407723963, 'fraction_numerical': 0.0031655587211142765, 'mean_word_length': 2.7176470588235295, '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': '7543233', 'n_tokens_mistral': 1056, 'n_tokens_neox': 1045, 'n_words': 252}