1
use std::fmt::Debug;
2

            
3
use canyon_connection::{
4
    canyon_database_connector::DatabaseType, get_database_config, DATASOURCES,
5
};
6

            
7
use crate::{
8
    bounds::{FieldIdentifier, FieldValueIdentifier, QueryParameter},
9
    crud::{CrudOperations, Transaction},
10
    mapper::RowMapper,
11
    query_elements::query::Query,
12
    Operator,
13
};
14

            
15
/// Contains the elements that makes part of the formal declaration
16
/// of the behaviour of the Canyon-SQL QueryBuilder
17
pub mod ops {
18
    pub use super::*;
19

            
20
    /// The [`QueryBuilder`] trait is the root of a kind of hierarchy
21
    /// on more specific [`super::QueryBuilder`], that are:
22
    ///
23
    /// * [`super::SelectQueryBuilder`]
24
    /// * [`super::UpdateQueryBuilder`]
25
    /// * [`super::DeleteQueryBuilder`]
26
    ///
27
    /// This trait provides the formal declaration of the behaviour that the
28
    /// implementors must provide in their public interfaces, groping
29
    /// the common elements between every element down in that
30
    /// hierarchy.
31
    ///
32
    /// For example, the [`super::QueryBuilder`] type holds the data
33
    /// necessary for track the SQL sentence while it's being generated
34
    /// thought the fluent builder, and provides the behaviour of
35
    /// the common elements defined in this trait.
36
    ///
37
    /// The more concrete types represents a wrapper over a raw
38
    /// [`super::QueryBuilder`], offering all the elements declared
39
    /// in this trait in its public interface, and which implementation
40
    /// only consists of call the same method on the wrapped
41
    /// [`super::QueryBuilder`].
42
    ///
43
    /// This allows us to declare in their public interface their
44
    /// specific operations, like, for example, join operations
45
    /// on the [`super::SelectQueryBuilder`], and the usage
46
    /// of the `SET` clause on a [`super::UpdateQueryBuilder`],
47
    /// without mixing types or convoluting everything into
48
    /// just one type.
49
    pub trait QueryBuilder<'a, T>
50
    where
51
        T: CrudOperations<T> + Transaction<T> + RowMapper<T>,
52
    {
53
        /// Returns a read-only reference to the underlying SQL sentence,
54
        /// with the same lifetime as self
55
        fn read_sql(&'a self) -> &'a str;
56

            
57
        /// Public interface for append the content of an slice to the end of
58
        /// the underlying SQL sentece.
59
        ///
60
        /// This mutator will allow the user to wire SQL code to the already
61
        /// generated one
62
        ///
63
        /// * `sql` - The [`&str`] to be wired in the SQL
64
        fn push_sql(&mut self, sql: &str);
65

            
66
        /// Generates a `WHERE` SQL clause for constraint the query.
67
        ///
68
        /// * `column` - A [`FieldValueIdentifier`] that will provide the target
69
        /// column name and the value for the filter
70
        /// * `op` - Any element that implements [`Operator`] for create the comparison
71
        /// or equality binary operator
72
        fn r#where<Z: FieldValueIdentifier<'a, T>>(
73
            &mut self,
74
            column: Z,
75
            op: impl Operator,
76
        ) -> &mut Self
77
        where
78
            T: Debug + CrudOperations<T> + Transaction<T> + RowMapper<T>;
79

            
80
        /// Generates an `AND` SQL clause for constraint the query.
81
        ///
82
        /// * `column` - A [`FieldValueIdentifier`] that will provide the target
83
        /// column name and the value for the filter
84
        /// * `op` - Any element that implements [`Operator`] for create the comparison
85
        /// or equality binary operator
86
        fn and<Z: FieldValueIdentifier<'a, T>>(
87
            &mut self,
88
            column: Z,
89
            op: impl Operator,
90
        ) -> &mut Self;
91

            
92
        /// Generates an `AND` SQL clause for constraint the query that will create
93
        /// the filter in conjunction with an `IN` operator that will ac
94
        ///
95
        /// * `column` - A [`FieldIdentifier`] that will provide the target
96
        /// column name for the filter, based on the variant that represents
97
        /// the field name that maps the targeted column name
98
        /// * `values` - An array of [`QueryParameter`] with the values to filter
99
        /// inside the `IN` operator
100
        fn and_values_in<Z, Q>(&mut self, column: Z, values: &'a [Q]) -> &mut Self
101
        where
102
            Z: FieldIdentifier<T>,
103
            Q: QueryParameter<'a>;
104

            
105
        /// Generates an `OR` SQL clause for constraint the query that will create
106
        /// the filter in conjunction with an `IN` operator that will ac
107
        ///
108
        /// * `column` - A [`FieldIdentifier`] that will provide the target
109
        /// column name for the filter, based on the variant that represents
110
        /// the field name that maps the targeted column name
111
        /// * `values` - An array of [`QueryParameter`] with the values to filter
112
        /// inside the `IN` operator
113
        fn or_values_in<Z, Q>(&mut self, r#or: Z, values: &'a [Q]) -> &mut Self
114
        where
115
            Z: FieldIdentifier<T>,
116
            Q: QueryParameter<'a>;
117

            
118
        /// Generates an `OR` SQL clause for constraint the query.
119
        ///
120
        /// * `column` - A [`FieldValueIdentifier`] that will provide the target
121
        /// column name and the value for the filter
122
        /// * `op` - Any element that implements [`Operator`] for create the comparison
123
        /// or equality binary operator
124
        fn or<Z: FieldValueIdentifier<'a, T>>(&mut self, column: Z, op: impl Operator)
125
            -> &mut Self;
126

            
127
        /// Generates a `ORDER BY` SQL clause for constraint the query.
128
        ///
129
        /// * `order_by` - A [`FieldIdentifier`] that will provide the target
130
        /// column name
131
        /// * `desc` - a boolean indicating if the generated `ORDER_BY` must be
132
        /// in ascending or descending order
133
        fn order_by<Z: FieldIdentifier<T>>(&mut self, order_by: Z, desc: bool) -> &mut Self;
134
    }
135
}
136

            
137
/// Type for construct more complex queries than the classical CRUD ones.
138
#[derive(Debug, Clone)]
139
pub struct QueryBuilder<'a, T>
140
where
141
    T: CrudOperations<T> + Transaction<T> + RowMapper<T>,
142
{
143
    query: Query<'a, T>,
144
    datasource_name: &'a str,
145
    datasource_type: DatabaseType,
146
}
147

            
148
unsafe impl<'a, T> Send for QueryBuilder<'a, T> where
149
    T: CrudOperations<T> + Transaction<T> + RowMapper<T>
150
{
151
}
152
unsafe impl<'a, T> Sync for QueryBuilder<'a, T> where
153
    T: CrudOperations<T> + Transaction<T> + RowMapper<T>
154
{
155
}
156

            
157
impl<'a, T> QueryBuilder<'a, T>
158
where
159
    T: CrudOperations<T> + Transaction<T> + RowMapper<T>,
160
{
161
    /// Returns a new instance of the [`QueryBuilder`]
162
30
    pub fn new(query: Query<'a, T>, datasource_name: &'a str) -> Self {
163
30
        Self {
164
            query,
165
            datasource_name,
166
30
            datasource_type: DatabaseType::from(
167
30
                &get_database_config(datasource_name, &DATASOURCES).auth,
168
            ),
169
        }
170
30
    }
171

            
172
    /// Launches the generated query against the database targeted
173
    /// by the selected datasource
174
14
    pub async fn query(
175
14
        &'a mut self,
176
88
    ) -> Result<Vec<T>, Box<(dyn std::error::Error + Sync + Send + 'static)>> {
177
14
        self.query.sql.push(';');
178

            
179
56
        Ok(T::query(
180
14
            self.query.sql.clone(),
181
14
            self.query.params.to_vec(),
182
14
            self.datasource_name,
183
        )
184
74
        .await?
185
        .into_results::<T>())
186
28
    }
187

            
188
30
    pub fn r#where<Z: FieldValueIdentifier<'a, T>>(&mut self, r#where: Z, op: impl Operator) {
189
30
        let (column_name, value) = r#where.value();
190

            
191
60
        let where_ = String::from(" WHERE ")
192
            + column_name
193
60
            + &op.as_str(self.query.params.len() + 1, &self.datasource_type);
194

            
195
30
        self.query.sql.push_str(&where_);
196
30
        self.query.params.push(value);
197
30
    }
198

            
199
12
    pub fn and<Z: FieldValueIdentifier<'a, T>>(&mut self, r#and: Z, op: impl Operator) {
200
12
        let (column_name, value) = r#and.value();
201

            
202
24
        let and_ = String::from(" AND ")
203
            + column_name
204
24
            + &op.as_str(self.query.params.len() + 1, &self.datasource_type);
205

            
206
12
        self.query.sql.push_str(&and_);
207
12
        self.query.params.push(value);
208
12
    }
209

            
210
1
    pub fn or<Z: FieldValueIdentifier<'a, T>>(&mut self, r#and: Z, op: impl Operator) {
211
1
        let (column_name, value) = r#and.value();
212

            
213
2
        let and_ = String::from(" OR ")
214
            + column_name
215
2
            + &op.as_str(self.query.params.len() + 1, &self.datasource_type);
216

            
217
1
        self.query.sql.push_str(&and_);
218
1
        self.query.params.push(value);
219
1
    }
220

            
221
2
    pub fn and_values_in<Z, Q>(&mut self, r#and: Z, values: &'a [Q])
222
    where
223
        Z: FieldIdentifier<T>,
224
        Q: QueryParameter<'a>,
225
    {
226
2
        if values.is_empty() {
227
            return;
228
        }
229

            
230
2
        self.query
231
            .sql
232
4
            .push_str(&format!(" AND {} IN (", r#and.as_str()));
233

            
234
2
        let mut counter = 1;
235
7
        values.iter().for_each(|qp| {
236
5
            if values.len() != counter {
237
6
                self.query
238
                    .sql
239
6
                    .push_str(&format!("${}, ", self.query.params.len()));
240
3
                counter += 1;
241
            } else {
242
4
                self.query
243
                    .sql
244
4
                    .push_str(&format!("${}", self.query.params.len()));
245
            }
246
5
            self.query.params.push(qp)
247
5
        });
248

            
249
2
        self.query.sql.push(')')
250
2
    }
251

            
252
1
    fn or_values_in<Z, Q>(&mut self, r#or: Z, values: &'a [Q])
253
    where
254
        Z: FieldIdentifier<T>,
255
        Q: QueryParameter<'a>,
256
    {
257
1
        if values.is_empty() {
258
            return;
259
        }
260

            
261
1
        self.query
262
            .sql
263
2
            .push_str(&format!(" OR {} IN (", r#or.as_str()));
264

            
265
1
        let mut counter = 1;
266
4
        values.iter().for_each(|qp| {
267
3
            if values.len() != counter {
268
4
                self.query
269
                    .sql
270
4
                    .push_str(&format!("${}, ", self.query.params.len()));
271
2
                counter += 1;
272
            } else {
273
2
                self.query
274
                    .sql
275
2
                    .push_str(&format!("${}", self.query.params.len()));
276
            }
277
3
            self.query.params.push(qp)
278
3
        });
279

            
280
1
        self.query.sql.push(')')
281
1
    }
282

            
283
    #[inline]
284
1
    pub fn order_by<Z: FieldIdentifier<T>>(&mut self, order_by: Z, desc: bool) {
285
1
        self.query.sql.push_str(
286
2
            &(format!(
287
                " ORDER BY {}{}",
288
1
                order_by.as_str(),
289
1
                if desc { " DESC " } else { "" }
290
            )),
291
1
        );
292
1
    }
293
}
294

            
295
#[derive(Debug, Clone)]
296
pub struct SelectQueryBuilder<'a, T>
297
where
298
    T: CrudOperations<T> + Transaction<T> + RowMapper<T>,
299
{
300
    _inner: QueryBuilder<'a, T>,
301
}
302

            
303
impl<'a, T> SelectQueryBuilder<'a, T>
304
where
305
    T: CrudOperations<T> + Transaction<T> + RowMapper<T>,
306
{
307
    /// Generates a new public instance of the [`SelectQueryBuilder`]
308
24
    pub fn new(table_schema_data: &str, datasource_name: &'a str) -> Self {
309
24
        Self {
310
24
            _inner: QueryBuilder::<T>::new(
311
24
                Query::new(format!("SELECT * FROM {table_schema_data}")),
312
                datasource_name,
313
            ),
314
        }
315
24
    }
316

            
317
    /// Launches the generated query to the database pointed by the
318
    /// selected datasource
319
    #[inline]
320
8
    pub async fn query(
321
8
        &'a mut self,
322
43
    ) -> Result<Vec<T>, Box<(dyn std::error::Error + Sync + Send + 'static)>> {
323
35
        self._inner.query().await
324
16
    }
325

            
326
    /// Adds a *LEFT JOIN* SQL statement to the underlying
327
    /// [`Query`] held by the [`QueryBuilder`], where:
328
    ///
329
    /// * `join_table` - The table target of the join operation
330
    /// * `col1` - The left side of the ON operator for the join
331
    /// * `col2` - The right side of the ON operator for the join
332
    ///
333
    /// > Note: The order on the column parameters is irrelevant
334
1
    pub fn left_join(&mut self, join_table: &str, col1: &str, col2: &str) -> &mut Self {
335
1
        self._inner
336
            .query
337
            .sql
338
2
            .push_str(&format!(" LEFT JOIN {join_table} ON {col1} = {col2}"));
339
        self
340
1
    }
341

            
342
    /// Adds a *RIGHT JOIN* SQL statement to the underlying
343
    /// [`Query`] held by the [`QueryBuilder`], where:
344
    ///
345
    /// * `join_table` - The table target of the join operation
346
    /// * `col1` - The left side of the ON operator for the join
347
    /// * `col2` - The right side of the ON operator for the join
348
    ///
349
    /// > Note: The order on the column parameters is irrelevant
350
1
    pub fn inner_join(&mut self, join_table: &str, col1: &str, col2: &str) -> &mut Self {
351
1
        self._inner
352
            .query
353
            .sql
354
2
            .push_str(&format!(" INNER JOIN {join_table} ON {col1} = {col2}"));
355
        self
356
1
    }
357

            
358
    /// Adds a *RIGHT JOIN* SQL statement to the underlying
359
    /// [`Query`] held by the [`QueryBuilder`], where:
360
    ///
361
    /// * `join_table` - The table target of the join operation
362
    /// * `col1` - The left side of the ON operator for the join
363
    /// * `col2` - The right side of the ON operator for the join
364
    ///
365
    /// > Note: The order on the column parameters is irrelevant
366
    pub fn right_join(&mut self, join_table: &str, col1: &str, col2: &str) -> &mut Self {
367
        self._inner
368
            .query
369
            .sql
370
            .push_str(&format!(" RIGHT JOIN {join_table} ON {col1} = {col2}"));
371
        self
372
    }
373

            
374
    /// Adds a *FULL JOIN* SQL statement to the underlying
375
    /// [`Query`] held by the [`QueryBuilder`], where:
376
    ///
377
    /// * `join_table` - The table target of the join operation
378
    /// * `col1` - The left side of the ON operator for the join
379
    /// * `col2` - The right side of the ON operator for the join
380
    ///
381
    /// > Note: The order on the column parameters is irrelevant
382
    pub fn full_join(&mut self, join_table: &str, col1: &str, col2: &str) -> &mut Self {
383
        self._inner
384
            .query
385
            .sql
386
            .push_str(&format!(" FULL JOIN {join_table} ON {col1} = {col2}"));
387
        self
388
    }
389
}
390

            
391
impl<'a, T> ops::QueryBuilder<'a, T> for SelectQueryBuilder<'a, T>
392
where
393
    T: Debug + CrudOperations<T> + Transaction<T> + RowMapper<T> + Send,
394
{
395
    #[inline]
396
16
    fn read_sql(&'a self) -> &'a str {
397
16
        self._inner.query.sql.as_str()
398
16
    }
399

            
400
    #[inline(always)]
401
    fn push_sql(&mut self, sql: &str) {
402
        self._inner.query.sql.push_str(sql);
403
    }
404

            
405
    #[inline]
406
24
    fn r#where<Z: FieldValueIdentifier<'a, T>>(
407
        &mut self,
408
        r#where: Z,
409
        op: impl Operator,
410
    ) -> &mut Self {
411
24
        self._inner.r#where(r#where, op);
412
        self
413
24
    }
414

            
415
    #[inline]
416
6
    fn and<Z: FieldValueIdentifier<'a, T>>(&mut self, column: Z, op: impl Operator) -> &mut Self {
417
6
        self._inner.and(column, op);
418
        self
419
6
    }
420

            
421
    #[inline]
422
2
    fn and_values_in<Z, Q>(&mut self, r#and: Z, values: &'a [Q]) -> &mut Self
423
    where
424
        Z: FieldIdentifier<T>,
425
        Q: QueryParameter<'a>,
426
    {
427
2
        self._inner.and_values_in(and, values);
428
        self
429
2
    }
430

            
431
    #[inline]
432
1
    fn or_values_in<Z, Q>(&mut self, r#and: Z, values: &'a [Q]) -> &mut Self
433
    where
434
        Z: FieldIdentifier<T>,
435
        Q: QueryParameter<'a>,
436
    {
437
1
        self._inner.or_values_in(and, values);
438
        self
439
1
    }
440

            
441
    #[inline]
442
1
    fn or<Z: FieldValueIdentifier<'a, T>>(&mut self, column: Z, op: impl Operator) -> &mut Self {
443
1
        self._inner.or(column, op);
444
        self
445
1
    }
446

            
447
    #[inline]
448
1
    fn order_by<Z: FieldIdentifier<T>>(&mut self, order_by: Z, desc: bool) -> &mut Self {
449
1
        self._inner.order_by(order_by, desc);
450
        self
451
1
    }
452
}
453

            
454
/// Contains the specific database operations of the *UPDATE* SQL statements.
455
///  
456
/// * `set` - To construct a new `SET` clause to determine the columns to
457
/// update with the provided values
458
#[derive(Debug, Clone)]
459
pub struct UpdateQueryBuilder<'a, T>
460
where
461
    T: CrudOperations<T> + Transaction<T> + RowMapper<T>,
462
{
463
    _inner: QueryBuilder<'a, T>,
464
}
465

            
466
impl<'a, T> UpdateQueryBuilder<'a, T>
467
where
468
    T: CrudOperations<T> + Transaction<T> + RowMapper<T>,
469
{
470
    /// Generates a new public instance of the [`UpdateQueryBuilder`]
471
3
    pub fn new(table_schema_data: &str, datasource_name: &'a str) -> Self {
472
3
        Self {
473
3
            _inner: QueryBuilder::<T>::new(
474
3
                Query::new(format!("UPDATE {table_schema_data}")),
475
                datasource_name,
476
            ),
477
        }
478
3
    }
479

            
480
    /// Launches the generated query to the database pointed by the
481
    /// selected datasource
482
    #[inline]
483
3
    pub async fn query(
484
3
        &'a mut self,
485
16
    ) -> Result<Vec<T>, Box<(dyn std::error::Error + Sync + Send + 'static)>> {
486
13
        self._inner.query().await
487
6
    }
488

            
489
    /// Creates an SQL `SET` clause to especify the columns that must be updated in the sentence
490
3
    pub fn set<Z, Q>(&mut self, columns: &'a [(Z, Q)]) -> &mut Self
491
    where
492
        Z: FieldIdentifier<T> + Clone,
493
        Q: QueryParameter<'a>,
494
    {
495
3
        if columns.is_empty() {
496
            return self;
497
        }
498
3
        if self._inner.query.sql.contains("SET") {
499
            panic!(
500
                "\n{}",
501
                String::from("\t[PANIC!] - Don't use chained calls of the .set(...) method. ")
502
                    + "\n\tPass all the values in a unique call within the 'columns' "
503
                    + "array of tuples parameter\n"
504
            )
505
        }
506

            
507
3
        let mut set_clause = String::new();
508
3
        set_clause.push_str(" SET ");
509

            
510
9
        for (idx, column) in columns.iter().enumerate() {
511
12
            set_clause.push_str(&format!(
512
                "{} = ${}",
513
6
                column.0.as_str(),
514
6
                self._inner.query.params.len() + 1
515
6
            ));
516

            
517
6
            if idx < columns.len() - 1 {
518
3
                set_clause.push_str(", ");
519
            }
520
6
            self._inner.query.params.push(&column.1);
521
        }
522

            
523
3
        self._inner.query.sql.push_str(&set_clause);
524
3
        self
525
3
    }
526
}
527

            
528
impl<'a, T> ops::QueryBuilder<'a, T> for UpdateQueryBuilder<'a, T>
529
where
530
    T: Debug + CrudOperations<T> + Transaction<T> + RowMapper<T> + Send,
531
{
532
    #[inline]
533
    fn read_sql(&'a self) -> &'a str {
534
        self._inner.query.sql.as_str()
535
    }
536

            
537
    #[inline(always)]
538
    fn push_sql(&mut self, sql: &str) {
539
        self._inner.query.sql.push_str(sql);
540
    }
541

            
542
    #[inline]
543
3
    fn r#where<Z: FieldValueIdentifier<'a, T>>(
544
        &mut self,
545
        r#where: Z,
546
        op: impl Operator,
547
    ) -> &mut Self {
548
3
        self._inner.r#where(r#where, op);
549
        self
550
3
    }
551

            
552
    #[inline]
553
3
    fn and<Z: FieldValueIdentifier<'a, T>>(&mut self, column: Z, op: impl Operator) -> &mut Self {
554
3
        self._inner.and(column, op);
555
        self
556
3
    }
557

            
558
    #[inline]
559
    fn and_values_in<Z, Q>(&mut self, r#and: Z, values: &'a [Q]) -> &mut Self
560
    where
561
        Z: FieldIdentifier<T>,
562
        Q: QueryParameter<'a>,
563
    {
564
        self._inner.and_values_in(and, values);
565
        self
566
    }
567

            
568
    #[inline]
569
    fn or_values_in<Z, Q>(&mut self, r#or: Z, values: &'a [Q]) -> &mut Self
570
    where
571
        Z: FieldIdentifier<T>,
572
        Q: QueryParameter<'a>,
573
    {
574
        self._inner.or_values_in(or, values);
575
        self
576
    }
577

            
578
    #[inline]
579
    fn or<Z: FieldValueIdentifier<'a, T>>(&mut self, column: Z, op: impl Operator) -> &mut Self {
580
        self._inner.or(column, op);
581
        self
582
    }
583

            
584
    #[inline]
585
    fn order_by<Z: FieldIdentifier<T>>(&mut self, order_by: Z, desc: bool) -> &mut Self {
586
        self._inner.order_by(order_by, desc);
587
        self
588
    }
589
}
590

            
591
/// Contains the specific database operations associated with the
592
/// *DELETE* SQL statements.
593
///  
594
/// * `set` - To construct a new `SET` clause to determine the columns to
595
/// update with the provided values
596
#[derive(Debug, Clone)]
597
pub struct DeleteQueryBuilder<'a, T>
598
where
599
    T: CrudOperations<T> + Transaction<T> + RowMapper<T>,
600
{
601
    _inner: QueryBuilder<'a, T>,
602
}
603

            
604
impl<'a, T> DeleteQueryBuilder<'a, T>
605
where
606
    T: CrudOperations<T> + Transaction<T> + RowMapper<T>,
607
{
608
    /// Generates a new public instance of the [`DeleteQueryBuilder`]
609
3
    pub fn new(table_schema_data: &str, datasource_name: &'a str) -> Self {
610
3
        Self {
611
3
            _inner: QueryBuilder::<T>::new(
612
3
                Query::new(format!("DELETE FROM {table_schema_data}")),
613
                datasource_name,
614
            ),
615
        }
616
3
    }
617

            
618
    /// Launches the generated query to the database pointed by the
619
    /// selected datasource
620
    #[inline]
621
3
    pub async fn query(
622
3
        &'a mut self,
623
15
    ) -> Result<Vec<T>, Box<(dyn std::error::Error + Sync + Send + 'static)>> {
624
12
        self._inner.query().await
625
6
    }
626
}
627

            
628
impl<'a, T> ops::QueryBuilder<'a, T> for DeleteQueryBuilder<'a, T>
629
where
630
    T: Debug + CrudOperations<T> + Transaction<T> + RowMapper<T> + Send,
631
{
632
    #[inline]
633
    fn read_sql(&'a self) -> &'a str {
634
        self._inner.query.sql.as_str()
635
    }
636

            
637
    #[inline(always)]
638
    fn push_sql(&mut self, sql: &str) {
639
        self._inner.query.sql.push_str(sql);
640
    }
641

            
642
    #[inline]
643
3
    fn r#where<Z: FieldValueIdentifier<'a, T>>(
644
        &mut self,
645
        r#where: Z,
646
        op: impl Operator,
647
    ) -> &mut Self {
648
3
        self._inner.r#where(r#where, op);
649
        self
650
3
    }
651

            
652
    #[inline]
653
3
    fn and<Z: FieldValueIdentifier<'a, T>>(&mut self, column: Z, op: impl Operator) -> &mut Self {
654
3
        self._inner.and(column, op);
655
        self
656
3
    }
657

            
658
    #[inline]
659
    fn and_values_in<Z, Q>(&mut self, r#and: Z, values: &'a [Q]) -> &mut Self
660
    where
661
        Z: FieldIdentifier<T>,
662
        Q: QueryParameter<'a>,
663
    {
664
        self._inner.or_values_in(and, values);
665
        self
666
    }
667

            
668
    #[inline]
669
    fn or_values_in<Z, Q>(&mut self, r#or: Z, values: &'a [Q]) -> &mut Self
670
    where
671
        Z: FieldIdentifier<T>,
672
        Q: QueryParameter<'a>,
673
    {
674
        self._inner.or_values_in(or, values);
675
        self
676
    }
677

            
678
    #[inline]
679
    fn or<Z: FieldValueIdentifier<'a, T>>(&mut self, column: Z, op: impl Operator) -> &mut Self {
680
        self._inner.or(column, op);
681
        self
682
    }
683

            
684
    #[inline]
685
    fn order_by<Z: FieldIdentifier<T>>(&mut self, order_by: Z, desc: bool) -> &mut Self {
686
        self._inner.order_by(order_by, desc);
687
        self
688
    }
689
}