Skip to content

Doctrine Insert with XmlEntry #1472

Closed
@jmortlock

Description

Hi

If i try and insert a dataframe into a database that contains an XmlEntry, I get the following error:

Error: Object of class DOMDocument could not be converted to string

/var/www/html/zg/vendor/doctrine/dbal/src/Driver/PDO/Statement.php:48
/var/www/html/zg/vendor/doctrine/dbal/src/Connection.php:1809
/var/www/html/zg/vendor/doctrine/dbal/src/Connection.php:1205
/var/www/html/zg/vendor/doctrine/dbal/src/Connections/PrimaryReadReplicaConnection.php:292
/var/www/html/zg/vendor/flow-php/doctrine-dbal-bulk/src/Flow/Doctrine/Bulk/Bulk.php:42
/var/www/html/zg/vendor/flow-php/etl-adapter-doctrine/src/Flow/ETL/Adapter/Doctrine/DbalLoader.php:67
/var/www/html/zg/vendor/flow-php/etl/src/Flow/ETL/Pipeline/SynchronousPipeline.php:65
/var/www/html/zg/vendor/flow-php/etl/src/Flow/ETL/DataFrame.php:763

Some pseduo code

{"descriptionHtml": "<b>This is a test</b>"}
       return data_frame()
            ->read(from_json_lines("sample.json")
            ->write(to_dbal_table_insert(.....)

I had a quick look at submitting a fix, as I managed to hack the v0.10.0 code to get it to work, however looks like I need a postgress db to run the test-suite which i don't currently have installed, and i suspect this is already fixed or easy enough for you.

I believe you need to handle it here

'object' => match ($entry::class) {

I believe something like this

\DOMDocument::class => $entry->saveXML($entry->documentElement),

As i side note are they are workarounds you can think of to transform the datatype in the row?

Closest I got was

->withEntry('DESCRIPTION_HTML', ref('DESCRIPTION_HTML')->domElementValue())

But that strips out the html tags, which ideally i want to keep.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions