Skip to content

Fix XML conversion #1192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 10, 2021
Merged

Fix XML conversion #1192

merged 3 commits into from
Mar 10, 2021

Conversation

vapaj
Copy link
Contributor

@vapaj vapaj commented Feb 18, 2021

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
Collaborator

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

@@ -705,7 +705,7 @@ builtinGetters = I.fromList
, (1005, listOf PersistInt64)
, (1007, listOf PersistInt64)
, (1009, listOf PersistText)
, (143, listOf PersistText)
, (143, listOf (PersistByteString . unUnknown))
Copy link
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
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
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