Skip to content
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

If cannot convert to requested datatype return null #6

Open
cwilkes opened this issue Mar 14, 2013 · 1 comment
Open

If cannot convert to requested datatype return null #6

cwilkes opened this issue Mar 14, 2013 · 1 comment

Comments

@cwilkes
Copy link

cwilkes commented Mar 14, 2013

I'm inserting rows that have json that I have no control over, so I can get something like this:
{ "a" : { "b" : "c" } }
{ "a" : 100 }
{ "foo": "bar" }
where the "a" value can be another json element, an integer, or not even there. Like in issue #3 where the value is missing it is skipped over can items that cannot be cast to the correct response type be skipped over?

Currently I'm getting "ERROR: wrong json type found string, expected number" which is understandable, but there's no way I can avoid it.

@theirix
Copy link
Owner

theirix commented Mar 27, 2013

Yes, it is not possible to extract unknown data type without getting an error because in other case you can't distinguish null value from the "wrong" (unexpected) type. Possible solutions:

  • to add a bunch of functions that silently return null on unexpected type (not very elegant)
  • to add complex type introspection functions (it will require some pgsql code).

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

No branches or pull requests

2 participants