pg_try_member.sql 651 B

1234567891011121314151617181920212223242526272829
  1. /* postgres can not */
  2. /* syntax version 1 */
  3. /* yt can not */
  4. $s = <|a:1p|>;
  5. $js = Just($s);
  6. $es = Nothing(Struct<a:PgInt>?);
  7. -- fully equivalent to <struct>.<name>
  8. select
  9. TryMember($s, "a", null),
  10. TryMember($js, "a", null),
  11. TryMember($es, "a", null),
  12. ;
  13. -- TypeOf TryMember is type of third argument
  14. -- field type should either match third type exactly, or (if the third type is optional)
  15. -- Optional(field) should be equal to third type
  16. select
  17. TryMember($s, "a", 999p),
  18. TryMember($s, "a", Just(999p)),
  19. TryMember($js, "a", 999p),
  20. TryMember($js, "a", Just(999p)),
  21. TryMember($es, "a", 999p),
  22. TryMember($es, "a", Just(999p)),
  23. ;