|
1 |
| -#[macro_use] |
2 |
| -extern crate diesel; |
3 |
| - |
4 | 1 | mod types {
|
5 | 2 | use diesel::sql_types::*;
|
6 | 3 |
|
@@ -110,63 +107,64 @@ pub mod configuration {
|
110 | 107 |
|
111 | 108 | #[allow(deprecated)]
|
112 | 109 | mod functions {
|
| 110 | + use crate::types::*; |
| 111 | + use diesel::define_sql_function; |
113 | 112 | use diesel::sql_types::*;
|
114 |
| - use types::*; |
115 | 113 |
|
116 |
| - sql_function!(fn length(x: TsVector) -> Integer); |
117 |
| - sql_function!(fn numnode(x: TsQuery) -> Integer); |
118 |
| - sql_function!(fn plainto_tsquery(x: Text) -> TsQuery); |
119 |
| - sql_function! { |
| 114 | + define_sql_function!(fn length(x: TsVector) -> Integer); |
| 115 | + define_sql_function!(fn numnode(x: TsQuery) -> Integer); |
| 116 | + define_sql_function!(fn plainto_tsquery(x: Text) -> TsQuery); |
| 117 | + define_sql_function! { |
120 | 118 | #[sql_name = "plainto_tsquery"]
|
121 | 119 | fn plainto_tsquery_with_search_config(config: RegConfig, querytext: Text) -> TsQuery;
|
122 | 120 | }
|
123 |
| - sql_function!(fn querytree(x: TsQuery) -> Text); |
124 |
| - sql_function!(fn strip(x: TsVector) -> TsVector); |
125 |
| - sql_function!(fn to_tsquery(x: Text) -> TsQuery); |
126 |
| - sql_function! { |
| 121 | + define_sql_function!(fn querytree(x: TsQuery) -> Text); |
| 122 | + define_sql_function!(fn strip(x: TsVector) -> TsVector); |
| 123 | + define_sql_function!(fn to_tsquery(x: Text) -> TsQuery); |
| 124 | + define_sql_function! { |
127 | 125 | #[sql_name = "to_tsquery"]
|
128 | 126 | fn to_tsquery_with_search_config(config: RegConfig, querytext: Text) -> TsQuery;
|
129 | 127 | }
|
130 |
| - sql_function!(fn to_tsvector<T: TextOrNullableText + SingleValue>(x: T) -> TsVector); |
131 |
| - sql_function! { |
| 128 | + define_sql_function!(fn to_tsvector<T: TextOrNullableText + SingleValue>(x: T) -> TsVector); |
| 129 | + define_sql_function! { |
132 | 130 | #[sql_name = "to_tsvector"]
|
133 | 131 | fn to_tsvector_with_search_config<T: TextOrNullableText + SingleValue>(config: RegConfig, document_content: T) -> TsVector;
|
134 | 132 | }
|
135 |
| - sql_function!(fn ts_headline(x: Text, y: TsQuery) -> Text); |
136 |
| - sql_function! { |
| 133 | + define_sql_function!(fn ts_headline(x: Text, y: TsQuery) -> Text); |
| 134 | + define_sql_function! { |
137 | 135 | #[sql_name = "ts_headline"]
|
138 | 136 | fn ts_headline_with_search_config(config: RegConfig, x: Text, y: TsQuery) -> Text;
|
139 | 137 | }
|
140 |
| - sql_function!(fn ts_rank(x: TsVector, y: TsQuery) -> Float); |
141 |
| - sql_function!(fn ts_rank_cd(x: TsVector, y: TsQuery) -> Float); |
142 |
| - sql_function! { |
| 138 | + define_sql_function!(fn ts_rank(x: TsVector, y: TsQuery) -> Float); |
| 139 | + define_sql_function!(fn ts_rank_cd(x: TsVector, y: TsQuery) -> Float); |
| 140 | + define_sql_function! { |
143 | 141 | #[sql_name = "ts_rank_cd"]
|
144 | 142 | fn ts_rank_cd_weighted(w: Array<Float>, x: TsVector, y: TsQuery) -> Float;
|
145 | 143 | }
|
146 |
| - sql_function! { |
| 144 | + define_sql_function! { |
147 | 145 | #[sql_name = "ts_rank_cd"]
|
148 | 146 | fn ts_rank_cd_normalized(x: TsVector, y: TsQuery, n: Integer) -> Float;
|
149 | 147 | }
|
150 |
| - sql_function! { |
| 148 | + define_sql_function! { |
151 | 149 | #[sql_name = "ts_rank_cd"]
|
152 | 150 | fn ts_rank_cd_weighted_normalized(w: Array<Float>, x: TsVector, y: TsQuery, n: Integer) -> Float;
|
153 | 151 | }
|
154 |
| - sql_function!(fn phraseto_tsquery(x: Text) -> TsQuery); |
155 |
| - sql_function!(fn websearch_to_tsquery(x: Text) -> TsQuery); |
156 |
| - sql_function! { |
| 152 | + define_sql_function!(fn phraseto_tsquery(x: Text) -> TsQuery); |
| 153 | + define_sql_function!(fn websearch_to_tsquery(x: Text) -> TsQuery); |
| 154 | + define_sql_function! { |
157 | 155 | #[sql_name = "websearch_to_tsquery"]
|
158 | 156 | fn websearch_to_tsquery_with_search_config(config: RegConfig, x: Text) -> TsQuery;
|
159 | 157 | }
|
160 |
| - sql_function!(fn setweight(x: TsVector, w: CChar) -> TsVector); |
| 158 | + define_sql_function!(fn setweight(x: TsVector, w: CChar) -> TsVector); |
161 | 159 | }
|
162 | 160 |
|
163 | 161 | mod dsl {
|
| 162 | + use crate::types::*; |
164 | 163 | use diesel::expression::{AsExpression, Expression};
|
165 |
| - use types::*; |
166 | 164 |
|
167 | 165 | mod predicates {
|
| 166 | + use crate::types::*; |
168 | 167 | use diesel::pg::Pg;
|
169 |
| - use types::*; |
170 | 168 |
|
171 | 169 | diesel::infix_operator!(Matches, " @@ ", backend: Pg);
|
172 | 170 | diesel::infix_operator!(Concat, " || ", TsVector, backend: Pg);
|
|
0 commit comments