-
Notifications
You must be signed in to change notification settings - Fork 5
Updating readme with unsupported/depreciation notice #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,77 +1,95 @@ | ||
| # pika | ||
|
|
||
| ORM-like SQL builder inspired by [kayak/pypika](https://github.com/kayak/pypika) | ||
|
|
||
| --- | ||
|
|
||
| # Notice of Deprecation | ||
|
|
||
| This repository contains the original code for pika, which was developed by CIQ as | ||
| a proof of concept (POC). It is intended solely as an illustrative example and is | ||
| provided as-is for reference purposes only. | ||
|
|
||
| > THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
|
||
| By using this software, you acknowledge and agree to these terms. | ||
|
|
||
| --- | ||
|
|
||
| # Features | ||
| * Any feature supported by sqlx | ||
| * Support for [AIP-160](https://google.aip.dev/160) filtering | ||
| * Utilities to help with [AIP-132](https://google.aip.dev/132) for List calls | ||
| * Support for determining filters based on Protobuf messages | ||
| * Automatically selecting columns in struct | ||
| * Count, Get, All, Create, Update, Delete and more. | ||
| * Support for simple joins | ||
|
|
||
| - Any feature supported by sqlx | ||
| - Support for [AIP-160](https://google.aip.dev/160) filtering | ||
| - Utilities to help with [AIP-132](https://google.aip.dev/132) for List calls | ||
| - Support for determining filters based on Protobuf messages | ||
| - Automatically selecting columns in struct | ||
| - Count, Get, All, Create, Update, Delete and more. | ||
| - Support for simple joins | ||
|
|
||
| # Example | ||
|
|
||
| ### Simple connect and Get | ||
|
|
||
| ```go | ||
| package main | ||
|
|
||
| import ( | ||
| "go.ciq.dev/pika" | ||
| "log" | ||
| "go.ciq.dev/pika" | ||
| "log" | ||
| ) | ||
|
|
||
| type User struct { | ||
| PikaTableName string `pika:"users"` | ||
| ID int64 `db:"id" pika:"omitempty"` | ||
| Name string `db:"name"` | ||
| PikaTableName string `pika:"users"` | ||
| ID int64 `db:"id" pika:"omitempty"` | ||
| Name string `db:"name"` | ||
| } | ||
|
|
||
| func main() { | ||
| psql, _ := pika.NewPostgreSQL("postgres://postgres:postgres@localhost:5432/test") | ||
| args := pika.NewArgs() | ||
| args.Set("id", 1) | ||
| qs := pika.Q[User](psql).Filter("id=:id").Args(args) | ||
| user, _ := qs.Get() | ||
| log.Println(user) | ||
| psql, _ := pika.NewPostgreSQL("postgres://postgres:postgres@localhost:5432/test") | ||
| args := pika.NewArgs() | ||
| args.Set("id", 1) | ||
| qs := pika.Q[User](psql).Filter("id=:id").Args(args) | ||
| user, _ := qs.Get() | ||
| log.Println(user) | ||
| } | ||
| ``` | ||
|
|
||
| ### AIP-160 | ||
|
|
||
| ```go | ||
| package main | ||
|
|
||
| import ( | ||
| "go.ciq.dev/pika" | ||
| "log" | ||
| "go.ciq.dev/pika" | ||
| "log" | ||
| ) | ||
|
|
||
| type Article struct { | ||
| PikaTableName string `pika:"users"` | ||
| ID int64 `db:"id" pika:"omitempty"` | ||
| CreatedAt time.Time `db:"created_at" pika:"omitempty"` | ||
| Title string `db:"title"` | ||
| Body string `db:"body"` | ||
| PikaTableName string `pika:"users"` | ||
| ID int64 `db:"id" pika:"omitempty"` | ||
| CreatedAt time.Time `db:"created_at" pika:"omitempty"` | ||
| Title string `db:"title"` | ||
| Body string `db:"body"` | ||
| } | ||
|
|
||
| func main() { | ||
| psql, _ := pika.NewPostgreSQL("postgres://postgres:postgres@localhost:5432/test") | ||
|
|
||
| qs := pika.Q[Article](s.db) | ||
| // Get the following articles | ||
| // * The title MUST contain Hello and the body MUST contain World | ||
| // * If the above is not match, the article MUST be created before 2023-07-30 | ||
| qs, err := qs.AIP160(`(title:"Hello" AND body:"World") OR (created_at < 2023-07-30T00:00:00Z)`, pika.AIPFilterOptions{}) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| rows, err := qs.All() | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| log.Println(rows) | ||
| psql, _ := pika.NewPostgreSQL("postgres://postgres:postgres@localhost:5432/test") | ||
|
|
||
| qs := pika.Q[Article](s.db) | ||
| // Get the following articles | ||
jsco2t marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // * The title MUST contain Hello and the body MUST contain World | ||
| // * If the above is not match, the article MUST be created before 2023-07-30 | ||
| qs, err := qs.AIP160(`(title:"Hello" AND body:"World") OR (created_at < 2023-07-30T00:00:00Z)`, pika.AIPFilterOptions{}) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| rows, err := qs.All() | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
jsco2t marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| log.Println(rows) | ||
| } | ||
| ``` | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.