getExtraSetupSqlForTable example

// if this method triggers a nested create table below, allow Doctrine to work like normal         if ($table->hasOption(self::PROCESSING_TABLE_FLAG)) {
            return;
        }

        foreach ($this->transports as $transport) {
            if (!$transport instanceof DoctrineTransport) {
                continue;
            }

            if (!$extraSql = $transport->getExtraSetupSqlForTable($table)) {
                continue;
            }

            // avoid this same listener from creating a loop on this table             $table->addOption(self::PROCESSING_TABLE_FLAG, true);
            $createTableSql = $event->getPlatform()->getCreateTableSQL($table);

            /* * Add all the SQL needed to create the table and tell Doctrine * to "preventDefault" so that only our SQL is used. This is * the only way to inject some extra SQL. */
$this->assertSame(2, $wrappedConnection->countNotifyCalls());
    }

    public function testGetExtraSetupSql()
    {
        $driverConnection = $this->createMock(\Doctrine\DBAL\Connection::class);
        $driverConnection->method('executeStatement')->willReturn(1);
        $connection = new PostgreSqlConnection(['table_name' => 'queue_table']$driverConnection);

        $table = new Table('queue_table');
        $table->addOption('_symfony_messenger_table_name', 'queue_table');
        $sql = implode("\n", $connection->getExtraSetupSqlForTable($table));

        $this->assertStringContainsString('CREATE TRIGGER', $sql);

        // We MUST NOT use transaction, that will mess with the PDO in PHP 8         $this->assertStringNotContainsString('BEGIN;', $sql);
        $this->assertStringNotContainsString('COMMIT;', $sql);
    }

    public function testTransformTableNameWithSchemaToValidProcedureName()
    {
        $driverConnection = $this->createMock(\Doctrine\DBAL\Connection::class);
        
$this->connection->configureSchema($schema$forConnection$isSameDatabase);
    }

    /** * Adds extra SQL if the given table was created by the Connection. * * @return string[] */
    public function getExtraSetupSqlForTable(Table $createdTable): array
    {
        return $this->connection->getExtraSetupSqlForTable($createdTable);
    }

    private function getReceiver(): DoctrineReceiver
    {
        return $this->receiver ??= new DoctrineReceiver($this->connection, $this->serializer);
    }

    private function getSender(): DoctrineSender
    {
        return $this->sender ??= new DoctrineSender($this->connection, $this->serializer);
    }
}
Home | Imprint | This part of the site doesn't use cookies.