<commit_before>package com.theah64.mock_api.database

import com.theah64.mock_api.models.Route
import com.theah64.webengine.database.BaseTable
import com.theah64.webengine.database.Connection
import com.theah64.webengine.database.querybuilders.QueryBuilderException

import java.sql.PreparedStatement
import java.sql.SQLException
import java.util.ArrayList

/**
 * Created by theapache64 on 14/5/17.
 */
class Routes private constructor() : BaseTable<Route>("routes") {

    @Throws(SQLException::class)
    override fun addv3(route: Route): String {
        var error: String? = null
        var id: String? = null
        val query = "INSERT INTO routes (project_id, name, default_response, description, is_secure, delay,external_api_url,updated_at_in_millis,method,json_req_body) VALUES (?,?,?,?,?,?,?,?,?,?);"
        val con = Connection.getConnection()
        try {
            val ps0 = con.prepareStatement(query, PreparedStatement.RETURN_GENERATED_KEYS)
            ps0.setString(1, route.projectId)
            ps0.setString(2, route.name)
            ps0.setString(3, route.defaultResponse)
            ps0.setString(4, route.description)
            ps0.setBoolean(5, route.isSecure)
            ps0.setLong(6, route.delay)
            ps0.setString(7, route.externalApiUrl)
            ps0.setLong(8, System.currentTimeMillis())
            ps0.setString(9, route.method)
            ps0.setString(10, route.jsonReqBody)

            ps0.executeUpdate()
            val rs = ps0.generatedKeys
            if (rs.first()) {
                id = rs.getString(1)
            }
            rs.close()
            ps0.close()

            route.id = id<commit_msg>🐛 Fixed add route bug'<commit_after>package com.theah64.mock_api.database

import com.theah64.mock_api.models.Route
import com.theah64.webengine.database.BaseTable
import com.theah64.webengine.database.Connection
import com.theah64.webengine.database.querybuilders.QueryBuilderException

import java.sql.PreparedStatement
import java.sql.SQLException
import java.util.ArrayList

/**
 * Created by theapache64 on 14/5/17.
 */
class Routes private constructor() : BaseTable<Route>("routes") {

    @Throws(SQLException::class)
    override fun addv3(route: Route): String {
        var error: String? = null
        var id: String? = null
        val query = "INSERT INTO routes (project_id, name, default_response, description, is_secure, delay,external_api_url,updated_at_in_millis,method,request_body_type,json_req_body) VALUES (?,?,?,?,?,?,?,?,?,?,?);"
        val con = Connection.getConnection()
        try {
            val ps0 = con.prepareStatement(query, PreparedStatement.RETURN_GENERATED_KEYS)
            ps0.setString(1, route.projectId)
            ps0.setString(2, route.name)
            ps0.setString(3, route.defaultResponse)
            ps0.setString(4, route.description)
            ps0.setBoolean(5, route.isSecure)
            ps0.setLong(6, route.delay)
            ps0.setString(7, route.externalApiUrl)
            ps0.setLong(8, System.currentTimeMillis())
            ps0.setString(9, route.method)
            ps0.setString(10, route.requestBodyType)
            ps0.setString(11, route.jsonReqBody)

            ps0.executeUpdate()
            val rs = ps0.generatedKeys
            if (rs.first()) {
                id = rs.getString(1)
            }
            rs.close()
            ps0.close()

            route.id = id
{'fraction_non_alphanumeric': 0.11201866977829639, 'fraction_numerical': 0.026546091015169197, 'mean_word_length': 2.6595517609391677, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '359561', 'n_tokens_mistral': 1070, 'n_tokens_neox': 1040, 'n_words': 189}