Skip to content

Commit

Permalink
Failing example for Xml insert
Browse files Browse the repository at this point in the history
  • Loading branch information
jmortlock committed Feb 12, 2025
1 parent dfde1cc commit 89d18fb
Showing 1 changed file with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use function Flow\ETL\Adapter\Doctrine\{to_dbal_table_insert, to_dbal_table_update};
use function Flow\ETL\DSL\data_frame;
use function Flow\ETL\DSL\{from_array, ref};
use function Flow\ETL\DSL\{from_array, int_schema, ref, str_schema, schema, xml_schema};
use Doctrine\DBAL\Schema\{Column, Table};
use Doctrine\DBAL\Types\{Type, Types};
use Flow\ETL\Adapter\Doctrine\DbalLoader;
Expand Down Expand Up @@ -84,6 +84,48 @@ public function test_inserts_empty_rows() : void
self::assertEquals(0, $this->pgsqlDatabaseContext->tableCount($table));
}

public function test_inserts_xml_entry() : void
{
$this->pgsqlDatabaseContext->createTable((new Table(
$table = 'flow_doctrine_bulk_test',
[
new Column('id', Type::getType(Types::INTEGER), ['notnull' => true]),
new Column('name', Type::getType(Types::STRING), ['notnull' => true, 'length' => 255]),
new Column('description', Type::getType(Types::STRING), ['notnull' => true, 'length' => 255]),
],
))
->setPrimaryKey(['id']));

$loader = to_dbal_table_insert($this->connectionParams(), $table);

(data_frame())
->read(
from_array([
['id' => 1, 'name' => 'Name One', 'description' => 'Description One'],
['id' => 2, 'name' => 'Name Two', 'description' => 'Description Two'],
['id' => 3, 'name' => 'Name Three', 'description' => '<b>Description Three</b>'],
])->withSchema(
schema(
int_schema('id'),
str_schema('name'),
xml_schema('description')
),
)
)
->load($loader)
->run();

self::assertEquals(3, $this->pgsqlDatabaseContext->tableCount($table));
self::assertEquals(
[
['id' => 1, 'name' => 'Name One', 'description' => 'Description One'],
['id' => 2, 'name' => 'Name Two', 'description' => 'Description Two'],
['id' => 3, 'name' => 'Name Three', 'description' => '<b>Description Three</b>'],
],
$this->pgsqlDatabaseContext->selectAll($table)
);
}

public function test_inserts_multiple_rows_at_once() : void
{
$this->pgsqlDatabaseContext->createTable((new Table(
Expand Down

0 comments on commit 89d18fb

Please sign in to comment.