Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Add JSON expressions ... path exists and value at path equals value #417

Closed
rbygrave opened this issue Sep 17, 2015 · 1 comment
Closed
Assignees
Milestone

Comments

@rbygrave
Copy link
Member

So Postgres and Oracle have JSON expressions and currently with Ebean you need to use a raw() expression to have these in your where clause like:

List<SimpleDoc> docs = SimpleDoc.find.where()
  .raw("jsonbExists(content#>'{docName}', 'My document')")
  .findList();

This enhancement would add 'path exists' and 'value at path equals ?' expressions to the ExpressionList to make this much nicer to use.

@rbygrave rbygrave self-assigned this Sep 17, 2015
@rbygrave
Copy link
Member Author

Expressions added are:

/**
 * Path exists - for the given path in a JSON document.
 */
ExpressionList<T> jsonExists(String propertyName, String path);

/**
 * Path does not exist - for the given path in a JSON document.
 */
ExpressionList<T> jsonNotExists(String propertyName, String path);

/**
 * Equal to expression for the value at the given path in the JSON document.
 */
ExpressionList<T> jsonEqualTo(String propertyName, String path, Object value);

/**
 * Not Equal to - for the given path in a JSON document.
 */
ExpressionList<T> jsonNotEqualTo(String propertyName, String path, Object val);

/**
 * Greater than - for the given path in a JSON document.
 */
ExpressionList<T> jsonGreaterThan(String propertyName, String path, Object val);

/**
 * Greater than or equal to - for the given path in a JSON document.
 */
ExpressionList<T> jsonGreaterOrEqual(String propertyName, String path, Object val);

/**
 * Less than - for the given path in a JSON document.
 */
ExpressionList<T> jsonLessThan(String propertyName, String path, Object val);

/**
 * Less than or equal to - for the given path in a JSON document.
 */
ExpressionList<T> jsonLessOrEqualTo(String propertyName, String path, Object val);

@rbygrave rbygrave added this to the 6.8.1 milestone Sep 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant