{"id":16000763,"url":"https://github.com/zero88/rsql","last_synced_at":"2025-08-22T17:05:23.679Z","repository":{"id":38309730,"uuid":"275730139","full_name":"zero88/rsql","owner":"zero88","description":"jOOQ + RQL","archived":false,"fork":false,"pushed_at":"2023-03-13T12:57:44.000Z","size":214,"stargazers_count":5,"open_issues_count":5,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T03:40:01.100Z","etag":null,"topics":["jooq","jpa","rsql","sql"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zero88.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-29T04:28:44.000Z","updated_at":"2023-04-09T18:23:18.000Z","dependencies_parsed_at":"2024-10-27T16:24:34.725Z","dependency_job_id":null,"html_url":"https://github.com/zero88/rsql","commit_stats":null,"previous_names":["zero88/universal-rsql"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zero88%2Frsql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zero88%2Frsql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zero88%2Frsql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zero88%2Frsql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zero88","download_url":"https://codeload.github.com/zero88/rsql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243878483,"owners_count":20362433,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jooq","jpa","rsql","sql"],"created_at":"2024-10-08T09:20:29.365Z","updated_at":"2025-03-17T20:30:25.213Z","avatar_url":"https://github.com/zero88.png","language":"Java","readme":"# Resource Query Language\n\n![build](https://github.com/zero88/rsql/workflows/build/badge.svg?branch=master)\n![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/zero88/rsql?include_prereleases\u0026sort=semver)\n![Sonatype Nexus (Releases)](https://img.shields.io/nexus/r/io.github.zero88/rsql-jooq?server=https%3A%2F%2Foss.sonatype.org)\n![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/io.github.zero88/rsql-jooq?server=https%3A%2F%2Foss.sonatype.org)\n\n[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=zero88_rsql\u0026metric=sqale_rating)](https://sonarcloud.io/dashboard?id=zero88_rsql)\n[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=zero88_rsql\u0026metric=reliability_rating)](https://sonarcloud.io/dashboard?id=zero88_rsql)\n[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=zero88_rsql\u0026metric=security_rating)](https://sonarcloud.io/dashboard?id=zero88_rsql)\n[![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=zero88_rsql\u0026metric=duplicated_lines_density)](https://sonarcloud.io/dashboard?id=zero88_rsql)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=zero88_rsql\u0026metric=coverage)](https://sonarcloud.io/dashboard?id=zero88_rsql)\n\nRESTful Service Query Language (RSQL) is a language, and a library designed for searching entries in RESTful services.\n\nThis library provides core functionality based on [rsql-parser](https://github.com/jirutka/rsql-parser) and make\nextension for [jOOQ](https://www.jooq.org/), which is translated to `jOOQ DSL`.\n\n## Usage\n\n### With jOOQ\n\n#### Parse to jOOQ Condition\n\nThe core functionality in `rsql-jooq` is creating `jOOQ condition` from RESTful query. For example:\n\n```bash\n\u003e url\nhttp://localhost:8080/api/data?q=(F_DATE=between=('2020-04-05T08:00:00','2020-04-08T08:00:00'))\n\u003e jooq\n\"ALL_DATA_TYPE\".\"F_DATE\" between timestamp '2020-04-05 08:00:00.0' and timestamp '2020-04-08 08:00:00.0'\n\n# With AND condition. Use [;] or [and]\n\u003e url\nhttp://localhost:8080/api/data?q=(F_STR=='abc';F_BOOL=='true')\n\n\u003e jooq\n( \"ALL_DATA_TYPE\".\"F_STR\" = 'abc' and \"ALL_DATA_TYPE\".\"F_BOOL\" = true )\n\n# With OR condition. Use [,] or [or]\n\u003e url\nhttp://localhost:8080/api/data?q=(F_DURATION=='abc',F_PERIOD=='xyz')\n\u003e jooq\n( \"ALL_DATA_TYPE\".\"F_DURATION\" = 'abc' or \"ALL_DATA_TYPE\".\"F_PERIOD\" = 'xyz' )\n\n\n# With combination AND and OR condition\n\u003e url\nhttp://localhost:8080/api/data?q=(F_STR=='abc';F_BOOL=='true';(F_DURATION=='def',F_PERIOD=='xyz'))\n\u003e jooq\n(\n  \"ALL_DATA_TYPE\".\"F_STR\" = 'abc'\n  and \"ALL_DATA_TYPE\".\"F_BOOL\" = true\n  and (\n    \"ALL_DATA_TYPE\".\"F_DURATION\" = 'def'\n    or \"ALL_DATA_TYPE\".\"F_PERIOD\" = 'xyz'\n  )\n)\n```\n\nThe entrypoint for the above magic is [JooqRqlParser](jooq/src/main/java/io/zero88/rsql/jooq/JooqRqlParser.java)\n\n```java\nString query=collectQueryPart(url);\n    // With your table\n    Condition condition=JooqRqlParser.DEFAULT.criteria(query,Tables.ALL_DATA_TYPE);\n```\n\nCurrently, `rsql-jooq` supports these comparison nodes\n\n| Name                  | Symbols              |\n| --------------------- | -------------------- |\n| EQUAL                 | [==]                 |\n| NOT_EQUAL             | [!=]                 |\n| GREATER_THAN          | [=gt=, \u003e]            |\n| GREATER_THAN_OR_EQUAL | [=ge=, \u003e=]           |\n| LESS_THAN             | [=lt=, \u003c]            |\n| LESS_THAN_OR_EQUAL    | [=le=, \u003c=]           |\n| IN                    | [=in=]               |\n| NOT_IN                | [=out=]              |\n| BETWEEN               | [=between=]          |\n| EXISTS                | [=exists=, =nn=]     |\n| NON_EXISTS            | [=null=, =isn=]      |\n| NULLABLE              | [=nullable=]         |\n| LIKE                  | [=like=]             |\n| UNLIKE                | [=nk=, =unlike=]     |\n| CONTAINS              | [=contains=]         |\n| STARTS_WITH           | [=sw=, =startswith=] |\n| ENDS_WITH             | [=ew=, =endswith=]   |\n\n\n#### Customize comparison\n\nThanks to [ServiceLoader](https://docs.oracle.com/javase/8/docs/api/java/util/ServiceLoader.html), you can add more `comparison builder` by\nextends [JooqComparisonCriteriaBuilder](/jooq/src/main/java/io/zero88/rsql/jooq/criteria/JooqComparisonCriteriaBuilder.java), then register in [META-INF/services/io.zero88.rsql.jooq.criteria.JooqComparisonCriteriaBuilder](jooq/src/main/resources/META-INF/services/io.zero88.rsql.jooq.criteria.JooqComparisonCriteriaBuilder)\n\n\nFor example:\n\n```java\npackage your.project.pkg\n\npublic final class CustomOpBuilder extends JooqComparisonCriteriaBuilder {\n\n    @Override\n    public @NonNull ComparisonOperatorProxy operator() {\n        return ComparisonOperatorProxy.create(\"=custom=\");\n    }\n\n    @Override\n    protected @NonNull Condition compare(@NonNull Field field, @NonNull List\u003cString\u003e arguments,\n                                         @NonNull JooqArgumentParser argParser,\n                                         @NonNull LikeWildcardPattern wildcardPattern) {\n        // do something here\n        throw new UnsupportedOperationException(\"Not yet implemented\")\n    }\n\n}\n```\n\nCreate new resource file `META-INF/services/io.zero88.rsql.jooq.criteria.JooqComparisonCriteriaBuilder` in your resource folder, with all content in [default registry](jooq/src/main/resources/META-INF/services/io.zero88.rsql.jooq.criteria.JooqComparisonCriteriaBuilder) and appends your FQN class (e.g: `your.project.pkg.CustomOpBuilder`)\n\n_Note_: in case that you don't support or overwrite any default comparison operator, it is safe to remove any line in service file.\n\n#### Integrate with jOOQ Query\n\nTo make a life is easier, `rsql-jooq` provide some basic queries that can execute directly to achieve records. For\nexample:\n\n```java\nint count = JooqFetchCountQuery.builder()\n                               .parser(jooqRqlParser)\n                               .dsl(dsl)\n                               .table(Tables.TABLES)\n                               .build()\n                               .execute(query)\n                               .intValue()\n\nboolean exists = JooqFetchExistQuery.builder()\n                                    .parser(jooqRqlParser)\n                                    .dsl(dsl)\n                                    .table(Tables.TABLES)\n                                    .build()\n                                    .execute(query)\n```\n\n### RSQL syntax\n\nRSQL syntax is described on [RSQL-parser's project page](https://github.com/jirutka/rsql-parser#grammar-and-semantic).\n\n### Add to your project\n\nTo use `rsql` with `jooq` add the\nfollowing [dependency](https://search.maven.org/artifact/io.github.zero88/rsql-jooq/1.0.0/jar) to the dependencies\nsection of your build descriptor:\n\n- `Maven` (in your `pom.xml`):\n\n```xml\n\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.github.zero88\u003c/groupId\u003e\n    \u003cartifactId\u003ersql-jooq\u003c/artifactId\u003e\n    \u003cversion\u003e1.0.0-alpha1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n- `Gradle` (in your `build.gradle`):\n\n```groovy\ndependencies {\n    api(\"io.github.zero88:rsql-jooq:1.0.0-alpha1\")\n}\n```\n\n**Hint**\n\n`rsql-jooq` is only depended on 2 main libraries:\n\n- `org.jooq:jooq`\n- `org.slf4j:slf4j-api`\n\nThen you need to add `jdbc driver` jar to your project.\n\n#### Use core lib\n\nBecause, currently I'm busy with other project, so only one portable version for `jOOQ` was implemented.\n\nTo develop more portable lib to another database abstraction in Java such as `Hibernate`, `JPA`, `MyBatis`, you can use\nonly core module\n\n- `Maven`\n\n```xml\n\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.github.zero88\u003c/groupId\u003e\n    \u003cartifactId\u003ersql-core\u003c/artifactId\u003e\n    \u003cversion\u003e1.0.0-alpha1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n- `Gradle`\n\n```groovy\ndependencies {\n    api(\"io.github.zero88:rsql-core:1.0.0-alpha1\")\n}\n```\n\nThen make extend in API core interface.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzero88%2Frsql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzero88%2Frsql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzero88%2Frsql/lists"}