diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 608172f..10fb77b 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -30,9 +30,9 @@ If applicable, add screenshots to help explain your problem. Please complete the following information: -- badaas version [X.X.X] or commit hash +- cql version [X.X.X] or commit hash - go version -- database vendor and version (in case of bugs related with badaas-orm) +- database vendor and version ## Additional context diff --git a/.github/ISSUE_TEMPLATE/discussion.md b/.github/ISSUE_TEMPLATE/discussion.md index 9835b3a..95ea823 100644 --- a/.github/ISSUE_TEMPLATE/discussion.md +++ b/.github/ISSUE_TEMPLATE/discussion.md @@ -1,7 +1,6 @@ --- name: Discussion -about: Start a discussion for BaDaaS +about: Start a discussion for cql title: '' labels: question ---- - \ No newline at end of file +--- \ No newline at end of file diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md deleted file mode 100644 index 210601a..0000000 --- a/.github/pull_request_template.md +++ /dev/null @@ -1,5 +0,0 @@ -:information_source: Don't forget to modify the changelog.md before merging this branch. - -:information_source: Don't forget to modify config files: - -- `badaas.example.yml`: the example file. diff --git a/.github/workflows/cql.yml b/.github/workflows/cql.yml index 25a8c97..235ee5f 100644 --- a/.github/workflows/cql.yml +++ b/.github/workflows/cql.yml @@ -101,7 +101,7 @@ jobs: path: coverage_${{ matrix.db }}.out - name: Stop containers if: ${{ matrix.db != 'sqlite' }} - run: docker stop badaas-test-db + run: docker stop cql-test-db sonarcloud: name: SonarCloud diff --git a/.gitignore b/.gitignore index f444a36..4e8e6ba 100644 --- a/.gitignore +++ b/.gitignore @@ -34,4 +34,4 @@ docs/_build/ # cli cql-cli/cql-cli cql-cli/cmd/gen/conditions/*_conditions.go -cql-cli/cmd/gen/conditions/tests/**/badaas-orm.go +cql-cli/cmd/gen/conditions/tests/**/cql.go diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 41fe403..8f6f2e9 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -60,7 +60,7 @@ representative at an online or offline event. Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at -. +. All complaints will be reviewed and investigated promptly and fairly. All community leaders are obligated to respect the privacy and security of the diff --git a/Makefile b/Makefile index 3d29140..ee84e06 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ lint: cd cql-cli && golangci-lint run --config ../.golangci.yml rmdb: - docker stop badaas-test-db && docker rm badaas-test-db + docker stop cql-test-db && docker rm cql-test-db postgresql: docker compose -f "docker/postgresql/docker-compose.yml" up -d diff --git a/README.md b/README.md index 5af8dec..f7b0b8d 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# BaDaaS ORM: Backend and Distribution ORM (Object Relational Mapping) +# CQL: Compiled Query Language -Badaas-orm is the BaDaaS' component that allows for easy and safe persistence and querying of objects but it can be used both within a BaDaaS application and independently. +CQL allows easy and safe persistence and querying of objects. -It's built on top of `gorm `_, a library that actually provides the functionality of an ORM: mapping objects to tables in the SQL database. While gorm does this job well with its automatic migration then performing queries on these objects is somewhat limited, forcing us to write SQL queries directly when they are complex. Badaas-orm seeks to address these limitations with a query system that: +It's built on top of `gorm `_, a library that actually provides the functionality of an ORM: mapping objects to tables in the SQL database. While gorm does this job well with its automatic migration then performing queries on these objects is somewhat limited, forcing us to write SQL queries directly when they are complex. CQL seeks to address these limitations with a query system that: - Is compile-time safe: its query system is validated at compile time to avoid errors such as comparing attributes that are of different types, trying to use attributes or navigate relationships that do not exist, using information from tables that are not included in the query, etc. - Is easy to use: the use of this system does not require knowledge of databases, SQL languages or complex concepts. Writing queries only requires programming in go and the result is easy to read. @@ -16,8 +16,8 @@ It's built on top of `gorm `_, a library that actually provide ## Contributing -See [this section](../docs/contributing/contributing.md) to view the badaas contribution guidelines. +See [this section](../docs/contributing/contributing.md) to view the cql contribution guidelines. ## License -Badaas is Licensed under the [Mozilla Public License Version 2.0](../LICENSE). +CQL is Licensed under the [Mozilla Public License Version 2.0](../LICENSE). diff --git a/changelog.md b/changelog.md deleted file mode 100644 index 11021e5..0000000 --- a/changelog.md +++ /dev/null @@ -1,18 +0,0 @@ -# Changelog - -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) - -## [Unreleased] - -### Added - -- Add badaas-orm with the compilable query system. -- Add operators support -- Add preloading -- Add dynamic and unsafe operators -- Add badaas-orm support for MySQL, SQLServer and SQLite - -[unreleased]: https://github.com/ditrit/badaas/blob/main/changelog.md#unreleased diff --git a/cql-cli/CONTRIBUTING.md b/cql-cli/CONTRIBUTING.md index 5aaa196..c23b898 100644 --- a/cql-cli/CONTRIBUTING.md +++ b/cql-cli/CONTRIBUTING.md @@ -1,25 +1,20 @@ -# Contribute to the development of badaas +# Contribute to the development of cql-cli -- [Contribute to the development of badaas](#contribute-to-the-development-of-badaas) - - [Local compilation](#local-compilation) - - [Tests](#tests) - - [Git](#git) - - [Branch naming policy](#branch-naming-policy) - - [Default branch](#default-branch) - - [How to release](#how-to-release) +- [Local compilation](#local-compilation) +- [Tests](#tests) ## Local compilation -You can make modifications to the badaas-cli source code and compile it locally with: +You can make modifications to the cql-cli source code and compile it locally with: ```bash go build . ``` -You can then run the badaas-cli executable directly or add a link in your $GOPATH to run it from a project: +You can then run the cql-cli executable directly or add a link in your $GOPATH to run it from a project: ```bash -ln -sf badaas-cli $GOPATH/bin/badaas-cli +ln -sf cql-cli $GOPATH/bin/cql-cli ``` ## Tests @@ -31,41 +26,3 @@ To run them, please run: ```sh make test ``` - -## Git - -### Branch naming policy - -`[BRANCH_TYPE]/[BRANCH_NAME]` - -- `BRANCH_TYPE` is a prefix to describe the purpose of the branch. - Accepted prefixes are: - - `feature`, used for feature development - - `bugfix`, used for bug fix - - `improvement`, used for refactor - - `library`, used for updating library - - `prerelease`, used for preparing the branch for the release - - `release`, used for releasing project - - `hotfix`, used for applying a hotfix on main - - `poc`, used for proof of concept -- `BRANCH_NAME` is managed by this regex: `[a-z0-9._-]` (`_` is used as space character). - -### Default branch - -The default branch is `main`. Direct commit on it is forbidden. The only way to update the application is through pull request. - -Release tag are only done on the `main` branch. - -### How to release - -We use [Semantic Versioning](https://semver.org/spec/v2.0.0.html) as guideline for the version management. - -Steps to release: - -- Create a new branch labeled `release/vX.Y.Z` from the latest `main`. -- Improve the version number in `changelog.md`. -- Verify the content of the `changelog.md`. -- Commit the modifications with the label `Release version X.Y.Z`. -- Create a pull request on github for this branch into `main`. -- Once the pull request validated and merged, tag the `main` branch with `vX.Y.Z`. -- After the tag is pushed, make the release on the tag in GitHub. diff --git a/cql-cli/LICENSE b/cql-cli/LICENSE deleted file mode 100644 index a612ad9..0000000 --- a/cql-cli/LICENSE +++ /dev/null @@ -1,373 +0,0 @@ -Mozilla Public License Version 2.0 -================================== - -1. Definitions --------------- - -1.1. "Contributor" - means each individual or legal entity that creates, contributes to - the creation of, or owns Covered Software. - -1.2. "Contributor Version" - means the combination of the Contributions of others (if any) used - by a Contributor and that particular Contributor's Contribution. - -1.3. "Contribution" - means Covered Software of a particular Contributor. - -1.4. "Covered Software" - means Source Code Form to which the initial Contributor has attached - the notice in Exhibit A, the Executable Form of such Source Code - Form, and Modifications of such Source Code Form, in each case - including portions thereof. - -1.5. "Incompatible With Secondary Licenses" - means - - (a) that the initial Contributor has attached the notice described - in Exhibit B to the Covered Software; or - - (b) that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the - terms of a Secondary License. - -1.6. "Executable Form" - means any form of the work other than Source Code Form. - -1.7. "Larger Work" - means a work that combines Covered Software with other material, in - a separate file or files, that is not Covered Software. - -1.8. "License" - means this document. - -1.9. "Licensable" - means having the right to grant, to the maximum extent possible, - whether at the time of the initial grant or subsequently, any and - all of the rights conveyed by this License. - -1.10. "Modifications" - means any of the following: - - (a) any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered - Software; or - - (b) any new file in Source Code Form that contains any Covered - Software. - -1.11. "Patent Claims" of a Contributor - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the - License, by the making, using, selling, offering for sale, having - made, import, or transfer of either its Contributions or its - Contributor Version. - -1.12. "Secondary License" - means either the GNU General Public License, Version 2.0, the GNU - Lesser General Public License, Version 2.1, the GNU Affero General - Public License, Version 3.0, or any later versions of those - licenses. - -1.13. "Source Code Form" - means the form of the work preferred for making modifications. - -1.14. "You" (or "Your") - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that - controls, is controlled by, or is under common control with You. For - purposes of this definition, "control" means (a) the power, direct - or indirect, to cause the direction or management of such entity, - whether by contract or otherwise, or (b) ownership of more than - fifty percent (50%) of the outstanding shares or beneficial - ownership of such entity. - -2. License Grants and Conditions --------------------------------- - -2.1. Grants - -Each Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: - -(a) under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and - -(b) under Patent Claims of such Contributor to make, use, sell, offer - for sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. - -2.2. Effective Date - -The licenses granted in Section 2.1 with respect to any Contribution -become effective for each Contribution on the date the Contributor first -distributes such Contribution. - -2.3. Limitations on Grant Scope - -The licenses granted in this Section 2 are the only rights granted under -this License. No additional rights or licenses will be implied from the -distribution or licensing of Covered Software under this License. -Notwithstanding Section 2.1(b) above, no patent license is granted by a -Contributor: - -(a) for any code that a Contributor has removed from Covered Software; - or - -(b) for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - -(c) under Patent Claims infringed by Covered Software in the absence of - its Contributions. - -This License does not grant any rights in the trademarks, service marks, -or logos of any Contributor (except as may be necessary to comply with -the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - -No Contributor makes additional grants as a result of Your choice to -distribute the Covered Software under a subsequent version of this -License (see Section 10.2) or under the terms of a Secondary License (if -permitted under the terms of Section 3.3). - -2.5. Representation - -Each Contributor represents that the Contributor believes its -Contributions are its original creation(s) or it has sufficient rights -to grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - -This License is not intended to limit any rights You have under -applicable copyright doctrines of fair use, fair dealing, or other -equivalents. - -2.7. Conditions - -Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted -in Section 2.1. - -3. Responsibilities -------------------- - -3.1. Distribution of Source Form - -All distribution of Covered Software in Source Code Form, including any -Modifications that You create or to which You contribute, must be under -the terms of this License. You must inform recipients that the Source -Code Form of the Covered Software is governed by the terms of this -License, and how they can obtain a copy of this License. You may not -attempt to alter or restrict the recipients' rights in the Source Code -Form. - -3.2. Distribution of Executable Form - -If You distribute Covered Software in Executable Form then: - -(a) such Covered Software must also be made available in Source Code - Form, as described in Section 3.1, and You must inform recipients of - the Executable Form how they can obtain a copy of such Source Code - Form by reasonable means in a timely manner, at a charge no more - than the cost of distribution to the recipient; and - -(b) You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter - the recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - -You may create and distribute a Larger Work under terms of Your choice, -provided that You also comply with the requirements of this License for -the Covered Software. If the Larger Work is a combination of Covered -Software with a work governed by one or more Secondary Licenses, and the -Covered Software is not Incompatible With Secondary Licenses, this -License permits You to additionally distribute such Covered Software -under the terms of such Secondary License(s), so that the recipient of -the Larger Work may, at their option, further distribute the Covered -Software under the terms of either this License or such Secondary -License(s). - -3.4. Notices - -You may not remove or alter the substance of any license notices -(including copyright notices, patent notices, disclaimers of warranty, -or limitations of liability) contained within the Source Code Form of -the Covered Software, except that You may alter any license notices to -the extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - -You may choose to offer, and to charge a fee for, warranty, support, -indemnity or liability obligations to one or more recipients of Covered -Software. However, You may do so only on Your own behalf, and not on -behalf of any Contributor. You must make it absolutely clear that any -such warranty, support, indemnity, or liability obligation is offered by -You alone, and You hereby agree to indemnify every Contributor for any -liability incurred by such Contributor as a result of warranty, support, -indemnity or liability terms You offer. You may include additional -disclaimers of warranty and limitations of liability specific to any -jurisdiction. - -4. Inability to Comply Due to Statute or Regulation ---------------------------------------------------- - -If it is impossible for You to comply with any of the terms of this -License with respect to some or all of the Covered Software due to -statute, judicial order, or regulation then You must: (a) comply with -the terms of this License to the maximum extent possible; and (b) -describe the limitations and the code they affect. Such description must -be placed in a text file included with all distributions of the Covered -Software under this License. Except to the extent prohibited by statute -or regulation, such description must be sufficiently detailed for a -recipient of ordinary skill to be able to understand it. - -5. Termination --------------- - -5.1. The rights granted under this License will terminate automatically -if You fail to comply with any of its terms. However, if You become -compliant, then the rights granted under this License from a particular -Contributor are reinstated (a) provisionally, unless and until such -Contributor explicitly and finally terminates Your grants, and (b) on an -ongoing basis, if such Contributor fails to notify You of the -non-compliance by some reasonable means prior to 60 days after You have -come back into compliance. Moreover, Your grants from a particular -Contributor are reinstated on an ongoing basis if such Contributor -notifies You of the non-compliance by some reasonable means, this is the -first time You have received notice of non-compliance with this License -from such Contributor, and You become compliant prior to 30 days after -Your receipt of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent -infringement claim (excluding declaratory judgment actions, -counter-claims, and cross-claims) alleging that a Contributor Version -directly or indirectly infringes any patent, then the rights granted to -You by any and all Contributors for the Covered Software under Section -2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all -end user license agreements (excluding distributors and resellers) which -have been validly granted by You or Your distributors under this License -prior to termination shall survive termination. - -************************************************************************ -* * -* 6. Disclaimer of Warranty * -* ------------------------- * -* * -* Covered Software is provided under this License on an "as is" * -* basis, without warranty of any kind, either expressed, implied, or * -* statutory, including, without limitation, warranties that the * -* Covered Software is free of defects, merchantable, fit for a * -* particular purpose or non-infringing. The entire risk as to the * -* quality and performance of the Covered Software is with You. * -* Should any Covered Software prove defective in any respect, You * -* (not any Contributor) assume the cost of any necessary servicing, * -* repair, or correction. This disclaimer of warranty constitutes an * -* essential part of this License. No use of any Covered Software is * -* authorized under this License except under this disclaimer. * -* * -************************************************************************ - -************************************************************************ -* * -* 7. Limitation of Liability * -* -------------------------- * -* * -* Under no circumstances and under no legal theory, whether tort * -* (including negligence), contract, or otherwise, shall any * -* Contributor, or anyone who distributes Covered Software as * -* permitted above, be liable to You for any direct, indirect, * -* special, incidental, or consequential damages of any character * -* including, without limitation, damages for lost profits, loss of * -* goodwill, work stoppage, computer failure or malfunction, or any * -* and all other commercial damages or losses, even if such party * -* shall have been informed of the possibility of such damages. This * -* limitation of liability shall not apply to liability for death or * -* personal injury resulting from such party's negligence to the * -* extent applicable law prohibits such limitation. Some * -* jurisdictions do not allow the exclusion or limitation of * -* incidental or consequential damages, so this exclusion and * -* limitation may not apply to You. * -* * -************************************************************************ - -8. Litigation -------------- - -Any litigation relating to this License may be brought only in the -courts of a jurisdiction where the defendant maintains its principal -place of business and such litigation shall be governed by laws of that -jurisdiction, without reference to its conflict-of-law provisions. -Nothing in this Section shall prevent a party's ability to bring -cross-claims or counter-claims. - -9. Miscellaneous ----------------- - -This License represents the complete agreement concerning the subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the extent -necessary to make it enforceable. Any law or regulation which provides -that the language of a contract shall be construed against the drafter -shall not be used to construe this License against a Contributor. - -10. Versions of the License ---------------------------- - -10.1. New Versions - -Mozilla Foundation is the license steward. Except as provided in Section -10.3, no one other than the license steward has the right to modify or -publish new versions of this License. Each version will be given a -distinguishing version number. - -10.2. Effect of New Versions - -You may distribute the Covered Software under the terms of the version -of the License under which You originally received the Covered Software, -or under the terms of any subsequent version published by the license -steward. - -10.3. Modified Versions - -If you create software not governed by this License, and you want to -create a new license for such software, you may create and use a -modified version of this License if you rename the license and remove -any references to the name of the license steward (except to note that -such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary -Licenses - -If You choose to distribute Source Code Form that is Incompatible With -Secondary Licenses under the terms of this version of the License, the -notice described in Exhibit B of this License must be attached. - -Exhibit A - Source Code Form License Notice -------------------------------------------- - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - -If it is not possible or desirable to put the notice in a particular -file, then You may include the notice in a location (such as a LICENSE -file in a relevant directory) where a recipient would be likely to look -for such a notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice ---------------------------------------------------------- - - This Source Code Form is "Incompatible With Secondary Licenses", as - defined by the Mozilla Public License, v. 2.0. diff --git a/cql-cli/Makefile b/cql-cli/Makefile index 0e617bf..059427e 100644 --- a/cql-cli/Makefile +++ b/cql-cli/Makefile @@ -3,6 +3,6 @@ test: clean_test_results clean_test_results: rm -f cmd/gen/conditions/*_conditions.go - rm -f cmd/gen/conditions/tests/**/badaas-orm.go + rm -f cmd/gen/conditions/tests/**/cql.go .PHONY: test \ No newline at end of file diff --git a/cql-cli/README.md b/cql-cli/README.md index e933bcb..2f46a22 100644 --- a/cql-cli/README.md +++ b/cql-cli/README.md @@ -1,12 +1,11 @@ -# badaas-cli +# cql-cli -`badaas-cli` is the command line tool that makes it possible to configure and run a badaas application. +`cql-cli` is the command line tool that makes it possible to use cql in your project. - [Install with go install](#install-with-go-install) - [Build from sources](#build-from-sources) - [Commands](#commands) - - [badaas-cli gen docker](#badaas-cli-gen-docker) - - [badaas-cli gen conditions](#badaas-cli-gen-conditions) + - [cql-cli gen conditions](#cql-cli-gen-conditions) - [Contributing](#contributing) - [License](#license) @@ -15,18 +14,19 @@ For simply installing it, use: ```bash -go install github.com/ditrit/badaas-cli +go install github.com/FrancoLiberali/cql/cql-cli ``` Or you can build it from sources. ## Build from sources -Get the sources of the project, either by visiting the [releases](https://github.com/ditrit/badaas/releases) page and downloading an archive or clone the main branch (please be aware that is it not a stable version). +Get the sources of the project, either by visiting the [releases](https://github.com/FrancoLiberali/cql/releases) page and downloading an archive or clone the main branch (please be aware that is it not a stable version). To build the project: - [Install go](https://go.dev/dl/#go1.18.4) v1.18 +- `cd cql-cli` - Install project dependencies ```bash @@ -39,39 +39,25 @@ To build the project: go build . ``` -Well done, you have a binary `badaas-cli` at the root of the project. +Well done, you have a binary `cql-cli` at the root of the project. ## Commands You can see the available commands by running: ```bash -badaas-cli help +cql-cli help ``` For more information about the functionality provided and how to use each command use: ```bash -badaas-cli help [command] +cql-cli help [command] ``` -### badaas-cli gen docker +### cql-cli gen conditions -gen docker is the command you can use to generate the files and configurations necessary for your project to use badaas in a simple way. - -`gen docker` will generate the docker and configuration files needed to run the application in the `badaas/docker` and `badaas/config` folders respectively. - -All these files can be modified in case you need different values than those provided by default. For more information about the configuration head to [configuration docs](github.com/ditrit/badaas/configuration.md). - -A Makefile will be generated for the execution of a badaas server, with the command: - -```bash -make badaas_run -``` - -### badaas-cli gen conditions - -gen conditions is the command you can use to generate conditions to query your objects using badaas-orm. For each BaDaaS Model found in the input packages a file containing all possible Conditions on that object will be generated, allowing you to use badaas-orm. +gen conditions is the command you can use to generate conditions to query your objects using cql. For each cql.Model found in the input packages a file containing all possible Conditions on that object will be generated, allowing you to use cql. Its use is recommended through `go generate`. To see an example of how to do it click [here](https://github.com/ditrit/badaa-orm-example/blob/main/standalone/conditions/orm.go). @@ -81,4 +67,4 @@ See [this section](./CONTRIBUTING.md). ## License -badaas-cli is Licensed under the [Mozilla Public License Version 2.0](./LICENSE). +cql-cli is Licensed under the [Mozilla Public License Version 2.0](../LICENSE). diff --git a/cql-cli/changelog.md b/cql-cli/changelog.md deleted file mode 100644 index 67a76d1..0000000 --- a/cql-cli/changelog.md +++ /dev/null @@ -1,18 +0,0 @@ -# Changelog - -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) - -## [Unreleased] - -### Added - -- Add generation of docker and configuration files -- Add gen conditions to generate the conditions for the badaas' compilable query system. -- Add support for operators in condition generation. -- Add preload conditions generation. -- Add support for dynamic operators. - -[unreleased]: https://github.com/ditrit/badaas-cli/blob/main/changelog.md#unreleased \ No newline at end of file diff --git a/cql-cli/cmd/gen/conditions/condition.go b/cql-cli/cmd/gen/conditions/condition.go index 609d228..d5fcef6 100644 --- a/cql-cli/cmd/gen/conditions/condition.go +++ b/cql-cli/cmd/gen/conditions/condition.go @@ -11,15 +11,15 @@ import ( const ( // cql/condition - conditionPath = cqlPath + "/condition" - badaasORMCondition = "Condition" - badaasORMJoinCondition = "JoinCondition" - badaasORMNewJoinCondition = "NewJoinCondition" - badaasORMNewCollectionPreload = "NewCollectionPreloadCondition" - badaasORMNewPreloadCondition = "NewPreloadCondition" - badaasORMField = "Field" - badaasORMBoolField = "BoolField" - badaasORMStringField = "StringField" + conditionPath = cqlPath + "/condition" + cqlCondition = "Condition" + cqlJoinCondition = "JoinCondition" + cqlNewJoinCondition = "NewJoinCondition" + cqlNewCollectionPreload = "NewCollectionPreloadCondition" + cqlNewPreloadCondition = "NewPreloadCondition" + cqlField = "Field" + cqlBoolField = "BoolField" + cqlStringField = "StringField" // cql/model modelPath = cqlPath + "/model" uIntID = "UIntID" @@ -104,9 +104,9 @@ func (condition *Condition) generateForSlice(objectType Type, field Field) { ) case *types.Named: // slice of named types (user defined types) - _, err := field.Type.BadaasModelStruct() + _, err := field.Type.CQLModelStruct() if err == nil { - // field is a Badaas Model + // field is a CQL Model condition.generateCollectionPreload(objectType, field) } case *types.Pointer: @@ -122,12 +122,12 @@ func (condition *Condition) generateForSlice(objectType Type, field Field) { // Generate condition between object and field when the field is a named type (user defined struct) func (condition *Condition) generateForNamedType(objectType Type, field Field) { - _, err := field.Type.BadaasModelStruct() + _, err := field.Type.CQLModelStruct() switch { case err == nil: - // field is a badaas model - condition.generateForBadaasModel(objectType, field) + // field is a cql model + condition.generateForCQLModel(objectType, field) case field.Type.IsSQLNullableType(): // field is a sql nullable type (sql.NullBool, sql.NullInt, etc.) condition.param.SQLToBasicType(field.Type) @@ -138,7 +138,7 @@ func (condition *Condition) generateForNamedType(objectType Type, field Field) { case field.Type.IsGormCustomType() || field.TypeString() == "time.Time" || field.IsModelID(): // field is a Gorm Custom type (implements Scanner and Valuer interfaces) // or a named type supported by gorm (time.Time) - // or a badaas-orm id (uuid or uintid) + // or a cql id (uuid or uintid) condition.param.ToCustomType(condition.destPkg, field.Type) condition.createField( objectType, @@ -149,8 +149,8 @@ func (condition *Condition) generateForNamedType(objectType Type, field Field) { } } -// Generate condition between object and field when the field is a Badaas Model -func (condition *Condition) generateForBadaasModel(objectType Type, field Field) { +// Generate condition between object and field when the field is a CQL Model +func (condition *Condition) generateForCQLModel(objectType Type, field Field) { _, err := objectType.GetFK(field) if err == nil { // has the fk -> belongsTo relation @@ -197,7 +197,7 @@ func (condition *Condition) createField(objectType Type, field Field) { ) fieldQual := jen.Qual( - conditionPath, badaasORMField, + conditionPath, cqlField, ).Types( objectTypeQual, condition.param.GenericType(), @@ -207,14 +207,14 @@ func (condition *Condition) createField(objectType Type, field Field) { jen.Id("Field"): fieldQual.Clone().Values(fieldValues), } fieldQual = jen.Qual( - conditionPath, badaasORMStringField, + conditionPath, cqlStringField, ).Types(objectTypeQual) } else if condition.param.isBool { fieldValues = jen.Dict{ jen.Id("Field"): fieldQual.Clone().Values(fieldValues), } fieldQual = jen.Qual( - conditionPath, badaasORMBoolField, + conditionPath, cqlBoolField, ).Types(objectTypeQual) } @@ -264,13 +264,13 @@ func (condition *Condition) generateJoin(objectType Type, field Field, t1Field, log.Logger.Debugf("Generated %q", conditionName) ormT1IJoinCondition := jen.Qual( - conditionPath, badaasORMJoinCondition, + conditionPath, cqlJoinCondition, ).Types(t1) ormT2Condition := jen.Qual( - conditionPath, badaasORMCondition, + conditionPath, cqlCondition, ).Types(t2) ormJoinCondition := jen.Qual( - conditionPath, badaasORMNewJoinCondition, + conditionPath, cqlNewJoinCondition, ).Types( t1, t2, ) @@ -319,13 +319,13 @@ func (condition *Condition) generateCollectionPreload(objectType Type, field Fie ) ormT1Condition := jen.Qual( - conditionPath, badaasORMCondition, + conditionPath, cqlCondition, ).Types(t1) ormT2IJoinCondition := jen.Qual( - conditionPath, badaasORMJoinCondition, + conditionPath, cqlJoinCondition, ).Types(t2) ormNewCollectionPreload := jen.Qual( - conditionPath, badaasORMNewCollectionPreload, + conditionPath, cqlNewCollectionPreload, ).Types( t1, t2, ) diff --git a/cql-cli/cmd/gen/conditions/conditionsGenerator.go b/cql-cli/cmd/gen/conditions/conditionsGenerator.go index 31ad105..e1caf8d 100644 --- a/cql-cli/cmd/gen/conditions/conditionsGenerator.go +++ b/cql-cli/cmd/gen/conditions/conditionsGenerator.go @@ -84,7 +84,7 @@ func (cg ConditionsGenerator) Into(file *File) error { func addPreloadRelationsMethod(file *File, objectName string, objectQual *jen.Statement, conditionsModelType string, relationPreloads []jen.Code) { if len(relationPreloads) > 0 { condition := jen.Index().Add(jen.Qual( - conditionPath, badaasORMCondition, + conditionPath, cqlCondition, )).Types( objectQual, ) @@ -105,14 +105,14 @@ func addPreloadMethod(file *File, objectName string, objectQual *jen.Statement, jen.Comment(fmt.Sprintf("Preload allows preloading the %s when doing a query", objectName)), createMethod(conditionsModelType, preloadMethod).Params().Add( jen.Qual( - conditionPath, badaasORMCondition, + conditionPath, cqlCondition, ).Types( objectQual, ), ).Block( jen.Return( jen.Qual( - conditionPath, badaasORMNewPreloadCondition, + conditionPath, cqlNewPreloadCondition, ).Types( objectQual, ).Call(fieldIdentifiers...), diff --git a/cql-cli/cmd/gen/conditions/field.go b/cql-cli/cmd/gen/conditions/field.go index 3c6e652..018a104 100644 --- a/cql-cli/cmd/gen/conditions/field.go +++ b/cql-cli/cmd/gen/conditions/field.go @@ -7,7 +7,7 @@ import ( "github.com/elliotchance/pie/v2" ) -// badaas/orm/baseModels.go +// cql/model/models.go var modelIDs = []string{ modelPath + "." + uIntID, modelPath + "." + uuid, @@ -100,12 +100,12 @@ func (field Field) ChangeType(newType types.Type) Field { } } -// Get fields of a Badaas model -// Returns error is objectType is not a Badaas model +// Get fields of a cql model +// Returns error is objectType is not a cql model func getFields(objectType Type) ([]Field, error) { - // The underlying type has to be a struct and a Badaas Model + // The underlying type has to be a struct and a cql Model // (ignore const, var, func, etc.) - structType, err := objectType.BadaasModelStruct() + structType, err := objectType.CQLModelStruct() if err != nil { return nil, err } diff --git a/cql-cli/cmd/gen/conditions/file.go b/cql-cli/cmd/gen/conditions/file.go index dfab842..40ae909 100644 --- a/cql-cli/cmd/gen/conditions/file.go +++ b/cql-cli/cmd/gen/conditions/file.go @@ -18,7 +18,7 @@ func NewFile(destPkg, name string) *File { f := jen.NewFile(destPkg) // Add a package comment, so IDEs detect files as generated - f.PackageComment("Code generated by badaas-cli v" + version.Version + ", DO NOT EDIT.") + f.PackageComment("Code generated by cql-cli v" + version.Version + ", DO NOT EDIT.") return &File{ destPkg: destPkg, diff --git a/cql-cli/cmd/gen/conditions/main.go b/cql-cli/cmd/gen/conditions/main.go index c55c343..3edd536 100644 --- a/cql-cli/cmd/gen/conditions/main.go +++ b/cql-cli/cmd/gen/conditions/main.go @@ -18,8 +18,8 @@ import ( var GenConditionsCmd = verdeter.BuildVerdeterCommand(verdeter.VerdeterConfig{ Use: "conditions", - Short: "Generate conditions to query your objects using badaas-orm", - Long: `gen is the command you can use to generate the files and configurations necessary for your project to use BadAss in a simple way.`, + Short: "Generate conditions to query your objects using cql", + Long: `gen is the command you can use to generate conditions to query your objects using cql.`, Run: generateConditions, Args: cobra.MinimumNArgs(1), }) @@ -60,11 +60,11 @@ func generateConditions(_ *cobra.Command, args []string) { } } -// Generates a file with conditions for each Badaas model in the package +// Generates a file with conditions for each cql model in the package func generateConditionsForPkg(destPkg string, pkgPath string, pkg *packages.Package) { log.Logger.Infof("Generating conditions for types in package %q", pkg.Types.Name()) - relationGettersFile := NewFile(pkg.Types.Name(), filepath.Join(pkgPath, "badaas-orm.go")) + relationGettersFile := NewFile(pkg.Types.Name(), filepath.Join(pkgPath, "cql.go")) for _, name := range pkg.Types.Scope().Names() { object := getObject(pkg, name) @@ -88,7 +88,7 @@ func generateConditionsForObject(destPkg string, object types.Object) { err := NewConditionsGenerator(object).Into(file) if err != nil { - // object is not a Badaas model, do not generate conditions + // object is not a cql model, do not generate conditions return } diff --git a/cql-cli/cmd/gen/conditions/main_test.go b/cql-cli/cmd/gen/conditions/main_test.go index ba7eca8..1446978 100644 --- a/cql-cli/cmd/gen/conditions/main_test.go +++ b/cql-cli/cmd/gen/conditions/main_test.go @@ -18,84 +18,84 @@ func TestUIntModel(t *testing.T) { doTest(t, "./tests/uintmodel", []Comparison{ {Have: "uint_model_conditions.go", Expected: "./tests/results/uintmodel.go"}, }) - testutils.CheckFileNotExists(t, "./tests/uintmodel/badaas-orm.go") + testutils.CheckFileNotExists(t, "./tests/uintmodel/cql.go") } func TestUUIDModel(t *testing.T) { doTest(t, "./tests/uuidmodel", []Comparison{ {Have: "uuid_model_conditions.go", Expected: "./tests/results/uuidmodel.go"}, }) - testutils.CheckFileNotExists(t, "./tests/uuidmodel/badaas-orm.go") + testutils.CheckFileNotExists(t, "./tests/uuidmodel/cql.go") } func TestBasicTypes(t *testing.T) { doTest(t, "./tests/basictypes", []Comparison{ {Have: "basic_types_conditions.go", Expected: "./tests/results/basictypes.go"}, }) - testutils.CheckFileNotExists(t, "./tests/basictypes/badaas-orm.go") + testutils.CheckFileNotExists(t, "./tests/basictypes/cql.go") } func TestBasicPointers(t *testing.T) { doTest(t, "./tests/basicpointers", []Comparison{ {Have: "basic_pointers_conditions.go", Expected: "./tests/results/basicpointers.go"}, }) - testutils.CheckFileNotExists(t, "./tests/basicpointers/badaas-orm.go") + testutils.CheckFileNotExists(t, "./tests/basicpointers/cql.go") } func TestBasicSlices(t *testing.T) { doTest(t, "./tests/basicslices", []Comparison{ {Have: "basic_slices_conditions.go", Expected: "./tests/results/basicslices.go"}, }) - testutils.CheckFileNotExists(t, "./tests/basicslices/badaas-orm.go") + testutils.CheckFileNotExists(t, "./tests/basicslices/cql.go") } func TestBasicSlicesPointer(t *testing.T) { doTest(t, "./tests/basicslicespointer", []Comparison{ {Have: "basic_slices_pointer_conditions.go", Expected: "./tests/results/basicslicespointer.go"}, }) - testutils.CheckFileNotExists(t, "./tests/basicslicespointer/badaas-orm.go") + testutils.CheckFileNotExists(t, "./tests/basicslicespointer/cql.go") } func TestGoEmbedded(t *testing.T) { doTest(t, "./tests/goembedded", []Comparison{ {Have: "go_embedded_conditions.go", Expected: "./tests/results/goembedded.go"}, }) - testutils.CheckFileNotExists(t, "./tests/goembedded/badaas-orm.go") + testutils.CheckFileNotExists(t, "./tests/goembedded/cql.go") } func TestGormEmbedded(t *testing.T) { doTest(t, "./tests/gormembedded", []Comparison{ {Have: "gorm_embedded_conditions.go", Expected: "./tests/results/gormembedded.go"}, }) - testutils.CheckFileNotExists(t, "./tests/gormembedded/badaas-orm.go") + testutils.CheckFileNotExists(t, "./tests/gormembedded/cql.go") } func TestCustomType(t *testing.T) { doTest(t, "./tests/customtype", []Comparison{ {Have: "custom_type_conditions.go", Expected: "./tests/results/customtype.go"}, }) - testutils.CheckFileNotExists(t, "./tests/customtype/badaas-orm.go") + testutils.CheckFileNotExists(t, "./tests/customtype/cql.go") } func TestColumnDefinition(t *testing.T) { doTest(t, "./tests/columndefinition", []Comparison{ {Have: "column_definition_conditions.go", Expected: "./tests/results/columndefinition.go"}, }) - testutils.CheckFileNotExists(t, "./tests/columndefinition/badaas-orm.go") + testutils.CheckFileNotExists(t, "./tests/columndefinition/cql.go") } func TestNullableTypes(t *testing.T) { doTest(t, "./tests/nullabletypes", []Comparison{ {Have: "nullable_types_conditions.go", Expected: "./tests/results/nullabletypes.go"}, }) - testutils.CheckFileNotExists(t, "./tests/nullabletypes/badaas-orm.go") + testutils.CheckFileNotExists(t, "./tests/nullabletypes/cql.go") } func TestBelongsTo(t *testing.T) { doTest(t, "./tests/belongsto", []Comparison{ {Have: "owner_conditions.go", Expected: "./tests/results/belongsto_owner.go"}, {Have: "owned_conditions.go", Expected: "./tests/results/belongsto_owned.go"}, - {Have: "./tests/belongsto/badaas-orm.go", Expected: "./tests/belongsto/badaas-orm_result.go"}, + {Have: "./tests/belongsto/cql.go", Expected: "./tests/belongsto/cql_result.go"}, }) } @@ -103,7 +103,7 @@ func TestHasOne(t *testing.T) { doTest(t, "./tests/hasone", []Comparison{ {Have: "country_conditions.go", Expected: "./tests/results/hasone_country.go"}, {Have: "city_conditions.go", Expected: "./tests/results/hasone_city.go"}, - {Have: "./tests/hasone/badaas-orm.go", Expected: "./tests/hasone/badaas-orm_result.go"}, + {Have: "./tests/hasone/cql.go", Expected: "./tests/hasone/cql_result.go"}, }) } @@ -111,7 +111,7 @@ func TestHasMany(t *testing.T) { doTest(t, "./tests/hasmany", []Comparison{ {Have: "company_conditions.go", Expected: "./tests/results/hasmany_company.go"}, {Have: "seller_conditions.go", Expected: "./tests/results/hasmany_seller.go"}, - {Have: "./tests/hasmany/badaas-orm.go", Expected: "./tests/hasmany/badaas-orm_result.go"}, + {Have: "./tests/hasmany/cql.go", Expected: "./tests/hasmany/cql_result.go"}, }) } @@ -119,21 +119,21 @@ func TestHasManyWithPointers(t *testing.T) { doTest(t, "./tests/hasmanywithpointers", []Comparison{ {Have: "company_with_pointers_conditions.go", Expected: "./tests/results/hasmanywithpointers_company.go"}, {Have: "seller_in_pointers_conditions.go", Expected: "./tests/results/hasmanywithpointers_seller.go"}, - {Have: "./tests/hasmanywithpointers/badaas-orm.go", Expected: "./tests/hasmanywithpointers/badaas-orm_result.go"}, + {Have: "./tests/hasmanywithpointers/cql.go", Expected: "./tests/hasmanywithpointers/cql_result.go"}, }) } func TestSelfReferential(t *testing.T) { doTest(t, "./tests/selfreferential", []Comparison{ {Have: "employee_conditions.go", Expected: "./tests/results/selfreferential.go"}, - {Have: "./tests/selfreferential/badaas-orm.go", Expected: "./tests/selfreferential/badaas-orm_result.go"}, + {Have: "./tests/selfreferential/cql.go", Expected: "./tests/selfreferential/cql_result.go"}, }) } func TestMultiplePackage(t *testing.T) { doTest(t, "./tests/multiplepackage/package1", []Comparison{ {Have: "package1_conditions.go", Expected: "./tests/results/multiplepackage_package1.go"}, - {Have: "./tests/multiplepackage/package1/badaas-orm.go", Expected: "./tests/multiplepackage/package1/badaas-orm_result.go"}, + {Have: "./tests/multiplepackage/package1/cql.go", Expected: "./tests/multiplepackage/package1/cql_result.go"}, }) doTest(t, "./tests/multiplepackage/package2", []Comparison{ {Have: "package2_conditions.go", Expected: "./tests/results/multiplepackage_package2.go"}, @@ -144,7 +144,7 @@ func TestOverrideForeignKey(t *testing.T) { doTest(t, "./tests/overrideforeignkey", []Comparison{ {Have: "bicycle_conditions.go", Expected: "./tests/results/overrideforeignkey_bicycle.go"}, {Have: "person_conditions.go", Expected: "./tests/results/overrideforeignkey_person.go"}, - {Have: "./tests/overrideforeignkey/badaas-orm.go", Expected: "./tests/overrideforeignkey/badaas-orm_result.go"}, + {Have: "./tests/overrideforeignkey/cql.go", Expected: "./tests/overrideforeignkey/cql_result.go"}, }) } @@ -152,7 +152,7 @@ func TestOverrideReferences(t *testing.T) { doTest(t, "./tests/overridereferences", []Comparison{ {Have: "phone_conditions.go", Expected: "./tests/results/overridereferences_phone.go"}, {Have: "brand_conditions.go", Expected: "./tests/results/overridereferences_brand.go"}, - {Have: "./tests/overridereferences/badaas-orm.go", Expected: "./tests/overridereferences/badaas-orm_result.go"}, + {Have: "./tests/overridereferences/cql.go", Expected: "./tests/overridereferences/cql_result.go"}, }) } @@ -160,7 +160,7 @@ func TestOverrideForeignKeyInverse(t *testing.T) { doTest(t, "./tests/overrideforeignkeyinverse", []Comparison{ {Have: "user_conditions.go", Expected: "./tests/results/overrideforeignkeyinverse_user.go"}, {Have: "credit_card_conditions.go", Expected: "./tests/results/overrideforeignkeyinverse_credit_card.go"}, - {Have: "./tests/overrideforeignkeyinverse/badaas-orm.go", Expected: "./tests/overrideforeignkeyinverse/badaas-orm_result.go"}, + {Have: "./tests/overrideforeignkeyinverse/cql.go", Expected: "./tests/overrideforeignkeyinverse/cql_result.go"}, }) } @@ -168,7 +168,7 @@ func TestOverrideReferencesInverse(t *testing.T) { doTest(t, "./tests/overridereferencesinverse", []Comparison{ {Have: "computer_conditions.go", Expected: "./tests/results/overridereferencesinverse_computer.go"}, {Have: "processor_conditions.go", Expected: "./tests/results/overridereferencesinverse_processor.go"}, - {Have: "./tests/overridereferencesinverse/badaas-orm.go", Expected: "./tests/overridereferencesinverse/badaas-orm_result.go"}, + {Have: "./tests/overridereferencesinverse/cql.go", Expected: "./tests/overridereferencesinverse/cql_result.go"}, }) } diff --git a/cql-cli/cmd/gen/conditions/relationGettersGenerator.go b/cql-cli/cmd/gen/conditions/relationGettersGenerator.go index 32b5d98..2ea5af9 100644 --- a/cql-cli/cmd/gen/conditions/relationGettersGenerator.go +++ b/cql-cli/cmd/gen/conditions/relationGettersGenerator.go @@ -10,12 +10,12 @@ import ( ) const ( - // badaas/orm/preload - preloadPath = cqlPath + "/preload" - badaasORMVerifyStructLoaded = "VerifyStructLoaded" - badaasORMVerifyPointerLoaded = "VerifyPointerLoaded" - badaasORMVerifyPointerWithIDLoaded = "VerifyPointerWithIDLoaded" - badaasORMVerifyCollectionLoaded = "VerifyCollectionLoaded" + // cql/preload + preloadPath = cqlPath + "/preload" + cqlVerifyStructLoaded = "VerifyStructLoaded" + cqlVerifyPointerLoaded = "VerifyPointerLoaded" + cqlVerifyPointerWithIDLoaded = "VerifyPointerWithIDLoaded" + cqlVerifyCollectionLoaded = "VerifyCollectionLoaded" ) type RelationGettersGenerator struct { @@ -72,10 +72,10 @@ func (generator RelationGettersGenerator) generateForField(field Field) jen.Code switch fieldType := field.GetType().(type) { case *types.Named: // the field is a named type (user defined structs) - _, err := field.Type.BadaasModelStruct() + _, err := field.Type.CQLModelStruct() if err == nil { log.Logger.Debugf("Generating relation getter for type %q and field %s", generator.object.Name(), field.Name) - // field is a badaas Model + // field is a cql Model return generator.verifyStruct(field) } case *types.Pointer: @@ -91,9 +91,9 @@ func (generator RelationGettersGenerator) generateForField(field Field) jen.Code func (generator RelationGettersGenerator) generateForPointer(field Field) jen.Code { switch fieldType := field.GetType().(type) { case *types.Named: - _, err := field.Type.BadaasModelStruct() + _, err := field.Type.CQLModelStruct() if err == nil { - // field is a pointer to Badaas Model + // field is a pointer to cql Model fk, err := generator.objectType.GetFK(field) if err != nil { log.Logger.Debugf("unhandled: field is a pointer and object not has the fk: %s", field.Type) @@ -125,9 +125,9 @@ func (generator RelationGettersGenerator) generateForPointer(field Field) jen.Co func (generator RelationGettersGenerator) generateForSlicePointer(field Field, fieldTypePrefix *jen.Statement) jen.Code { switch fieldType := field.GetType().(type) { case *types.Named: - _, err := field.Type.BadaasModelStruct() + _, err := field.Type.CQLModelStruct() if err == nil { - // field is a pointer to a slice of badaas Model + // field is a pointer to a slice of cql Model return generator.verifyCollection(field, fieldTypePrefix) } case *types.Pointer: @@ -147,7 +147,7 @@ func getGetterName(field Field) string { func (generator RelationGettersGenerator) verifyStruct(field Field) *jen.Statement { return generator.verifyCommon( field, - badaasORMVerifyStructLoaded, + cqlVerifyStructLoaded, jen.Op("*"), nil, jen.Op("&").Id("m").Op(".").Id(field.Name), @@ -155,17 +155,17 @@ func (generator RelationGettersGenerator) verifyStruct(field Field) *jen.Stateme } func (generator RelationGettersGenerator) verifyPointer(field Field) *jen.Statement { - return generator.verifyPointerCommon(field, badaasORMVerifyPointerLoaded) + return generator.verifyPointerCommon(field, cqlVerifyPointerLoaded) } func (generator RelationGettersGenerator) verifyPointerWithID(field Field) *jen.Statement { - return generator.verifyPointerCommon(field, badaasORMVerifyPointerWithIDLoaded) + return generator.verifyPointerCommon(field, cqlVerifyPointerWithIDLoaded) } func (generator RelationGettersGenerator) verifyCollection(field Field, fieldTypePrefix *jen.Statement) jen.Code { return generator.verifyCommon( field, - badaasORMVerifyCollectionLoaded, + cqlVerifyCollectionLoaded, jen.Index(), fieldTypePrefix, jen.Id("m").Op(".").Id(field.Name), diff --git a/cql-cli/cmd/gen/conditions/tests/belongsto/badaas-orm_result.go b/cql-cli/cmd/gen/conditions/tests/belongsto/cql_result.go similarity index 76% rename from cql-cli/cmd/gen/conditions/tests/belongsto/badaas-orm_result.go rename to cql-cli/cmd/gen/conditions/tests/belongsto/cql_result.go index 55af0d9..b781bd3 100644 --- a/cql-cli/cmd/gen/conditions/tests/belongsto/badaas-orm_result.go +++ b/cql-cli/cmd/gen/conditions/tests/belongsto/cql_result.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package belongsto import preload "github.com/FrancoLiberali/cql/preload" diff --git a/cql-cli/cmd/gen/conditions/tests/hasmany/badaas-orm_result.go b/cql-cli/cmd/gen/conditions/tests/hasmany/cql_result.go similarity index 85% rename from cql-cli/cmd/gen/conditions/tests/hasmany/badaas-orm_result.go rename to cql-cli/cmd/gen/conditions/tests/hasmany/cql_result.go index 62ccc7b..2abbe71 100644 --- a/cql-cli/cmd/gen/conditions/tests/hasmany/badaas-orm_result.go +++ b/cql-cli/cmd/gen/conditions/tests/hasmany/cql_result.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package hasmany import preload "github.com/FrancoLiberali/cql/preload" diff --git a/cql-cli/cmd/gen/conditions/tests/hasmanywithpointers/badaas-orm_result.go b/cql-cli/cmd/gen/conditions/tests/hasmanywithpointers/cql_result.go similarity index 87% rename from cql-cli/cmd/gen/conditions/tests/hasmanywithpointers/badaas-orm_result.go rename to cql-cli/cmd/gen/conditions/tests/hasmanywithpointers/cql_result.go index 5b44395..9f1ad84 100644 --- a/cql-cli/cmd/gen/conditions/tests/hasmanywithpointers/badaas-orm_result.go +++ b/cql-cli/cmd/gen/conditions/tests/hasmanywithpointers/cql_result.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package hasmanywithpointers import preload "github.com/FrancoLiberali/cql/preload" diff --git a/cql-cli/cmd/gen/conditions/tests/hasone/badaas-orm_result.go b/cql-cli/cmd/gen/conditions/tests/hasone/cql_result.go similarity index 84% rename from cql-cli/cmd/gen/conditions/tests/hasone/badaas-orm_result.go rename to cql-cli/cmd/gen/conditions/tests/hasone/cql_result.go index e22756c..7e14e13 100644 --- a/cql-cli/cmd/gen/conditions/tests/hasone/badaas-orm_result.go +++ b/cql-cli/cmd/gen/conditions/tests/hasone/cql_result.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package hasone import preload "github.com/FrancoLiberali/cql/preload" diff --git a/cql-cli/cmd/gen/conditions/tests/multiplepackage/package1/badaas-orm_result.go b/cql-cli/cmd/gen/conditions/tests/multiplepackage/package1/cql_result.go similarity index 85% rename from cql-cli/cmd/gen/conditions/tests/multiplepackage/package1/badaas-orm_result.go rename to cql-cli/cmd/gen/conditions/tests/multiplepackage/package1/cql_result.go index 91c70a2..2c26eca 100644 --- a/cql-cli/cmd/gen/conditions/tests/multiplepackage/package1/badaas-orm_result.go +++ b/cql-cli/cmd/gen/conditions/tests/multiplepackage/package1/cql_result.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package package1 import ( diff --git a/cql-cli/cmd/gen/conditions/tests/overrideforeignkey/badaas-orm_result.go b/cql-cli/cmd/gen/conditions/tests/overrideforeignkey/cql_result.go similarity index 77% rename from cql-cli/cmd/gen/conditions/tests/overrideforeignkey/badaas-orm_result.go rename to cql-cli/cmd/gen/conditions/tests/overrideforeignkey/cql_result.go index dde763c..4d9577b 100644 --- a/cql-cli/cmd/gen/conditions/tests/overrideforeignkey/badaas-orm_result.go +++ b/cql-cli/cmd/gen/conditions/tests/overrideforeignkey/cql_result.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package overrideforeignkey import preload "github.com/FrancoLiberali/cql/preload" diff --git a/cql-cli/cmd/gen/conditions/tests/overrideforeignkeyinverse/badaas-orm_result.go b/cql-cli/cmd/gen/conditions/tests/overrideforeignkeyinverse/cql_result.go similarity index 79% rename from cql-cli/cmd/gen/conditions/tests/overrideforeignkeyinverse/badaas-orm_result.go rename to cql-cli/cmd/gen/conditions/tests/overrideforeignkeyinverse/cql_result.go index 87ccf0f..b0a467a 100644 --- a/cql-cli/cmd/gen/conditions/tests/overrideforeignkeyinverse/badaas-orm_result.go +++ b/cql-cli/cmd/gen/conditions/tests/overrideforeignkeyinverse/cql_result.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package overrideforeignkeyinverse import preload "github.com/FrancoLiberali/cql/preload" diff --git a/cql-cli/cmd/gen/conditions/tests/overridereferences/badaas-orm_result.go b/cql-cli/cmd/gen/conditions/tests/overridereferences/cql_result.go similarity index 77% rename from cql-cli/cmd/gen/conditions/tests/overridereferences/badaas-orm_result.go rename to cql-cli/cmd/gen/conditions/tests/overridereferences/cql_result.go index 599b2d6..8821bea 100644 --- a/cql-cli/cmd/gen/conditions/tests/overridereferences/badaas-orm_result.go +++ b/cql-cli/cmd/gen/conditions/tests/overridereferences/cql_result.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package overridereferences import preload "github.com/FrancoLiberali/cql/preload" diff --git a/cql-cli/cmd/gen/conditions/tests/overridereferencesinverse/badaas-orm_result.go b/cql-cli/cmd/gen/conditions/tests/overridereferencesinverse/cql_result.go similarity index 79% rename from cql-cli/cmd/gen/conditions/tests/overridereferencesinverse/badaas-orm_result.go rename to cql-cli/cmd/gen/conditions/tests/overridereferencesinverse/cql_result.go index 52aa7f6..15b4851 100644 --- a/cql-cli/cmd/gen/conditions/tests/overridereferencesinverse/badaas-orm_result.go +++ b/cql-cli/cmd/gen/conditions/tests/overridereferencesinverse/cql_result.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package overridereferencesinverse import preload "github.com/FrancoLiberali/cql/preload" diff --git a/cql-cli/cmd/gen/conditions/tests/results/basicpointers.go b/cql-cli/cmd/gen/conditions/tests/results/basicpointers.go index 0306529..137949c 100644 --- a/cql-cli/cmd/gen/conditions/tests/results/basicpointers.go +++ b/cql-cli/cmd/gen/conditions/tests/results/basicpointers.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/cql-cli/cmd/gen/conditions/tests/results/basicslices.go b/cql-cli/cmd/gen/conditions/tests/results/basicslices.go index 53761ad..c666f77 100644 --- a/cql-cli/cmd/gen/conditions/tests/results/basicslices.go +++ b/cql-cli/cmd/gen/conditions/tests/results/basicslices.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/cql-cli/cmd/gen/conditions/tests/results/basicslicespointer.go b/cql-cli/cmd/gen/conditions/tests/results/basicslicespointer.go index 1848e77..58bb99e 100644 --- a/cql-cli/cmd/gen/conditions/tests/results/basicslicespointer.go +++ b/cql-cli/cmd/gen/conditions/tests/results/basicslicespointer.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/cql-cli/cmd/gen/conditions/tests/results/basictypes.go b/cql-cli/cmd/gen/conditions/tests/results/basictypes.go index fc991ae..6c68bad 100644 --- a/cql-cli/cmd/gen/conditions/tests/results/basictypes.go +++ b/cql-cli/cmd/gen/conditions/tests/results/basictypes.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/cql-cli/cmd/gen/conditions/tests/results/belongsto_owned.go b/cql-cli/cmd/gen/conditions/tests/results/belongsto_owned.go index 5eef2af..b498624 100644 --- a/cql-cli/cmd/gen/conditions/tests/results/belongsto_owned.go +++ b/cql-cli/cmd/gen/conditions/tests/results/belongsto_owned.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/cql-cli/cmd/gen/conditions/tests/results/belongsto_owner.go b/cql-cli/cmd/gen/conditions/tests/results/belongsto_owner.go index f4d069a..7ed56b8 100644 --- a/cql-cli/cmd/gen/conditions/tests/results/belongsto_owner.go +++ b/cql-cli/cmd/gen/conditions/tests/results/belongsto_owner.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/cql-cli/cmd/gen/conditions/tests/results/columndefinition.go b/cql-cli/cmd/gen/conditions/tests/results/columndefinition.go index e2b6d86..48953e6 100644 --- a/cql-cli/cmd/gen/conditions/tests/results/columndefinition.go +++ b/cql-cli/cmd/gen/conditions/tests/results/columndefinition.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/cql-cli/cmd/gen/conditions/tests/results/customtype.go b/cql-cli/cmd/gen/conditions/tests/results/customtype.go index 59eb731..27dd056 100644 --- a/cql-cli/cmd/gen/conditions/tests/results/customtype.go +++ b/cql-cli/cmd/gen/conditions/tests/results/customtype.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/cql-cli/cmd/gen/conditions/tests/results/goembedded.go b/cql-cli/cmd/gen/conditions/tests/results/goembedded.go index 043eead..4656b18 100644 --- a/cql-cli/cmd/gen/conditions/tests/results/goembedded.go +++ b/cql-cli/cmd/gen/conditions/tests/results/goembedded.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/cql-cli/cmd/gen/conditions/tests/results/gormembedded.go b/cql-cli/cmd/gen/conditions/tests/results/gormembedded.go index 5c09775..d3f4109 100644 --- a/cql-cli/cmd/gen/conditions/tests/results/gormembedded.go +++ b/cql-cli/cmd/gen/conditions/tests/results/gormembedded.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/cql-cli/cmd/gen/conditions/tests/results/hasmany_company.go b/cql-cli/cmd/gen/conditions/tests/results/hasmany_company.go index 7695074..28f489c 100644 --- a/cql-cli/cmd/gen/conditions/tests/results/hasmany_company.go +++ b/cql-cli/cmd/gen/conditions/tests/results/hasmany_company.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/cql-cli/cmd/gen/conditions/tests/results/hasmany_seller.go b/cql-cli/cmd/gen/conditions/tests/results/hasmany_seller.go index fd3c0e7..a6863f8 100644 --- a/cql-cli/cmd/gen/conditions/tests/results/hasmany_seller.go +++ b/cql-cli/cmd/gen/conditions/tests/results/hasmany_seller.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/cql-cli/cmd/gen/conditions/tests/results/hasmanywithpointers_company.go b/cql-cli/cmd/gen/conditions/tests/results/hasmanywithpointers_company.go index 3c701d5..7912037 100644 --- a/cql-cli/cmd/gen/conditions/tests/results/hasmanywithpointers_company.go +++ b/cql-cli/cmd/gen/conditions/tests/results/hasmanywithpointers_company.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/cql-cli/cmd/gen/conditions/tests/results/hasmanywithpointers_seller.go b/cql-cli/cmd/gen/conditions/tests/results/hasmanywithpointers_seller.go index f0c596e..823f673 100644 --- a/cql-cli/cmd/gen/conditions/tests/results/hasmanywithpointers_seller.go +++ b/cql-cli/cmd/gen/conditions/tests/results/hasmanywithpointers_seller.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/cql-cli/cmd/gen/conditions/tests/results/hasone_city.go b/cql-cli/cmd/gen/conditions/tests/results/hasone_city.go index 5990b7a..4a9ae74 100644 --- a/cql-cli/cmd/gen/conditions/tests/results/hasone_city.go +++ b/cql-cli/cmd/gen/conditions/tests/results/hasone_city.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/cql-cli/cmd/gen/conditions/tests/results/hasone_country.go b/cql-cli/cmd/gen/conditions/tests/results/hasone_country.go index d46a915..1d0186b 100644 --- a/cql-cli/cmd/gen/conditions/tests/results/hasone_country.go +++ b/cql-cli/cmd/gen/conditions/tests/results/hasone_country.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/cql-cli/cmd/gen/conditions/tests/results/multiplepackage_package1.go b/cql-cli/cmd/gen/conditions/tests/results/multiplepackage_package1.go index cfe8478..67004aa 100644 --- a/cql-cli/cmd/gen/conditions/tests/results/multiplepackage_package1.go +++ b/cql-cli/cmd/gen/conditions/tests/results/multiplepackage_package1.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/cql-cli/cmd/gen/conditions/tests/results/multiplepackage_package2.go b/cql-cli/cmd/gen/conditions/tests/results/multiplepackage_package2.go index c46769b..371fd29 100644 --- a/cql-cli/cmd/gen/conditions/tests/results/multiplepackage_package2.go +++ b/cql-cli/cmd/gen/conditions/tests/results/multiplepackage_package2.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/cql-cli/cmd/gen/conditions/tests/results/nullabletypes.go b/cql-cli/cmd/gen/conditions/tests/results/nullabletypes.go index 58a2ff5..6067445 100644 --- a/cql-cli/cmd/gen/conditions/tests/results/nullabletypes.go +++ b/cql-cli/cmd/gen/conditions/tests/results/nullabletypes.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/cql-cli/cmd/gen/conditions/tests/results/overrideforeignkey_bicycle.go b/cql-cli/cmd/gen/conditions/tests/results/overrideforeignkey_bicycle.go index 1730e1d..9609ed7 100644 --- a/cql-cli/cmd/gen/conditions/tests/results/overrideforeignkey_bicycle.go +++ b/cql-cli/cmd/gen/conditions/tests/results/overrideforeignkey_bicycle.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/cql-cli/cmd/gen/conditions/tests/results/overrideforeignkey_person.go b/cql-cli/cmd/gen/conditions/tests/results/overrideforeignkey_person.go index f17f025..ff0ae3f 100644 --- a/cql-cli/cmd/gen/conditions/tests/results/overrideforeignkey_person.go +++ b/cql-cli/cmd/gen/conditions/tests/results/overrideforeignkey_person.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/cql-cli/cmd/gen/conditions/tests/results/overrideforeignkeyinverse_credit_card.go b/cql-cli/cmd/gen/conditions/tests/results/overrideforeignkeyinverse_credit_card.go index 98fac02..9ece12c 100644 --- a/cql-cli/cmd/gen/conditions/tests/results/overrideforeignkeyinverse_credit_card.go +++ b/cql-cli/cmd/gen/conditions/tests/results/overrideforeignkeyinverse_credit_card.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/cql-cli/cmd/gen/conditions/tests/results/overrideforeignkeyinverse_user.go b/cql-cli/cmd/gen/conditions/tests/results/overrideforeignkeyinverse_user.go index 00f25d7..d584278 100644 --- a/cql-cli/cmd/gen/conditions/tests/results/overrideforeignkeyinverse_user.go +++ b/cql-cli/cmd/gen/conditions/tests/results/overrideforeignkeyinverse_user.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/cql-cli/cmd/gen/conditions/tests/results/overridereferences_brand.go b/cql-cli/cmd/gen/conditions/tests/results/overridereferences_brand.go index 5b14838..60f6b7e 100644 --- a/cql-cli/cmd/gen/conditions/tests/results/overridereferences_brand.go +++ b/cql-cli/cmd/gen/conditions/tests/results/overridereferences_brand.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/cql-cli/cmd/gen/conditions/tests/results/overridereferences_phone.go b/cql-cli/cmd/gen/conditions/tests/results/overridereferences_phone.go index eb71cd1..312f338 100644 --- a/cql-cli/cmd/gen/conditions/tests/results/overridereferences_phone.go +++ b/cql-cli/cmd/gen/conditions/tests/results/overridereferences_phone.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/cql-cli/cmd/gen/conditions/tests/results/overridereferencesinverse_computer.go b/cql-cli/cmd/gen/conditions/tests/results/overridereferencesinverse_computer.go index 1b387c7..bd332bb 100644 --- a/cql-cli/cmd/gen/conditions/tests/results/overridereferencesinverse_computer.go +++ b/cql-cli/cmd/gen/conditions/tests/results/overridereferencesinverse_computer.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/cql-cli/cmd/gen/conditions/tests/results/overridereferencesinverse_processor.go b/cql-cli/cmd/gen/conditions/tests/results/overridereferencesinverse_processor.go index 23841e7..f7f0e78 100644 --- a/cql-cli/cmd/gen/conditions/tests/results/overridereferencesinverse_processor.go +++ b/cql-cli/cmd/gen/conditions/tests/results/overridereferencesinverse_processor.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/cql-cli/cmd/gen/conditions/tests/results/selfreferential.go b/cql-cli/cmd/gen/conditions/tests/results/selfreferential.go index c6c8761..f509176 100644 --- a/cql-cli/cmd/gen/conditions/tests/results/selfreferential.go +++ b/cql-cli/cmd/gen/conditions/tests/results/selfreferential.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/cql-cli/cmd/gen/conditions/tests/results/uintmodel.go b/cql-cli/cmd/gen/conditions/tests/results/uintmodel.go index 33ccba3..f15a363 100644 --- a/cql-cli/cmd/gen/conditions/tests/results/uintmodel.go +++ b/cql-cli/cmd/gen/conditions/tests/results/uintmodel.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/cql-cli/cmd/gen/conditions/tests/results/uuidmodel.go b/cql-cli/cmd/gen/conditions/tests/results/uuidmodel.go index c01b5ce..6917e68 100644 --- a/cql-cli/cmd/gen/conditions/tests/results/uuidmodel.go +++ b/cql-cli/cmd/gen/conditions/tests/results/uuidmodel.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/cql-cli/cmd/gen/conditions/tests/selfreferential/badaas-orm_result.go b/cql-cli/cmd/gen/conditions/tests/selfreferential/cql_result.go similarity index 78% rename from cql-cli/cmd/gen/conditions/tests/selfreferential/badaas-orm_result.go rename to cql-cli/cmd/gen/conditions/tests/selfreferential/cql_result.go index 685e8e7..9347637 100644 --- a/cql-cli/cmd/gen/conditions/tests/selfreferential/badaas-orm_result.go +++ b/cql-cli/cmd/gen/conditions/tests/selfreferential/cql_result.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package selfreferential import preload "github.com/FrancoLiberali/cql/preload" diff --git a/cql-cli/cmd/gen/conditions/type.go b/cql-cli/cmd/gen/conditions/type.go index d4439d7..9f0bbeb 100644 --- a/cql-cli/cmd/gen/conditions/type.go +++ b/cql-cli/cmd/gen/conditions/type.go @@ -13,8 +13,8 @@ import ( ) var ( - // badaas/orm/baseModels.go - badaasORMBaseModels = []string{ + // cql/model/models.go + cqlBaseModels = []string{ modelPath + "." + uuidModel, modelPath + "." + uIntModel, } @@ -61,19 +61,19 @@ func (t Type) Pkg() *types.Package { } } -// Get the struct under type if it is a Badaas model -// Returns error if the type is not a Badaas model -func (t Type) BadaasModelStruct() (*types.Struct, error) { +// Get the struct under type if it is a cql model +// Returns error if the type is not a cql model +func (t Type) CQLModelStruct() (*types.Struct, error) { structType, ok := t.Underlying().(*types.Struct) - if !ok || !isBadaasModel(structType) { - return nil, fmt.Errorf("type %s is not a Badaas Model", t.String()) + if !ok || !isCQLModel(structType) { + return nil, fmt.Errorf("type %s is not a cql Model", t.String()) } return structType, nil } -// Returns true if the type is a Badaas model -func isBadaasModel(structType *types.Struct) bool { +// Returns true if the type is a cql model +func isCQLModel(structType *types.Struct) bool { for i := 0; i < structType.NumFields(); i++ { field := structType.Field(i) @@ -86,7 +86,7 @@ func isBadaasModel(structType *types.Struct) bool { } func isBaseModel(fieldName string) bool { - return pie.Contains(badaasORMBaseModels, fieldName) + return pie.Contains(cqlBaseModels, fieldName) } // Returns the fk field of the type to the "field"'s object diff --git a/cql-cli/cmd/root.go b/cql-cli/cmd/root.go index e64a9f0..e92fc96 100644 --- a/cql-cli/cmd/root.go +++ b/cql-cli/cmd/root.go @@ -10,9 +10,9 @@ import ( // rootCmd represents the base command when called without any subcommands var rootCmd = verdeter.BuildVerdeterCommand(verdeter.VerdeterConfig{ - Use: "badaas-cli", - Short: "the badaas command line client", - Long: `badaas-cli is the command line tool that makes it possible to configure and run your badaas applications easily.`, + Use: "cql-cli", + Short: "the cql command line client", + Long: `cql-cli is the command line tool that makes it possible to use cql in your project.`, Version: version.Version, }) diff --git a/cql-cli/go.mod b/cql-cli/go.mod index 6a73c27..6d5ca0c 100644 --- a/cql-cli/go.mod +++ b/cql-cli/go.mod @@ -4,6 +4,7 @@ go 1.18 require ( github.com/dave/jennifer v1.6.1 + // TODO change by FrancoLiberali/cql github.com/ditrit/badaas v0.0.0-20230829122312-83f5e8a9f307 github.com/ditrit/verdeter v0.4.0 github.com/elliotchance/pie/v2 v2.7.0 diff --git a/docker/cockroachdb/docker-compose.yml b/docker/cockroachdb/docker-compose.yml index 7b74318..312f23c 100644 --- a/docker/cockroachdb/docker-compose.yml +++ b/docker/cockroachdb/docker-compose.yml @@ -3,7 +3,7 @@ version: '3.5' services: db: - container_name: "badaas-test-db" + container_name: "cql-test-db" image: cockroachdb/cockroach:latest volumes: - .:/cockroach/files @@ -13,8 +13,8 @@ services: - "5000:26257" - "8080:8080" # Web based dashboard environment: - - COCKROACH_USER=badaas - - COCKROACH_DATABASE=badaas_db + - COCKROACH_USER=cql + - COCKROACH_DATABASE=cql_db healthcheck: test: curl --fail http://localhost:8080 || exit 1 interval: 10s diff --git a/docker/mysql/docker-compose.yml b/docker/mysql/docker-compose.yml index bcc350a..1b5a788 100644 --- a/docker/mysql/docker-compose.yml +++ b/docker/mysql/docker-compose.yml @@ -3,13 +3,13 @@ version: '3.5' services: db: - container_name: "badaas-test-db" + container_name: "cql-test-db" image: mysql:latest environment: MYSQL_ALLOW_EMPTY_PASSWORD: "true" - MYSQL_DATABASE: 'badaas_db' - MYSQL_USER: 'badaas' - MYSQL_PASSWORD: 'badaas_password2023' + MYSQL_DATABASE: 'cql_db' + MYSQL_USER: 'cql' + MYSQL_PASSWORD: 'cql_password2023' ports: - '5000:3306' healthcheck: diff --git a/docker/postgresql/docker-compose.yml b/docker/postgresql/docker-compose.yml index f21a2b2..f7644f8 100644 --- a/docker/postgresql/docker-compose.yml +++ b/docker/postgresql/docker-compose.yml @@ -3,12 +3,12 @@ version: '3.5' services: db: - container_name: "badaas-test-db" + container_name: "cql-test-db" image: postgres:latest environment: - POSTGRES_USER: badaas - POSTGRES_PASSWORD: badaas_password2023 - POSTGRES_DB: badaas_db + POSTGRES_USER: cql + POSTGRES_PASSWORD: cql_password2023 + POSTGRES_DB: cql_db PGDATA: /data/postgres ports: - "5000:5432" diff --git a/docker/sqlserver/docker-compose.yml b/docker/sqlserver/docker-compose.yml index 192f3ac..a8cd67e 100644 --- a/docker/sqlserver/docker-compose.yml +++ b/docker/sqlserver/docker-compose.yml @@ -3,14 +3,14 @@ version: "3.5" services: db: - container_name: "badaas-test-db" + container_name: "cql-test-db" build: . - image: badaas/mssqlserver:latest + image: cql/mssqlserver:latest ports: - "5000:1433" environment: - MSSQL_SA_PASSWORD: "badaas2023!" + MSSQL_SA_PASSWORD: "cql2023!" ACCEPT_EULA: "Y" - MSSQL_DB: badaas_db - MSSQL_USER: badaas - MSSQL_PASSWORD: badaas_password2023 \ No newline at end of file + MSSQL_DB: cql_db + MSSQL_USER: cql + MSSQL_PASSWORD: cql_password2023 \ No newline at end of file diff --git a/docker/wait_for_db.sh b/docker/wait_for_db.sh index 04263a1..75c8de1 100755 --- a/docker/wait_for_db.sh +++ b/docker/wait_for_db.sh @@ -1,6 +1,6 @@ #!/bin/sh -until [ "`docker inspect -f {{.State.Health.Status}} badaas-test-db`"=="healthy" ]; do +until [ "`docker inspect -f {{.State.Health.Status}} cql-test-db`"=="healthy" ]; do printf '.'; sleep 1; done; \ No newline at end of file diff --git a/docs/README.rst b/docs/README.rst index 75d490a..94835e4 100644 --- a/docs/README.rst +++ b/docs/README.rst @@ -1,10 +1,10 @@ :orphan: ====================================== -BaDaaS documentation quick start guide +CQL documentation quick start guide ====================================== -This file provides a quick guide on how to compile the BaDaaS documentation. +This file provides a quick guide on how to compile the CQL documentation. Setup the environment diff --git a/docs/badaas-orm/crud.rst b/docs/badaas-orm/crud.rst deleted file mode 100644 index 768a1c0..0000000 --- a/docs/badaas-orm/crud.rst +++ /dev/null @@ -1,69 +0,0 @@ -============================== -CRUD Operations -============================== - -CRUDServices and CRUDRepositories --------------------------------------- - -CRUD operations are made to your models via the CRUDServices and CRUDRepositories. -The difference between them is that a CRUDService will execute this operations within a transaction -while the CRUDRepository will be executed within a transaction received by parameter, -thus allowing defining services that perform multiple CRUD operations within the same transaction. - -Create, Save and Delete methods are just hooks to the gorm's corresponding methods. -For details visit -, and . -On the other hand, read (query) operations are provided by badaas-orm via its -:ref:`compilable query system ` -(see how in :doc:`/badaas-orm/query`). - -Each pair of CRUDService and CRUDRepository corresponds to a model. To create them you must use -the `orm.GetCRUD[, ](gormDB)` where -`` is the type of your :ref:`model `, -`` is the type of your :ref:`model's id ` -and `gormDB` is the :ref:`gorm.DB ` object. - -When using badaas-orm with `fx` as :ref:`dependency injector ` you -will need to provide to fx `orm.GetCRUDServiceModule[]()` -where `` is the type of your :ref:`model `. -After that the following can be used by dependency injection: - -- `crudYourModelService orm.CRUDService[, ]` -- `crudYourModelRepository orm.CRUDRepository[, ]` - -For example: - -.. code-block:: go - - - type YourModel struct { - model.UUIDModel - } - - func main() { - fx.New( - // connect to db - fx.Provide(NewDBConnection), - fx.Provide(GetModels), - orm.AutoMigrate, - - orm.GetCRUDServiceModule[YourModel](), - fx.Invoke(QueryCRUDObjects), - ).Run() - } - - func QueryCRUDObjects(crudYourModelService orm.CRUDService[YourModel, model.UUID]) { - // use crudYourModelService - } - -Transactions --------------------- - -To execute transactions badaas-orm provides the function orm.Transaction. -The function passed by parameter will be executed inside a gorm transaction -(for more information visit https://gorm.io/docs/transactions.html). -Using this method will also allow the transaction execution time to be logged. - -In accordance to the previous section, -CRUDServices make use of the orm.Transaction function while -CRUDRepositories must be called within one of them. diff --git a/docs/conf.py b/docs/conf.py index 86279d5..861639a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -6,9 +6,9 @@ # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information -project = 'BaDaaS' -copyright = '2023, DitRit' -author = 'DitRit' +project = 'cql' +copyright = '2023, Franco Liberali' +author = 'Franco Liberali' release = '0.0.1' version = '0.0.1' diff --git a/docs/contributing/contributing.md b/docs/contributing/contributing.md index e0ff5f5..c1babad 100644 --- a/docs/contributing/contributing.md +++ b/docs/contributing/contributing.md @@ -1,6 +1,6 @@ # Contributing -Thank you for your interest in BaDaaS! This document provides the guidelines for how to contribute to the project through issues and pull-requests. Contributions can also come in additional ways such as joining the [DitRit discord server](https://discord.gg/zkKfj9gj2C), commenting on issues or pull requests and more. +Thank you for your interest in CQL! This document provides the guidelines for how to contribute to the project through issues and pull-requests. Contributions can also come in additional ways such as commenting on issues or pull requests and more. ## Issues @@ -12,14 +12,12 @@ There are 3 types of issues: - Discussion: You have something on your mind, which requires input form others in a discussion, before it eventually manifests as a proposal. - Feature request: Used for items that propose a new idea or functionality. This allows feedback from others before code is written. -To ask questions and troubleshoot, please join the [DitRit discord server](https://discord.gg/zkKfj9gj2C) (use the BADAAS channel). - ### Before submitting Before you submit an issue, make sure you’ve checked the following: 1. Check for existing issues - - Before you create a new issue, please do a search in [open issues](https://github.com/ditrit/badaas/issues) to see if the issue or feature request has already been filed. + - Before you create a new issue, please do a search in [open issues](https://github.com/FrancoLiberali/cql/issues) to see if the issue or feature request has already been filed. - If you find your issue already exists, make relevant comments and add your reaction. 2. For bugs - It’s not an environment issue. @@ -32,11 +30,11 @@ All contributions come through pull requests. To submit a proposed change, follo 1. Make sure there's an issue (bug report or feature request) opened, which sets the expectations for the contribution you are about to make 2. Assign yourself to the issue and add the `wip` tag -3. Fork the [repo](https://github.com/ditrit/badaas) and create a new [branch](#branch-naming-policy) from the issue +3. Fork the [repo](https://github.com/FrancoLiberali/cql) and create a new [branch](#branch-naming-policy) from the issue 4. Install the necessary [development environment](developing.md#environment) 5. Create your change and the corresponding [tests](developing.md#tests) 6. Update relevant documentation for the change in `docs/` -7. If changes are necessary in [BaDaaS example](https://github.com/ditrit/badaas-example), [badaas-orm quickstart](https://github.com/ditrit/badaas-orm-quickstart) and [badaas-orm tutorial](https://github.com/ditrit/badaas-orm-tutorial), follow the same workflow there +7. If changes are necessary in [cql quickstart](https://github.com/FrancoLiberali/cql-quickstart) and [cql tutorial](https://github.com/FrancoLiberali/cql-tutorial), follow the same workflow there 8. Open a PR (and add links to the example repos' PR if they exist) 9. Wait for the CI process to finish and make sure all checks are green 10. A maintainer of the project will be assigned @@ -63,4 +61,4 @@ A good way to communicate before investing too much time is to create a "Work-in ## Code of Conduct -This project has adopted the [Contributor Covenant Code of Conduct](https://github.com/ditrit/badaas/blob/main/CODE_OF_CONDUCT.md) +This project has adopted the [Contributor Covenant Code of Conduct](https://github.com/FrancoLiberali/cql/blob/main/CODE_OF_CONDUCT.md) diff --git a/docs/contributing/developing.md b/docs/contributing/developing.md index 98412a4..9ae0b79 100644 --- a/docs/contributing/developing.md +++ b/docs/contributing/developing.md @@ -14,7 +14,6 @@ This is the directory structure we use for the project: - `docker/` : Contains the docker, docker-compose and configuration files for different environments. - `docs/`: Contains the documentation showed for readthedocs.io. -- `orm/` *(Go code)*: Contains the code of the orm used by badaas. - `test/`: Contains all the tests. At the root of the project, you will find: @@ -35,7 +34,7 @@ We use `golangci-lint` for linting our code. You can test it with `make lint`. T ### Tests -We use the standard test suite in combination with [github.com/stretchr/testify](https://github.com/stretchr/testify) to do our testing. Tests have a database. Badaas-orm is tested on multiple databases. By default, the database used will be postgresql: +We use the standard test suite in combination with [github.com/stretchr/testify](https://github.com/stretchr/testify) to do our testing. Tests have a database. CQL is tested on multiple databases. By default, the database used will be postgresql: ```sh make test @@ -49,7 +48,7 @@ To be acceptable, contributions must: - Have a good quality of code, based on . - Have at least 80 percent new code coverage (although a higher percentage may be required depending on the importance of the feature). The tests that contribute to coverage are unit tests and integration tests. -- The features defined in the PR base issue must be explicitly tested by an e2e test or by integration tests in case it is not possible (for badaas-orm features for example). +- The features defined in the PR base issue must be explicitly tested by tests. ## Use of Third-party code diff --git a/docs/contributing/maintaining.md b/docs/contributing/maintaining.md index 44ce9c4..5069f78 100644 --- a/docs/contributing/maintaining.md +++ b/docs/contributing/maintaining.md @@ -1,6 +1,6 @@ # Maintaining -This document is intended for BaDaaS maintainers only. +This document is intended for CQL maintainers only. ## How to release diff --git a/docs/badaas-orm/advanced_query.rst b/docs/cql/advanced_query.rst similarity index 93% rename from docs/badaas-orm/advanced_query.rst rename to docs/cql/advanced_query.rst index f859bc8..c108e79 100644 --- a/docs/badaas-orm/advanced_query.rst +++ b/docs/cql/advanced_query.rst @@ -5,7 +5,7 @@ Advanced query Dynamic operators -------------------------------- -In :doc:`/badaas-orm/query` we have seen how to use the operators +In :doc:`/cql/query` we have seen how to use the operators to make comparisons between the attributes of a model and static values such as a string, a number, etc. But if we want to make comparisons between two or more attributes of the same type we need to use the dynamic operators. @@ -71,7 +71,7 @@ For example: will respond orm.ErrFieldModelNotConcerned in err. -All operators supported by badaas-orm that receive any value are available in their dynamic version +All operators supported by cql that receive any value are available in their dynamic version after using the Dynamic() method of the FieldIs object. Select join @@ -138,14 +138,14 @@ types map at the same time in the database (see ` object. +To communicate with the database cql need a :ref:`GormDB ` object. To create it, you can use the function `orm.Open` that will allow you to connect to a database using the specified dialector. This function is equivalent to `gorm.Open` but with the difference that in case of not adding any configuration, -the badaas-orm default logger will be configured instead of the gorm one. -For details about this logger visit :doc:`/badaas-orm/logger`. +the cql default logger will be configured instead of the gorm one. +For details about this logger visit :doc:`/cql/logger`. For details about gorm configuration visit `gorm documentation `_. Migration diff --git a/docs/badaas-orm/declaring_models.rst b/docs/cql/declaring_models.rst similarity index 85% rename from docs/badaas-orm/declaring_models.rst rename to docs/cql/declaring_models.rst index 94ef757..ac252de 100644 --- a/docs/badaas-orm/declaring_models.rst +++ b/docs/cql/declaring_models.rst @@ -5,16 +5,16 @@ Declaring models Model declaration ----------------------- -The badaas-orm :ref:`model ` declaration is based on the GORM model declaration, -so its definition, conventions, tags and associations are compatible with badaas-orm. +The cql :ref:`model ` declaration is based on the GORM model declaration, +so its definition, conventions, tags and associations are compatible with cql. For details see `gorm documentation `_. -On the contrary, badaas-orm presents some differences/extras that are explained in this section. +On the contrary, cql presents some differences/extras that are explained in this section. Base models ----------------------- To be considered a model, your structures must have embedded one of the -:ref:`base models ` provided by badaas-orm: +:ref:`base models ` provided by cql: - `model.UUIDModel`: Model identified by a model.UUID (Random (Version 4) UUID). - `model.UIntModel`: Model identified by a model.UIntID (auto-incremental uint). @@ -42,7 +42,7 @@ Type of attributes As we can see in the example in the previous section, the attributes of your models can be of multiple types, -such as basic go types, pointers, and :ref:`nullable types `. +such as basic go types, pointers, and :ref:`nullable types `. This difference can generate differences in the information that is stored in the database, since saving a model created as follows: @@ -53,7 +53,7 @@ since saving a model created as follows: will save a empty string for Name but a null for the Email and the MemberNumber. -The use of nullable types is strongly recommended and badaas-orm takes into account +The use of nullable types is strongly recommended and cql takes into account their use in each of its functionalities. Associations @@ -63,13 +63,13 @@ All associations provided by GORM are supported. For more information see , , and . -However, in this section we will give some differences in badaas-orm and +However, in this section we will give some differences in cql and details that are not clear in this documentation. IDs ^^^^^^^^^^^^^^^^^^^^^ -Since badaas-orm base models use model.UUID or model.UIntID to identify the models, +Since cql base models use model.UUID or model.UIntID to identify the models, the type of id used in a reference to another model is the corresponding one of these two, for example: @@ -128,7 +128,7 @@ this can make a difference when persisting, since one created as follows: ModelWithoutPointer{} will also create and save an empty ReferencedModel{}, what may be undesired behavior. -For this reason, although both options are still compatible with badaas-orm, +For this reason, although both options are still compatible with cql, we recommend the use of pointers for references. In case the relation is not nullable, use the `not null` tag in the id of the reference, for example: diff --git a/docs/badaas-orm/index.rst b/docs/cql/index.rst similarity index 81% rename from docs/badaas-orm/index.rst rename to docs/cql/index.rst index 1cf9607..e9161d9 100644 --- a/docs/badaas-orm/index.rst +++ b/docs/cql/index.rst @@ -2,15 +2,14 @@ Introduction ============================== -Badaas-orm is the BaDaaS' component that allows for easy and safe persistence and querying of objects but -it can be used both within a BaDaaS application and independently. +CQL allows easy and safe persistence and querying of objects. It's built on top of `gorm `_, a library that actually provides the functionality of an ORM: mapping objects to tables in the SQL database. While gorm does this job well with its automatic migration then performing queries on these objects is somewhat limited, forcing us to write SQL queries directly when they are complex. -Badaas-orm seeks to address these limitations with a query system that: +CQL seeks to address these limitations with a query system that: - Is compile-time safe: its query system is validated at compile time to avoid errors such as @@ -32,5 +31,5 @@ Badaas-orm seeks to address these limitations with a query system that: the query system avoids as much as possible the use of reflection and aims that all the necessary model data can be retrieved in a single query to the database. -To see how to start using badaas-orm in your project you can read the :doc:`quickstart`. -If you are interested in learning how to use the features provided by badaas-orm you can read the :doc:`tutorial`. +To see how to start using cql in your project you can read the :doc:`quickstart`. +If you are interested in learning how to use the features provided by cql you can read the :doc:`tutorial`. diff --git a/docs/badaas-orm/logger.rst b/docs/cql/logger.rst similarity index 90% rename from docs/badaas-orm/logger.rst rename to docs/cql/logger.rst index 751aa7b..e80c478 100644 --- a/docs/badaas-orm/logger.rst +++ b/docs/cql/logger.rst @@ -4,7 +4,7 @@ Logger When connecting to the database, i.e. when creating the `gorm.DB` object, it is possible to configure the type of logger to use, the logging level, among others. -As explained in the :ref:`connection section `, +As explained in the :ref:`connection section `, this can be done by using the `orm.Open` method: .. code-block:: go @@ -21,7 +21,7 @@ Any logger that complies with `logger.Interface` can be configured. Log levels ------------------------------ -The log levels provided by badaas-orm are the same as those of gorm: +The log levels provided by cql are the same as those of gorm: - `logger.Error`: To only view error messages in case they occur during the execution of a sql query. - `logger.Warn`: The previous level plus warnings for execution of queries and transactions that take @@ -39,10 +39,10 @@ to be performed, it is necessary to use the orm.Transaction method. Default logger ------------------------------- -badaas-orm provides a default logger that will print Slow SQL and happening errors. +cql provides a default logger that will print Slow SQL and happening errors. You can create one with the default configuration using -(take into account that logger is github.com/ditrit/badaas/orm/logger +(take into account that logger is github.com/FrancoLiberali/cql/logger and gormLogger is gorm.io/gorm/logger): .. code-block:: go @@ -73,7 +73,7 @@ The LogLevel is also configurable via the `ToLogMode` method. Zap logger ------------------------------ -badaas-orm provides the possibility to use `zap `_ as logger. +cql provides the possibility to use `zap `_ as logger. For this, there is a package called `gormzap`. The information displayed by the zap logger will be the same as if we were using the default logger but in a structured form, with the following information: diff --git a/docs/badaas-orm/preloading.rst b/docs/cql/preloading.rst similarity index 90% rename from docs/badaas-orm/preloading.rst rename to docs/cql/preloading.rst index 581060c..17570e5 100644 --- a/docs/badaas-orm/preloading.rst +++ b/docs/cql/preloading.rst @@ -5,7 +5,7 @@ Preloading PreloadConditions --------------------------- -During the :ref:`conditions generation ` the following +During the :ref:`conditions generation ` the following methods will also be created for the condition models: - Preload() will allow to preload this model when doing a query. @@ -95,12 +95,12 @@ The problem is that once we get the result of the query, we cannot determine if corresponds to the fact that the relation is really null or that the preload was not performed, which means a big risk of making decisions in our business logic on incomplete information. -For this reason, badaas-orm provides the Relation getters. +For this reason, cql provides the Relation getters. These are methods that will be added to your models to safely navigate a relation, responding `errors.ErrRelationNotLoaded` in case you try to navigate a relation that was not loaded from the database. -They are created in a file called badaas-orm.go in your model package when -:ref:`generating conditions `. +They are created in a file called cql.go in your model package when +:ref:`generating conditions `. Here is an example of its use: @@ -133,6 +133,6 @@ Here is an example of its use: Unfortunately, these relation getters cannot be created in all cases but only in those in which: - The relation is made with an object directly instead of a pointer - (which is not recommended as described :ref:`here `). + (which is not recommended as described :ref:`here `). - The relation is made with pointers and the foreign key (typically the ID) is in the same model. - The relation is made with a pointer to a list. \ No newline at end of file diff --git a/docs/badaas-orm/query.rst b/docs/cql/query.rst similarity index 85% rename from docs/badaas-orm/query.rst rename to docs/cql/query.rst index 8335315..8273183 100644 --- a/docs/badaas-orm/query.rst +++ b/docs/cql/query.rst @@ -5,20 +5,20 @@ Query Create, Save and Delete methods are done directly with gormDB object using the corresponding methods. For details visit , and . -On the other hand, read (query) operations are provided by badaas-orm via its compilable query system. +On the other hand, read (query) operations are provided by cql via its compilable query system. Query creation ----------------------- To create a query you must use the orm.NewQuery[models.MyModel] method, where models.MyModel is the model you expect this query to answer. -This function takes as parameters the :ref:`transaction ` -on which to execute the query and the query :ref:`badaas-orm/query:conditions`. +This function takes as parameters the :ref:`transaction ` +on which to execute the query and the query :ref:`cql/query:conditions`. Transactions -------------------- -To execute transactions badaas-orm provides the function orm.Transaction. +To execute transactions cql provides the function orm.Transaction. The function passed by parameter will be executed inside a gorm transaction (for more information visit https://gorm.io/docs/transactions.html). Using this method will also allow the transaction execution time to be logged. @@ -53,21 +53,21 @@ Conditions ------------------------ The set of conditions that are received by the `orm.NewQuery` method -form the badaas-orm compilable query system. +form the cql compilable query system. It is so named because the conditions will verify at compile time that the query to be executed is correct. These conditions are objects of type Condition that contain the necessary information to perform the queries in a safe way. -They are generated from the definition of your models using badaas-cli. +They are generated from the definition of your models using cql-cli. Conditions generation ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -The generation of conditions is done with badaas-cli. For this, we need to install badaas-cli: +The generation of conditions is done with cql-cli. For this, we need to install cql-cli: .. code-block:: bash - go install github.com/ditrit/badaas-cli + go install github.com/FrancoLiberali/cql/cql-cli Then, inside our project we will have to create a package called conditions (or another name if you wish) and inside it a file with the following content: @@ -76,7 +76,7 @@ Then, inside our project we will have to create a package called conditions package conditions - //go:generate badaas-cli gen conditions ../models_path_1 ../models_path_2 + //go:generate cql-cli gen conditions ../models_path_1 ../models_path_2 where ../models_path_1 ../models_path_2 are the relative paths between the package conditions and the packages containing the definition of your models (can be only one). @@ -101,14 +101,14 @@ This variable is called the condition model and it has: - An attribute for each attribute of your original model with the same name (if models.MyModel.Name exists, then conditions.MyModel.Name is generated), of type FieldIdentifier that allows to use that attribute in queries - (for :ref:`dynamic conditions ` for example). + (for :ref:`dynamic conditions ` for example). - A method for each attribute of your original model with the same name + Is (if models.MyModel.Name exists, then conditions.MyModel.NameIs() is generated), which will allow you to create operations for that attribute in your queries. - A method for each relation of your original model with the same name (if models.MyModel.MyOtherModel exists, then conditions.MyModel.MyOtherModel() is generated), which will allow you to perform joins in your queries. -- Methods for :doc:`/badaas-orm/preloading`. +- Methods for :doc:`/cql/preloading`. Then, combining these conditions, the Connection Conditions (cql.And, cql.Or, cql.Not) you will be able to make all the queries you need in a safe way. @@ -219,10 +219,10 @@ Below you will find the complete list of available operators: - In(values) - NotIn(values) -In addition to these, badaas-orm gives the possibility to use operators +In addition to these, cql gives the possibility to use operators that are only supported by a certain database (outside the standard). -These operators can be found in , -, - -and . +These operators can be found in , +, + +and . To use them, use the Custom method of FieldIs type. diff --git a/docs/badaas-orm/quickstart.rst b/docs/cql/quickstart.rst similarity index 66% rename from docs/badaas-orm/quickstart.rst rename to docs/cql/quickstart.rst index b81dbb5..00f95b5 100644 --- a/docs/badaas-orm/quickstart.rst +++ b/docs/cql/quickstart.rst @@ -2,21 +2,21 @@ Quickstart ============================== -To integrate badaas-orm into your project, you can head to the -`quickstart `_. +To integrate cql into your project, you can head to the +`quickstart `_. Refer to its README.md for running it. Understand it ---------------------------------- -Once you have started your project with `go init`, you must add the dependency to BaDaaS: +Once you have started your project with `go init`, you must add the dependency to cql: .. code-block:: bash - go get -u github.com/ditrit/badaas + go get -u github.com/FrancoLiberali/cql -Create a package for your :ref:`models `, for example: +Create a package for your :ref:`models `, for example: .. code-block:: go @@ -32,7 +32,7 @@ Create a package for your :ref:`models `, for example Name string } -Once done, you can :ref:`generate the conditions ` +Once done, you can :ref:`generate the conditions ` to perform queries on them. Create a new package named conditions and add a file with the following content: @@ -40,12 +40,12 @@ Create a new package named conditions and add a file with the following content: package conditions - //go:generate badaas-cli gen conditions ../models + //go:generate cql-cli gen conditions ../models -Then, you can generate the conditions using `badaas-cli` as described in the README.md. +Then, you can generate the conditions using `cql-cli` as described in the README.md. -In main.go create a main function that creates a :ref:`gorm.DB ` -that allows connection with the database and call the :ref:`AutoMigrate ` +In main.go create a main function that creates a :ref:`gorm.DB ` +that allows connection with the database and call the :ref:`AutoMigrate ` method with the models you want to be persisted: .. code-block:: go @@ -68,7 +68,7 @@ method with the models you want to be persisted: func NewDBConnection() (*gorm.DB, error) { return orm.Open( - postgres.Open(orm.CreatePostgreSQLDSN("localhost", "root", "postgres", "disable", "badaas_db", 26257)), + postgres.Open(orm.CreatePostgreSQLDSN("localhost", "root", "postgres", "disable", "cql_db", 26257)), &gorm.Config{ Logger: logger.Default.ToLogMode(logger.Info), }, @@ -78,5 +78,5 @@ method with the models you want to be persisted: Use it ---------------------- -Now that you know how to integrate badaas-orm into your project, +Now that you know how to integrate cql into your project, you can learn how to use it by following the :doc:`tutorial`. \ No newline at end of file diff --git a/docs/badaas-orm/tutorial.rst b/docs/cql/tutorial.rst similarity index 90% rename from docs/badaas-orm/tutorial.rst rename to docs/cql/tutorial.rst index f4e0bbb..075cd5c 100644 --- a/docs/badaas-orm/tutorial.rst +++ b/docs/cql/tutorial.rst @@ -2,19 +2,19 @@ Tutorial ============================== -In this short tutorial you will learn the main functionalities of badaas-orm. -The code to be executed in each step can be found in this `repository `_. +In this short tutorial you will learn the main functionalities of cql. +The code to be executed in each step can be found in this `repository `_. Model and data ----------------------- In the file `models/models.go` you find the definition of the following model: -.. image:: /img/badaas-orm-tutorial-model.png +.. image:: /img/cql-tutorial-model.png :width: 700 - :alt: badaas-orm tutorial model + :alt: cql tutorial model -For details about the definition of models you can read :doc:`/badaas-orm/declaring_models`. +For details about the definition of models you can read :doc:`/cql/declaring_models`. In `sqlite:db` you will find a sqlite database with the following data: @@ -56,7 +56,7 @@ the well known Paris, capital of France and site of the iconic Eiffel tower, and Paris in the United States of America, site of the Eiffel tower with the cowboy hat (no joke, just search for paris texas eiffel tower in your favorite search engine). -In this tutorial we will explore the badaas-orm functions that will allow us to differentiate these two Paris. +In this tutorial we will explore the cql functions that will allow us to differentiate these two Paris. Tutorial 1: simple query ------------------------------- @@ -82,8 +82,8 @@ We can run this tutorial with `make tutorial_1` and we will obtain the following As you can see, in this case we will get both cities which we can differentiate by their population and the id of the country. -In this tutorial we have used the badaas-orm compilable queries system to get these cities, -for more details you can read :ref:`badaas-orm/query:conditions`. +In this tutorial we have used the cql compilable queries system to get these cities, +for more details you can read :ref:`cql/query:conditions`. Tutorial 2: operators ------------------------------- @@ -112,7 +112,7 @@ We can run this tutorial with `make tutorial_2` and we will obtain the following As you can see, in this case we only get one city, Paris in France. In this tutorial we have used the operator Gt to obtain this city, -for more details you can read :ref:`badaas-orm/query:Operators`. +for more details you can read :ref:`cql/query:Operators`. Tutorial 3: modifiers ------------------------------- @@ -145,7 +145,7 @@ This is because in this case we are sure that the result is a single model, so instead of getting a list we get a single city. In this tutorial we have used query modifier methods, -for more details you can read :ref:`badaas-orm/query:Query methods`. +for more details you can read :ref:`cql/query:Query methods`. Tutorial 4: joins ------------------------------- @@ -177,13 +177,13 @@ We can run this tutorial with `make tutorial_4` and we will obtain the following As you can see, again we get only the Paris in France. In this tutorial we have used a condition that performs a join, -for more details you can read :ref:`badaas-orm/query:Use of the conditions`. +for more details you can read :ref:`cql/query:Use of the conditions`. Tutorial 5: preloading ------------------------------- You may have noticed that in the results of the previous tutorials the Country field of the cities was null (Country:). -This is because, to ensure performance, badaas-orm will retrieve only the attributes of the model +This is because, to ensure performance, cql will retrieve only the attributes of the model you are querying (City in this case because the method used is orm.NewQuery[models.City]) but not of its relationships. If we also want to obtain this data, we must perform preloading. @@ -209,13 +209,13 @@ We can run this tutorial with `make tutorial_5` and we will obtain the following As you can see, now the country attribute is a valid pointer to a Country object (Country:0xc0001d1600). Then the Country object information is accessed with the `GetCountry` method. -This method is not defined in the `models/models.go` file but is a :ref:`relation getter ` -that is generated by badaas-cli together with the conditions. +This method is not defined in the `models/models.go` file but is a :ref:`relation getter ` +that is generated by cql-cli together with the conditions. These methods allow us to differentiate null objects from objects not loaded from the database, since when trying to browse a relation that was not loaded we will get `errors.ErrRelationNotLoaded`. In this tutorial we have used preloading and relation getters, -for more details you can read :doc:`/badaas-orm/preloading`. +for more details you can read :doc:`/cql/preloading`. Tutorial 6: dynamic operators ------------------------------- @@ -246,4 +246,4 @@ We can run this tutorial with `make tutorial_6` and we will obtain the following As you can see, again we only get the Paris in France. In this tutorial we have used dynamic conditions, -for more details you can read :ref:`badaas-orm/advanced_query:Dynamic operators`. +for more details you can read :ref:`cql/advanced_query:Dynamic operators`. diff --git a/docs/img/badaas-orm-tutorial-model.png b/docs/img/cql-tutorial-model.png similarity index 100% rename from docs/img/badaas-orm-tutorial-model.png rename to docs/img/cql-tutorial-model.png diff --git a/docs/index.rst b/docs/index.rst index 08be69f..24fd513 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -3,18 +3,18 @@ Introduction ============================== .. toctree:: - :caption: Badaas-orm + :caption: CQL - badaas-orm/index - badaas-orm/quickstart - badaas-orm/tutorial - badaas-orm/concepts - badaas-orm/declaring_models - badaas-orm/connecting_to_a_database - badaas-orm/query - badaas-orm/advanced_query - badaas-orm/preloading - badaas-orm/logger + cql/index + cql/quickstart + cql/tutorial + cql/concepts + cql/declaring_models + cql/connecting_to_a_database + cql/query + cql/advanced_query + cql/preloading + cql/logger .. toctree:: :caption: Contributing @@ -22,4 +22,4 @@ Introduction contributing/contributing contributing/developing contributing/maintaining - Github + Github diff --git a/logger/default.go b/logger/default.go index 9be2548..6ddd9b9 100644 --- a/logger/default.go +++ b/logger/default.go @@ -86,7 +86,7 @@ const defaultStacktraceLen = 2 func (w writerWrapper) Printf(msg string, args ...interface{}) { if len(args) > 0 { - // change the file path to avoid showing badaas-orm internal files + // change the file path to avoid showing cql internal files firstArg := args[0] _, isString := firstArg.(string) diff --git a/logger/logger.go b/logger/logger.go index 72fefb5..518d1aa 100644 --- a/logger/logger.go +++ b/logger/logger.go @@ -48,7 +48,7 @@ func (c Config) toGormConfig() gormLogger.Config { } } -// search in the stacktrace the last file outside gormzap, badaas-orm and gorm +// search in the stacktrace the last file outside gormzap, cql and gorm func FindLastCaller(skip int) (string, int, int) { // +1 because at least one will be inside gorm // +1 because of this function @@ -58,8 +58,8 @@ func FindLastCaller(skip int) (string, int, int) { if !ok { // we checked in all the stacktrace and none meet the conditions, return "", 0, 0 - } else if !strings.Contains(file, gormSourceDir) && !strings.Contains(file, badaasORMSourceDir) { - // file outside badaas-orm and gorm + } else if !strings.Contains(file, gormSourceDir) && !strings.Contains(file, cqlSourceDir) { + // file outside cql and gorm return file, line, i - 1 // -1 to remove this function from the stacktrace } } @@ -68,19 +68,19 @@ func FindLastCaller(skip int) (string, int, int) { } var ( - badaasORMSourceDir string - gormSourceDir = filepath.Join("gorm.io", "gorm") + cqlSourceDir string + gormSourceDir = filepath.Join("gorm.io", "gorm") ) func init() { _, file, _, _ := runtime.Caller(0) - // compatible solution to get badaas-orm source directory with various operating systems - badaasORMSourceDir = sourceDir(file) + // compatible solution to get cql source directory with various operating systems + cqlSourceDir = sourceDir(file) } func sourceDir(file string) string { loggerDir := filepath.Dir(file) - badaasORMDir := filepath.Dir(loggerDir) + cqlDir := filepath.Dir(loggerDir) - return filepath.ToSlash(badaasORMDir) + "/" + return filepath.ToSlash(cqlDir) + "/" } diff --git a/test/conditions/bicycle_conditions.go b/test/conditions/bicycle_conditions.go index a25b92f..985608e 100644 --- a/test/conditions/bicycle_conditions.go +++ b/test/conditions/bicycle_conditions.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/test/conditions/brand_conditions.go b/test/conditions/brand_conditions.go index 5ca4a5c..2908844 100644 --- a/test/conditions/brand_conditions.go +++ b/test/conditions/brand_conditions.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/test/conditions/child_conditions.go b/test/conditions/child_conditions.go index 754082f..e496aeb 100644 --- a/test/conditions/child_conditions.go +++ b/test/conditions/child_conditions.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/test/conditions/city_conditions.go b/test/conditions/city_conditions.go index ccb5821..edc99d5 100644 --- a/test/conditions/city_conditions.go +++ b/test/conditions/city_conditions.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/test/conditions/company_conditions.go b/test/conditions/company_conditions.go index 5254872..046fa5e 100644 --- a/test/conditions/company_conditions.go +++ b/test/conditions/company_conditions.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/test/conditions/country_conditions.go b/test/conditions/country_conditions.go index 82b5c59..e93b9c7 100644 --- a/test/conditions/country_conditions.go +++ b/test/conditions/country_conditions.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/test/conditions/employee_conditions.go b/test/conditions/employee_conditions.go index f5c3cd4..e8281ec 100644 --- a/test/conditions/employee_conditions.go +++ b/test/conditions/employee_conditions.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/test/conditions/orm.go b/test/conditions/orm.go index 78acbc6..765a265 100644 --- a/test/conditions/orm.go +++ b/test/conditions/orm.go @@ -1,3 +1,3 @@ package conditions -//go:generate badaas-cli gen conditions ../models +//go:generate cql-cli gen conditions ../models diff --git a/test/conditions/parent1_conditions.go b/test/conditions/parent1_conditions.go index db14444..ffdfd9c 100644 --- a/test/conditions/parent1_conditions.go +++ b/test/conditions/parent1_conditions.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/test/conditions/parent2_conditions.go b/test/conditions/parent2_conditions.go index f788de4..722581f 100644 --- a/test/conditions/parent2_conditions.go +++ b/test/conditions/parent2_conditions.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/test/conditions/parent_parent_conditions.go b/test/conditions/parent_parent_conditions.go index 88e7f00..921b612 100644 --- a/test/conditions/parent_parent_conditions.go +++ b/test/conditions/parent_parent_conditions.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/test/conditions/person_conditions.go b/test/conditions/person_conditions.go index 2369535..9fb2230 100644 --- a/test/conditions/person_conditions.go +++ b/test/conditions/person_conditions.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/test/conditions/phone_conditions.go b/test/conditions/phone_conditions.go index eb01ba2..c3ccc8e 100644 --- a/test/conditions/phone_conditions.go +++ b/test/conditions/phone_conditions.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/test/conditions/product_conditions.go b/test/conditions/product_conditions.go index e4de5a6..30056cc 100644 --- a/test/conditions/product_conditions.go +++ b/test/conditions/product_conditions.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/test/conditions/sale_conditions.go b/test/conditions/sale_conditions.go index 485d36b..03dfc39 100644 --- a/test/conditions/sale_conditions.go +++ b/test/conditions/sale_conditions.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/test/conditions/seller_conditions.go b/test/conditions/seller_conditions.go index 6ff7e59..442594b 100644 --- a/test/conditions/seller_conditions.go +++ b/test/conditions/seller_conditions.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/test/conditions/university_conditions.go b/test/conditions/university_conditions.go index eb229aa..fcc2013 100644 --- a/test/conditions/university_conditions.go +++ b/test/conditions/university_conditions.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package conditions import ( diff --git a/test/main_test.go b/test/main_test.go index ddfedf2..e64734d 100644 --- a/test/main_test.go +++ b/test/main_test.go @@ -21,15 +21,15 @@ import ( const dbTypeEnvKey = "DB" const ( - username = "badaas" - password = "badaas_password2023" + username = "cql" + password = "cql_password2023" host = "localhost" port = 5000 sslMode = "disable" - dbName = "badaas_db" + dbName = "cql_db" ) -func TestBaDaaSORM(t *testing.T) { +func TestCQL(t *testing.T) { db, err := NewDBConnection() if err != nil { log.Fatalln(err) diff --git a/test/models/badaas-orm.go b/test/models/cql.go similarity index 96% rename from test/models/badaas-orm.go rename to test/models/cql.go index b14323e..826ff0e 100644 --- a/test/models/badaas-orm.go +++ b/test/models/cql.go @@ -1,4 +1,4 @@ -// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +// Code generated by cql-cli v0.0.0, DO NOT EDIT. package models import preload "github.com/FrancoLiberali/cql/preload" diff --git a/unsafe/condition.go b/unsafe/condition.go index 12f1bae..72ecaa1 100644 --- a/unsafe/condition.go +++ b/unsafe/condition.go @@ -7,7 +7,7 @@ import ( "github.com/FrancoLiberali/cql/model" ) -// Condition that can be used to express conditions that are not supported (yet?) by badaas-orm +// Condition that can be used to express conditions that are not supported (yet?) by cql // Example: table1.columnX = table2.columnY type unsafeCondition[T model.Model] struct { SQLCondition string @@ -34,7 +34,7 @@ func (unsafeCondition unsafeCondition[T]) AffectsDeletedAt() bool { return false } -// Condition that can be used to express conditions that are not supported (yet?) by badaas-orm +// Condition that can be used to express conditions that are not supported (yet?) by cql // Example: table1.columnX = table2.columnY func NewCondition[T model.Model](sqlCondition string, values ...any) condition.Condition[T] { return unsafeCondition[T]{