<commit_before>package org.fastnate.generator;

import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

import org.fastnate.generator.context.GeneratorContext;
import org.fastnate.generator.statements.EntityStatement;

import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

/**
 * An extension of an {@link EntitySqlGenerator} which writes the SQL statements directly to a database connection.
 *
 * @author <NAME>
 */
@Slf4j
public class ConnectedEntitySqlGenerator extends EntitySqlGenerator {

	/** The count of milliseconds to wait, until a log message with the current count of statements is written. */
	private static final long MILLISECONDS_BETWEEN_LOG_MESSAGES = 60 * 1000;

	private static String trimStatement(final String sql) {
		int start = 0;
		int end = sql.length();
		while (start < end) {
			final char c = sql.charAt(start);
			if (c != ';' && !Character.isWhitespace(c)) {
				break;
			}
			start++;
		}
		while (start < end) {
			final char c = sql.charAt(end - 1);
			if (c != ';' && !Character.isWhitespace(c)) {
				break;
			}
			end--;
		}
		return sql.substring(start, end);
	}

	/** The database connection that was used when creating this generator. */
	@Getter
	private final Connection connection;

	/** Used to execute all SQL statements. */
	private final Statement statement;
<commit_msg>Don't trim semikolon of "end;" statements<commit_after>package org.fastnate.generator;

import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

import org.fastnate.generator.context.GeneratorContext;
import org.fastnate.generator.statements.EntityStatement;

import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

/**
 * An extension of an {@link EntitySqlGenerator} which writes the SQL statements directly to a database connection.
 *
 * @author <NAME>
 */
@Slf4j
public class ConnectedEntitySqlGenerator extends EntitySqlGenerator {

	/** The count of milliseconds to wait, until a log message with the current count of statements is written. */
	private static final long MILLISECONDS_BETWEEN_LOG_MESSAGES = 60 * 1000;

	private static String trimStatement(final String sql) {
		// Remove surrounding whitespaces and ';' - except for "end" keyword.
		int start = 0;
		int end = sql.length();
		while (start < end) {
			final char c = sql.charAt(start);
			if (c != ';' && !Character.isWhitespace(c)) {
				break;
			}
			start++;
		}
		while (start < end) {
			final char c = sql.charAt(end - 1);
			if (c == ';') {
				final String endKeyword = "end;";
				if (sql.regionMatches(true, end - endKeyword.length(), endKeyword, 0, endKeyword.length())) {
					break;
				}
			} else if (!Character.isWhitespace(c)) {
				break;
			}
			end--;
		}
		return sql.substring(start, end);
	}

	/** The database connection that was used when creating this generator. */
	@Getter
	private final Connection connection;

	/** Used to execute all SQL statements. */
	private final Statement statement;

{'fraction_non_alphanumeric': 0.11231884057971014, 'fraction_numerical': 0.007575757575757576, 'mean_word_length': 3.8669871794871793, 'pattern_counts': {'":': 0, '<': 9, '<?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': '6207066', 'n_tokens_mistral': 1026, 'n_tokens_neox': 931, 'n_words': 291}