dict_builtins_null_lookup.sql 1.2 KB

123456789101112131415161718192021222324252627
  1. /* postgres can not */
  2. $d2 = AsDict(AsTuple(1/1, "bar"));
  3. $d3 = AsDict(AsTuple(1/0, "baz"));
  4. $t1 = AsDict(AsTuple(AsTuple(1, "key"), AsTuple(1, "value")));
  5. $t2 = AsDict(AsTuple(AsTuple(1/1, "key"), AsTuple(2/1, "value")));
  6. $t3 = AsDict(AsTuple(AsTuple(1/0, "key"), AsTuple(123, "value")));
  7. SELECT
  8. DictContains($d2, null), -- false, no such key
  9. DictContains($d3, null), -- true, null is convertible to Nothing<T> for any T
  10. DictLookup($d2, null), -- Nothing(String?), no such key
  11. DictLookup($d3, null); -- Just("baz"), null is convertible to Nothing<T> for any T
  12. SELECT
  13. DictContains($t1, AsTuple(1, "keyy")), -- false, missing key
  14. DictContains($t1, AsTuple(1, "key")), -- true, match
  15. DictContains($t1, Just(AsTuple(1, "key"))), -- true, match with optional
  16. DictContains($t2, AsTuple(null, "key")), -- false, no such key
  17. DictContains($t3, AsTuple(null, "key")), -- true, null is convertible to Nothing<T> for any T
  18. DictLookup($t2, AsTuple(null, "key")), -- Nothing(Tuple<Int32?, String>?), no such key
  19. DictLookup($t3, AsTuple(null, "key")); -- Just(AsTuple(123, "value")), null is convertible to Nothing<T> for any T