Skip to content

Commit

Permalink
Merge pull request #43 from diesel-rs/prepare/2.2.x
Browse files Browse the repository at this point in the history
Make the crate compatible with diesel 2.2
  • Loading branch information
weiznich committed May 31, 2024
2 parents a1484bf + 82acb64 commit b09d82a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 29 deletions.
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[package]
name = "diesel_full_text_search"
version = "2.1.1"
version = "2.2.0"
description = "Adds support for PostgreSQL full text search to Diesel"
license = "MIT"
repository = "https://github.com/diesel-rs/diesel_full_text_search"
edition = "2021"

[dependencies]
diesel = { version = "~2.1.0", features = ["postgres_backend"], default-features = false }
diesel = { version = "~2.2.0", features = ["postgres_backend"], default-features = false }

[features]
default = ["with-diesel-postgres"]
Expand Down
52 changes: 25 additions & 27 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#[macro_use]
extern crate diesel;

mod types {
use diesel::sql_types::*;

Expand Down Expand Up @@ -110,63 +107,64 @@ pub mod configuration {

#[allow(deprecated)]
mod functions {
use crate::types::*;
use diesel::define_sql_function;
use diesel::sql_types::*;
use types::*;

sql_function!(fn length(x: TsVector) -> Integer);
sql_function!(fn numnode(x: TsQuery) -> Integer);
sql_function!(fn plainto_tsquery(x: Text) -> TsQuery);
sql_function! {
define_sql_function!(fn length(x: TsVector) -> Integer);
define_sql_function!(fn numnode(x: TsQuery) -> Integer);
define_sql_function!(fn plainto_tsquery(x: Text) -> TsQuery);
define_sql_function! {
#[sql_name = "plainto_tsquery"]
fn plainto_tsquery_with_search_config(config: RegConfig, querytext: Text) -> TsQuery;
}
sql_function!(fn querytree(x: TsQuery) -> Text);
sql_function!(fn strip(x: TsVector) -> TsVector);
sql_function!(fn to_tsquery(x: Text) -> TsQuery);
sql_function! {
define_sql_function!(fn querytree(x: TsQuery) -> Text);
define_sql_function!(fn strip(x: TsVector) -> TsVector);
define_sql_function!(fn to_tsquery(x: Text) -> TsQuery);
define_sql_function! {
#[sql_name = "to_tsquery"]
fn to_tsquery_with_search_config(config: RegConfig, querytext: Text) -> TsQuery;
}
sql_function!(fn to_tsvector<T: TextOrNullableText + SingleValue>(x: T) -> TsVector);
sql_function! {
define_sql_function!(fn to_tsvector<T: TextOrNullableText + SingleValue>(x: T) -> TsVector);
define_sql_function! {
#[sql_name = "to_tsvector"]
fn to_tsvector_with_search_config<T: TextOrNullableText + SingleValue>(config: RegConfig, document_content: T) -> TsVector;
}
sql_function!(fn ts_headline(x: Text, y: TsQuery) -> Text);
sql_function! {
define_sql_function!(fn ts_headline(x: Text, y: TsQuery) -> Text);
define_sql_function! {
#[sql_name = "ts_headline"]
fn ts_headline_with_search_config(config: RegConfig, x: Text, y: TsQuery) -> Text;
}
sql_function!(fn ts_rank(x: TsVector, y: TsQuery) -> Float);
sql_function!(fn ts_rank_cd(x: TsVector, y: TsQuery) -> Float);
sql_function! {
define_sql_function!(fn ts_rank(x: TsVector, y: TsQuery) -> Float);
define_sql_function!(fn ts_rank_cd(x: TsVector, y: TsQuery) -> Float);
define_sql_function! {
#[sql_name = "ts_rank_cd"]
fn ts_rank_cd_weighted(w: Array<Float>, x: TsVector, y: TsQuery) -> Float;
}
sql_function! {
define_sql_function! {
#[sql_name = "ts_rank_cd"]
fn ts_rank_cd_normalized(x: TsVector, y: TsQuery, n: Integer) -> Float;
}
sql_function! {
define_sql_function! {
#[sql_name = "ts_rank_cd"]
fn ts_rank_cd_weighted_normalized(w: Array<Float>, x: TsVector, y: TsQuery, n: Integer) -> Float;
}
sql_function!(fn phraseto_tsquery(x: Text) -> TsQuery);
sql_function!(fn websearch_to_tsquery(x: Text) -> TsQuery);
sql_function! {
define_sql_function!(fn phraseto_tsquery(x: Text) -> TsQuery);
define_sql_function!(fn websearch_to_tsquery(x: Text) -> TsQuery);
define_sql_function! {
#[sql_name = "websearch_to_tsquery"]
fn websearch_to_tsquery_with_search_config(config: RegConfig, x: Text) -> TsQuery;
}
sql_function!(fn setweight(x: TsVector, w: CChar) -> TsVector);
define_sql_function!(fn setweight(x: TsVector, w: CChar) -> TsVector);
}

mod dsl {
use crate::types::*;
use diesel::expression::{AsExpression, Expression};
use types::*;

mod predicates {
use crate::types::*;
use diesel::pg::Pg;
use types::*;

diesel::infix_operator!(Matches, " @@ ", backend: Pg);
diesel::infix_operator!(Concat, " || ", TsVector, backend: Pg);
Expand Down

0 comments on commit b09d82a

Please sign in to comment.