I have two hstore
fields, that I want to compare, and I want to know if the one is a subset of the other?
So, let's say I have "foo"=>"bar","fnuggle"=>"snuggle","dwurp"=>"qwork"
and "dwurp"=>"qwork"
, the result would be TRUE
.
When I have "foo"=>"bar","fnuggle"=>"snuggle","dwurp"=>"qwork"
and "dwurp"=>"dworp"
, the result should be FALSE
.
Also, when I have "foo"=>"bar","fnuggle"=>"snuggle","dwurp"=>"qwork"
and "dwurp"=>"qwork","flippin"=>"floppin"
, the result should be FALSE
.
I worked through the hstore
operators and other possibilities, but didn't find a good solution.
The answer turned out to be pretty simple. Consider big
to be the superset and small
the subset, this:
slice(big, akeys(small)) = small
returns TRUE
when small
is a subset.