Skip to content

Fix XML conversion - #1192

Merged
parsonsmatt merged 3 commits into
yesodweb:masterfrom
KSF-Media:xml-bytestring
Mar 10, 2021
Merged

parsonsmatt merged 3 commits into
yesodweb:masterfrom
KSF-Media:xml-bytestring

Conversation

@vapaj

@vapaj vapaj commented Feb 18, 2021 •

Copy link
Copy Markdown
Contributor

Converting sqltype=xml values into Haskell types seem to fail:

*** Exception: Incompatible {errSQLType = "xml", errSQLTableOid = column number 1 is out of range 0..-1
Nothing, errSQLField = "column number 1 is out of range 0..-1
", errHaskellType = "Text", errMessage = "types incompatible"}

This is because Persistent tries to parse it as PersistText (using the Database.PostgreSQL.Simple.FromField instance of Text), however the oid of xml, 142, does not match the oid's of name, text, char, bpchar or varchar, resulting in an Incompatible error.

To fix this, I simply changed the type from Text to (unknown) ByteString.

Before submitting your PR, check that you've:

After submitting your PR:

  • Update the Changelog.md file with a link to your PR
  • Bumped the version number if there isn't an (unreleased) on the Changelog
  • Check that CI passes (or if it fails, for reasons unrelated to your change, like CI timeouts)

@parsonsmatt

Copy link
Copy Markdown
Collaborator

I've fixed CI, mind rebasing and trying again?

Comment thread persistent-postgresql/ChangeLog.md Outdated
, (1007, listOf PersistInt64)
, (1009, listOf PersistText)
, (143, listOf PersistText)
, (143, listOf (PersistByteString . unUnknown))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting.

So, based on what you're saying - the xml type shouldn't ever have worked, right? So no existing working code should be affected by this change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonderful, thanks! 😄

@parsonsmatt
parsonsmatt merged commit a956377 into yesodweb:master Mar 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants