<commit_before><?php

/*
 * This file is part of the "RocketORM" package.
 *
 * https://github.com/RocketORM/ORM
 *
 * For the full license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Rocket\ORM\Command;

use Rocket\ORM\Console\Command\AbstractCommand;
use Rocket\ORM\Console\RocketApplication;
use Rocket\ORM\Generator\Database\Table\DatabaseTableGenerator;
use Rocket\ORM\Generator\Schema\Schema;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Output\OutputInterface;

/**
 * @author <NAME> <<EMAIL>>
 */
class RocketDatabaseInsertCommand extends AbstractCommand
{
    /**
     *
     */
    protected function configure()
    {
        $this
            ->setName('database:insert')
            ->setDescription('Insert all tables in databases. Databases should be created first.')
        ;
    }

    /**
     * @param InputInterface $input
     * @param OutputInterface $output
     *
     * @return int
     *
     * @throws \Exception
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $schemas = $this->getSchemas($this->getSchemaPath());

        // Generating SQL
        $app = new RocketApplication();
        $command = $this->getRocketBuildSqlCommand();
        $app->add($command);
        $params = [
            'command' => $command->getName(),
        ];

        if (OutputInterface::VERBOSITY_DEBUG > $output->getVerbosity()) {
            $params['-q'] = true;
        }

        $app->setAutoExit(false);
        $app->run(new ArrayInput($params), new ConsoleOutput());
        $this->debug($output, '');

        $tableGenerator = new DatabaseTableGenerator($this->getSqlOutputPath());

        /** @var Schema $schema */
        foreach ($schemas as $schema) {
            $this->verbose($output, 'Inserting tables for database "' . $schema->database . '"... ', false);
            try {
                $tableGenerator->generate($schema);
            } catch (\Exception $e) {
                $this->verbose($output, '<error>FAIL</error>');

                throw $e;
            }

            $this->verbose($output, '<info>OK</info>');
        }

        $output->writeln('<info>All tables has been inserted</info>');

        return 0;
    }

    /**
     * @return AbstractCommand
     */
    protected function getRocketBuildSqlCommand()
    {
        return new RocketGenerateSqlCommand();
    }
}
<commit_msg>fix: typo in "database:insert" command.<commit_after><?php

/*
 * This file is part of the "RocketORM" package.
 *
 * https://github.com/RocketORM/ORM
 *
 * For the full license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Rocket\ORM\Command;

use Rocket\ORM\Console\Command\AbstractCommand;
use Rocket\ORM\Console\RocketApplication;
use Rocket\ORM\Generator\Database\Table\DatabaseTableGenerator;
use Rocket\ORM\Generator\Schema\Schema;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Output\OutputInterface;

/**
 * @author <NAME> <<EMAIL>>
 */
class RocketDatabaseInsertCommand extends AbstractCommand
{
    /**
     *
     */
    protected function configure()
    {
        $this
            ->setName('database:insert')
            ->setDescription('Insert all tables in databases. Databases should be created first.')
        ;
    }

    /**
     * @param InputInterface $input
     * @param OutputInterface $output
     *
     * @return int
     *
     * @throws \Exception
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $schemas = $this->getSchemas($this->getSchemaPath());

        // Generating SQL
        $app = new RocketApplication();
        $command = $this->getRocketBuildSqlCommand();
        $app->add($command);
        $params = [
            'command' => $command->getName(),
        ];

        if (OutputInterface::VERBOSITY_DEBUG > $output->getVerbosity()) {
            $params['-q'] = true;
        }

        $app->setAutoExit(false);
        $app->run(new ArrayInput($params), new ConsoleOutput());
        $this->debug($output, '');

        $tableGenerator = new DatabaseTableGenerator($this->getSqlOutputPath());

        /** @var Schema $schema */
        foreach ($schemas as $schema) {
            $this->verbose($output, 'Inserting tables for database "' . $schema->database . '"... ', false);
            try {
                $tableGenerator->generate($schema);
            } catch (\Exception $e) {
                $this->verbose($output, '<error>FAIL</error>');

                throw $e;
            }

            $this->verbose($output, '<info>OK</info>');
        }

        $output->writeln('<info>All tables has been inserted.</info>');

        return 0;
    }

    /**
     * @return AbstractCommand
     */
    protected function getRocketBuildSqlCommand()
    {
        return new RocketGenerateSqlCommand();
    }
}

{'fraction_non_alphanumeric': 0.13756003842459175, 'fraction_numerical': 0.00038424591738712776, 'mean_word_length': 2.4637391882900865, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 61, 'https://': 2, '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': '3628370', 'n_tokens_mistral': 1445, 'n_tokens_neox': 1410, 'n_words': 304}