<commit_before>//
//  Convenience.swift
//  PostgresStORM
//
//  Created by <NAME> on 2016-10-04.
//
//


import StORM

extension PostgresStORM {

	// create is in main PostgresStORM now.

	/// Deletes one row, with an id
	/// Presumes first property in class is the id.
	public func delete() throws {
		let (idname, idval) = firstAsKey()
		do {
			try exec(deleteSQL(self.table(), idName: idname), params: [String(describing: idval)])
		} catch {
			self.error = StORMError.error(error.localizedDescription)
			throw error
		}
	}

	public func delete(_ id: Any) throws {
		let (idname, _) = firstAsKey()
		do {
			try exec(deleteSQL(self.table(), idName: idname), params: [String(describing: id)])
		} catch {
			self.error = StORMError.error(error.localizedDescription)
			throw error
		}
	}

	public func get(_ id: Any) throws {
		let (idname, _) = firstAsKey()
		do {
			try select(whereclause: "\(idname) = $1", params: [id], orderby: [])
		} catch {
			throw error
		}
	}

	public func get() throws {
		let (idname, idval) = firstAsKey()
		do {
			try select(whereclause: "\(idname) = $1", params: ["\(idval)"], orderby: [])
		} catch {
			throw error
		}
	}


	public func find(_ data: [(String, Any)]) throws {
		let (idname, _) = firstAsKey()

		var paramsString = [String]()
		var set = [String]()
		for i in 0..<data.count {
			paramsString.append("\(data[i].1)")
			set.append("\(data[i].0) = $\(i+1)")
		}

		do {
			try select(whereclause: set.joined(separator: " AND "), params: paramsString, orderby: [idname])
		} catch {
			print("Error detacted: \(error)")
		}

	}
}<commit_msg>properly quoting the column name in the get methods<commit_after>//
//  Convenience.swift
//  PostgresStORM
//
//  Created by <NAME> on 2016-10-04.
//
//


import StORM

extension PostgresStORM {

	// create is in main PostgresStORM now.

	/// Deletes one row, with an id
	/// Presumes first property in class is the id.
	public func delete() throws {
		let (idname, idval) = firstAsKey()
		do {
			try exec(deleteSQL(self.table(), idName: idname), params: [String(describing: idval)])
		} catch {
			self.error = StORMError.error(error.localizedDescription)
			throw error
		}
	}

	public func delete(_ id: Any) throws {
		let (idname, _) = firstAsKey()
		do {
			try exec(deleteSQL(self.table(), idName: idname), params: [String(describing: id)])
		} catch {
			self.error = StORMError.error(error.localizedDescription)
			throw error
		}
	}

	public func get(_ id: Any) throws {
		let (idname, _) = firstAsKey()
		do {
			try select(whereclause: "\"\(idname)\" = $1", params: [id], orderby: [])
		} catch {
			throw error
		}
	}

	public func get() throws {
		let (idname, idval) = firstAsKey()
		do {
			try select(whereclause: "\"\(idname)\" = $1", params: ["\(idval)"], orderby: [])
		} catch {
			throw error
		}
	}


	public func find(_ data: [(String, Any)]) throws {
		let (idname, _) = firstAsKey()

		var paramsString = [String]()
		var set = [String]()
		for i in 0..<data.count {
			paramsString.append("\(data[i].1)")
			set.append("\(data[i].0) = $\(i+1)")
		}

		do {
			try select(whereclause: set.joined(separator: " AND "), params: paramsString, orderby: [idname])
		} catch {
			print("Error detacted: \(error)")
		}

	}
}
{'fraction_non_alphanumeric': 0.16666666666666666, 'fraction_numerical': 0.008641975308641974, 'mean_word_length': 3.181935483870968, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2194630', 'n_tokens_mistral': 1342, 'n_tokens_neox': 1180, 'n_words': 308}