From 1de35747aff7db1e4b56a43b969710e13437b7d4 Mon Sep 17 00:00:00 2001 From: Ross Rogers Date: Sun, 24 Mar 2024 08:31:07 -0700 Subject: [PATCH 1/4] Add simple example usage in README and in example directory --- README.md | 14 ++++++++++++++ examples/simple.rs | 24 ++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 examples/simple.rs diff --git a/README.md b/README.md index 73d313f..e2846ba 100644 --- a/README.md +++ b/README.md @@ -8,3 +8,17 @@ to [diesel](https://diesel.rs/), the safe, extensible ORM and query builder for This crate also serves as an example of how to extend diesel with database specific features outside of diesel itself as third party crate. + + +## Example Usage + +```rust + +use diesel_full_text_search::*; + +let search = "bar"; + +let query = Foo::table.filter(to_tsvector(Foo::description).matches(to_tsquery(search))); +``` + +For complete examples, see [/examples](./examples). \ No newline at end of file diff --git a/examples/simple.rs b/examples/simple.rs new file mode 100644 index 0000000..0a3bb74 --- /dev/null +++ b/examples/simple.rs @@ -0,0 +1,24 @@ +extern crate diesel; +use diesel::*; + +extern crate diesel_full_text_search; +use diesel_full_text_search::*; + +type DB = diesel::pg::Pg; + +diesel::table! { + foo (id) { + id -> Int4, + description -> Text, + } +} + +fn main() { + let search = "bar"; + + let query = foo::table.filter(to_tsvector(foo::description).matches(to_tsquery(search))); + + let sql = debug_query::(&query).to_string(); + + println!("The sql code for `query` is:\n {sql}\n"); +} From 08ab536c3ea1f431405d0498373b4d097cffa4bd Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Mon, 25 Mar 2024 19:41:24 +0100 Subject: [PATCH 2/4] Add example to the CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 394ebaf..6c4cfc0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,4 +42,4 @@ jobs: - uses: taiki-e/install-action@cargo-hack - name: Build crate - run: cargo hack --feature-powerset build + run: cargo hack --feature-powerset build --all-targets From 2ea5804ebd09c0fe41724aacc9b6a33234ce97c4 Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Mon, 25 Mar 2024 19:42:45 +0100 Subject: [PATCH 3/4] Use lower case table name in readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e2846ba..d38bdf7 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ use diesel_full_text_search::*; let search = "bar"; -let query = Foo::table.filter(to_tsvector(Foo::description).matches(to_tsquery(search))); +let query = foo::table.filter(to_tsvector(Foo::description).matches(to_tsquery(search))); ``` -For complete examples, see [/examples](./examples). \ No newline at end of file +For complete examples, see [/examples](./examples). From ce20a52fa15de992beb195dc900dbb011982328f Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Mon, 25 Mar 2024 19:48:10 +0100 Subject: [PATCH 4/4] Use check builds in ci, to skip linking libpq --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6c4cfc0..71c75ca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,4 +42,4 @@ jobs: - uses: taiki-e/install-action@cargo-hack - name: Build crate - run: cargo hack --feature-powerset build --all-targets + run: cargo hack --feature-powerset check --all-targets