Skip to content

Commit

Permalink
Merge pull request #15 from mrcosta/ts_vector_and_ts_query_accepts_la…
Browse files Browse the repository at this point in the history
…nguage

Ts vector and ts query accepts language
  • Loading branch information
weiznich committed Jun 2, 2020
2 parents 5507e8d + f84220e commit 2e4dc75
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 28 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "diesel_full_text_search"
version = "1.0.1"
version = "1.1.0"
authors = ["Sean Griffin <sean@seantheprogrammer.com>"]
description = "Adds support for PostgreSQL full text search to Diesel"
license = "MIT"
repository = "https://github.com/diesel-rs/diesel_full_text_search"

[dependencies]
diesel = { version = "1.0", features = ["postgres"] }
diesel = { version = "1.3.0", features = ["postgres"] }
46 changes: 20 additions & 26 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,34 +1,20 @@
#[macro_use]
extern crate diesel;
#[macro_use] extern crate diesel;

mod types {
#[allow(deprecated)]
use diesel::sql_types::{HasSqlType, NotNull};
use diesel::pg::{Pg, PgTypeMetadata, PgMetadataLookup};

#[derive(Clone, Copy)] pub struct TsQuery;
#[derive(Clone, Copy)] pub struct TsVector;

impl HasSqlType<TsQuery> for Pg {
fn metadata(_: &PgMetadataLookup) -> PgTypeMetadata {
PgTypeMetadata {
oid: 3615,
array_oid: 3645,
}
}
}
use diesel::SqlType;

impl HasSqlType<TsVector> for Pg {
fn metadata(_: &PgMetadataLookup) -> PgTypeMetadata {
PgTypeMetadata {
oid: 3614,
array_oid: 3643,
}
}
}
#[derive(Clone, Copy, SqlType)]
#[postgres(oid = "3615", array_oid = "3645")]
pub struct TsQuery;

impl NotNull for TsVector {}
impl NotNull for TsQuery {}
#[derive(Clone, Copy, SqlType)]
#[postgres(oid = "3614", array_oid = "3643")]
pub struct TsVector;

#[derive(SqlType)]
#[postgres(type_name = "regconfig")]
pub struct Regconfig;
}

#[allow(deprecated)]
Expand All @@ -42,7 +28,15 @@ mod functions {
sql_function!(fn querytree(x: TsQuery) -> Text);
sql_function!(fn strip(x: TsVector) -> TsVector);
sql_function!(fn to_tsquery(x: Text) -> TsQuery);
sql_function! {
#[sql_name = "to_tsquery"]
fn to_tsquery_with_search_config(config: Regconfig, querytext: Text) -> TsQuery;
}
sql_function!(fn to_tsvector(x: Text) -> TsVector);
sql_function! {
#[sql_name = "to_tsvector"]
fn to_tsvector_with_search_config(config: Regconfig, document_content: Text) -> TsVector;
}
sql_function!(fn ts_headline(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);
Expand Down

0 comments on commit 2e4dc75

Please sign in to comment.