Determining if an hstore is empty

Started by Wells Oliverabout 13 years ago2 messagesgeneral
Jump to latest
#1Wells Oliver
wellsoliver@gmail.com

What's the canonical way of doing this? Various failed attempts include:

select array_length(%%'a=>1'::hstore - 'a=>1'::hstore, 1)

select array_length(%%('a=>1'::hstore - 'a=>1'::hstore), 1)

select array_length(avals('a=>1'::hstore - 'a=>1'::hstore), 1);

select array_length(akeys('a=>1'::hstore - 'a=>1'::hstore), 1);

select skeys('a=>1'::hstore - 'a=>1'::hstore) is null

select 'a=>1'::hstore - 'a=>1'::hstore is null

Etc.

--
Wells Oliver
wellsoliver@gmail.com

#2Sergey Konoplev
gray.ru@gmail.com
In reply to: Wells Oliver (#1)
Re: Determining if an hstore is empty

On Mon, Feb 11, 2013 at 11:36 AM, Wells Oliver <wellsoliver@gmail.com> wrote:

What's the canonical way of doing this? Various failed attempts include:

Just compare an empty hstore with yours.

[local]:5432 grayhemp@grayhemp=# select ''::hstore = ''::hstore,
''::hstore = '{a=>1}'::hstore;
?column? | ?column?
----------+----------
t | f
(1 row)

select array_length(%%'a=>1'::hstore - 'a=>1'::hstore, 1)

select array_length(%%('a=>1'::hstore - 'a=>1'::hstore), 1)

select array_length(avals('a=>1'::hstore - 'a=>1'::hstore), 1);

select array_length(akeys('a=>1'::hstore - 'a=>1'::hstore), 1);

select skeys('a=>1'::hstore - 'a=>1'::hstore) is null

select 'a=>1'::hstore - 'a=>1'::hstore is null

Etc.

--
Wells Oliver
wellsoliver@gmail.com

--
Sergey Konoplev
Database and Software Architect
http://www.linkedin.com/in/grayhemp

Phones:
USA +1 415 867 9984
Russia, Moscow +7 901 903 0499
Russia, Krasnodar +7 988 888 1979

Skype: gray-hemp
Jabber: gray.ru@gmail.com

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general