Feature Request: JSON input for hstore

Started by Josh Berkusover 16 years ago10 messages
#1Josh Berkus
josh@agliodbs.com

Hackers,

I've just had a feature request from a client that we come up with a way
to enable JSON input into hstore. This would make hstore much more
useful for software developers.

First question: would this go in the language driver, libpq, or the
backend? Thoughts?

--
Josh Berkus
PostgreSQL Experts Inc.
www.pgexperts.com

#2David Fetter
david@fetter.org
In reply to: Josh Berkus (#1)
Re: Feature Request: JSON input for hstore

On Mon, Sep 14, 2009 at 03:14:57PM -0700, Josh Berkus wrote:

Hackers,

I've just had a feature request from a client that we come up with a
way to enable JSON input into hstore. This would make hstore much
more useful for software developers.

First question: would this go in the language driver, libpq, or the
backend? Thoughts?

The backend, ideally in some pluggable way. XML, under proper
circumstances, should work, as should YAML, etc.

Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david.fetter@gmail.com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

#3Andrew Dunstan
andrew@dunslane.net
In reply to: David Fetter (#2)
Re: Feature Request: JSON input for hstore

David Fetter wrote:

On Mon, Sep 14, 2009 at 03:14:57PM -0700, Josh Berkus wrote:

Hackers,

I've just had a feature request from a client that we come up with a
way to enable JSON input into hstore. This would make hstore much
more useful for software developers.

First question: would this go in the language driver, libpq, or the
backend? Thoughts?

The backend, ideally in some pluggable way. XML, under proper
circumstances, should work, as should YAML, etc.

The way the standard specifies SQL/XML requires grammar support. That
means it can't really be pluggable. We've been over this before.

chjeers

andrew

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: David Fetter (#2)
Re: Feature Request: JSON input for hstore

David Fetter <david@fetter.org> writes:

On Mon, Sep 14, 2009 at 03:14:57PM -0700, Josh Berkus wrote:

I've just had a feature request from a client that we come up with a
way to enable JSON input into hstore. This would make hstore much
more useful for software developers.

First question: would this go in the language driver, libpq, or the
backend? Thoughts?

The backend, ideally in some pluggable way. XML, under proper
circumstances, should work, as should YAML, etc.

Uh, hstore is a contrib module. Why aren't we talking about just some
more code in the contrib module? Adding anything to support a contrib
module in, say, libpq seems right out.

regards, tom lane

#5Jeff Davis
pgsql@j-davis.com
In reply to: Josh Berkus (#1)
Re: Feature Request: JSON input for hstore

On Mon, 2009-09-14 at 15:14 -0700, Josh Berkus wrote:

Hackers,

I've just had a feature request from a client that we come up with a way
to enable JSON input into hstore. This would make hstore much more
useful for software developers.

First question: would this go in the language driver, libpq, or the
backend? Thoughts?

What's wrong with just using a variant of the type input function? With
a parameterized insert, it doesn't seem like it's really placing much of
a burden on the application.

Or am I missing the use case?

Regards,
Jeff Davis

#6David Fetter
david@fetter.org
In reply to: Andrew Dunstan (#3)
Re: Feature Request: JSON input for hstore

On Mon, Sep 14, 2009 at 06:55:52PM -0400, Andrew Dunstan wrote:

David Fetter wrote:

On Mon, Sep 14, 2009 at 03:14:57PM -0700, Josh Berkus wrote:

Hackers,

I've just had a feature request from a client that we come up with
a way to enable JSON input into hstore. This would make hstore
much more useful for software developers.

First question: would this go in the language driver, libpq, or
the backend? Thoughts?

The backend, ideally in some pluggable way. XML, under proper
circumstances, should work, as should YAML, etc.

The way the standard specifies SQL/XML requires grammar support.
That means it can't really be pluggable. We've been over this
before.

I haven't found anything about hstore in the standard, so I'm not sure
how this applies.

Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david.fetter@gmail.com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

#7Robert Haas
robertmhaas@gmail.com
In reply to: Jeff Davis (#5)
Re: Feature Request: JSON input for hstore

On Sep 14, 2009, at 7:05 PM, Jeff Davis <pgsql@j-davis.com> wrote:

On Mon, 2009-09-14 at 15:14 -0700, Josh Berkus wrote:

Hackers,

I've just had a feature request from a client that we come up with
a way
to enable JSON input into hstore. This would make hstore much more
useful for software developers.

First question: would this go in the language driver, libpq, or the
backend? Thoughts?

What's wrong with just using a variant of the type input function?
With
a parameterized insert, it doesn't seem like it's really placing
much of
a burden on the application.

Agreed, I was thinking the same thing.

...Roberta

#8David E. Wheeler
david@kineticode.com
In reply to: Robert Haas (#7)
Re: Feature Request: JSON input for hstore

On Sep 14, 2009, at 4:32 PM, Robert Haas wrote:

What's wrong with just using a variant of the type input function?
With
a parameterized insert, it doesn't seem like it's really placing
much of
a burden on the application.

Agreed, I was thinking the same thing.

And the type output function, too. Not sure how you'd configure that,
though.

David

#9Robert Haas
robertmhaas@gmail.com
In reply to: David E. Wheeler (#8)
Re: Feature Request: JSON input for hstore

On Mon, Sep 14, 2009 at 7:42 PM, David E. Wheeler <david@kineticode.com> wrote:

On Sep 14, 2009, at 4:32 PM, Robert Haas wrote:

What's wrong with just using a variant of the type input function? With
a parameterized insert, it doesn't seem like it's really placing much of
a burden on the application.

Agreed, I was thinking the same thing.

And the type output function, too. Not sure how you'd configure that,
though.

Well I don't think you really need any them to BE the type
input/output functions. You just need

hstore_to_json(hstore) returns text
json_to_hstore(text) returns json

Insert into your query where appropriate.

...Robert

#10Andrew Dunstan
andrew@dunslane.net
In reply to: David Fetter (#6)
Re: Feature Request: JSON input for hstore

David Fetter wrote:

On Mon, Sep 14, 2009 at 06:55:52PM -0400, Andrew Dunstan wrote:

David Fetter wrote:

On Mon, Sep 14, 2009 at 03:14:57PM -0700, Josh Berkus wrote:

Hackers,

I've just had a feature request from a client that we come up with
a way to enable JSON input into hstore. This would make hstore
much more useful for software developers.

First question: would this go in the language driver, libpq, or
the backend? Thoughts?

The backend, ideally in some pluggable way. XML, under proper
circumstances, should work, as should YAML, etc.

The way the standard specifies SQL/XML requires grammar support.
That means it can't really be pluggable. We've been over this
before.

I haven't found anything about hstore in the standard, so I'm not sure
how this applies.

You're the one that mentioned the backend being pluggable w.r.t. XML
among other things.

In any case, this is academic. It has become clear in off-list
discussion that support for JSON input isn't really what the requestor
needs. What he needs is a way to translate a Perl hashref to an hstore
literal and vice versa, and Andrew Gierth has written some nice routines
in Perl to do just that.

cheers

andrew