example.sql 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* syntax version 1 */
  2. /* postgres can not */
  3. USE plato;
  4. -- These examples are taken from [ISO/IEC TR 19075-6:2017] standard (https://www.iso.org/standard/67367.html)
  5. SELECT T.K
  6. FROM T
  7. WHERE JSON_EXISTS (T.J, 'lax $.where');
  8. SELECT T.K
  9. FROM T
  10. WHERE JSON_EXISTS (T.J, 'strict $.where');
  11. SELECT T.K
  12. FROM T
  13. WHERE JSON_EXISTS(T.J, 'strict $.where' FALSE ON ERROR);
  14. SELECT T.K
  15. FROM T
  16. WHERE JSON_EXISTS (T.J, 'strict $.friends[*].rank');
  17. -- NOTE: Table "T" was renamed to "Filter{index}" to combine several filter examples in 1 test
  18. SELECT K
  19. FROM Filter1
  20. WHERE JSON_EXISTS (Filter1.J, 'lax $ ? (@.pay/@.hours > 9)');
  21. SELECT K
  22. FROM Filter1
  23. WHERE JSON_EXISTS (Filter1.J, 'strict $ ? (@.pay/@.hours > 9)');
  24. SELECT K
  25. FROM Filter2
  26. WHERE JSON_EXISTS (Filter2.J, 'lax $ ? (@.pay/@.hours > 9)');
  27. SELECT K
  28. FROM Filter2
  29. WHERE JSON_EXISTS (Filter2.J, 'strict $ ? (@.pay/@.hours > 9)');
  30. SELECT K
  31. FROM Filter2
  32. WHERE JSON_EXISTS (Filter2.J, 'lax $ ? (@.hours > 9)');
  33. SELECT K
  34. FROM Filter2
  35. WHERE JSON_EXISTS (Filter2.J, 'strict $ ? (@.hours > 9)');
  36. -- NOTE: Standard also provides several examples with is unknown predicate. Following their inimitable style
  37. -- standard authors do not provide data for these examples so we do not include them here