22//! of the behaviour of the Canyon-SQL QueryBuilder
33
44use std:: error:: Error ;
5- use crate :: query:: bounds:: { FieldIdentifier , FieldValueIdentifier , TableMetadata } ;
5+ use crate :: query:: bounds:: { FieldIdentifier , FieldValueIdentifier } ;
66use crate :: query:: operators:: Comp ;
77use crate :: query:: parameters:: QueryParameter ;
88use crate :: query:: querybuilder:: syntax:: column:: ColumnRef ;
9+ use crate :: query:: querybuilder:: syntax:: table_metadata:: TableMetadata ;
910
1011pub trait DeleteQueryBuilderOps < ' a > : QueryBuilderOps < ' a > { }
1112
@@ -46,9 +47,9 @@ pub trait SelectQueryBuilderOps<'a>: QueryBuilderOps<'a> {
4647 /// > Note: The order on the column parameters is irrelevant
4748 fn left_join (
4849 self ,
49- join_table : impl TableMetadata < ' a > ,
50- col1 : impl FieldIdentifier ,
51- col2 : impl FieldIdentifier ,
50+ join_table : impl Into < TableMetadata < ' a > > ,
51+ col1 : impl Into < ColumnRef < ' a > > ,
52+ col2 : impl Into < ColumnRef < ' a > > ,
5253 ) -> Self ;
5354
5455 /// Adds a *INNER JOIN* SQL statement to the underlying
@@ -61,9 +62,9 @@ pub trait SelectQueryBuilderOps<'a>: QueryBuilderOps<'a> {
6162 /// > Note: The order on the column parameters is irrelevant
6263 fn inner_join (
6364 self ,
64- join_table : impl TableMetadata < ' a > ,
65- col1 : impl FieldIdentifier ,
66- col2 : impl FieldIdentifier ,
65+ join_table : impl Into < TableMetadata < ' a > > ,
66+ col1 : impl Into < ColumnRef < ' a > > ,
67+ col2 : impl Into < ColumnRef < ' a > > ,
6768 ) -> Self ;
6869
6970 /// Adds a *RIGHT JOIN* SQL statement to the underlying
@@ -76,9 +77,9 @@ pub trait SelectQueryBuilderOps<'a>: QueryBuilderOps<'a> {
7677 /// > Note: The order on the column parameters is irrelevant
7778 fn right_join (
7879 self ,
79- join_table : impl TableMetadata < ' a > ,
80- col1 : impl FieldIdentifier ,
81- col2 : impl FieldIdentifier ,
80+ join_table : impl Into < TableMetadata < ' a > > ,
81+ col1 : impl Into < ColumnRef < ' a > > ,
82+ col2 : impl Into < ColumnRef < ' a > > ,
8283 ) -> Self ;
8384
8485 /// Adds a *FULL JOIN* SQL statement to the underlying
@@ -91,10 +92,16 @@ pub trait SelectQueryBuilderOps<'a>: QueryBuilderOps<'a> {
9192 /// > Note: The order on the column parameters is irrelevant
9293 fn full_join (
9394 self ,
94- join_table : impl TableMetadata < ' a > ,
95- col1 : impl FieldIdentifier ,
96- col2 : impl FieldIdentifier ,
95+ join_table : impl Into < TableMetadata < ' a > > ,
96+ col1 : impl Into < ColumnRef < ' a > > ,
97+ col2 : impl Into < ColumnRef < ' a > > ,
9798 ) -> Self ;
99+
100+ /// Generates a `ORDER BY` SQL clause for constraint the query.
101+ ///
102+ /// * `order_by` - A [`FieldIdentifier`] that will provide the target column name
103+ /// * `desc` - a boolean indicating if the generated `ORDER_BY` must be in ascending or descending order
104+ fn order_by < Z : FieldIdentifier + Into < ColumnRef < ' a > > > ( self , order_by : Z , desc : bool ) -> Self ;
98105}
99106
100107/// The [`QueryBuilder`] trait is the root of a kind of hierarchy
@@ -145,8 +152,11 @@ pub trait QueryBuilderOps<'a> {
145152 /// * `column` - An [`&str`] that will provide the target column name
146153 /// * `op` - Any element that implements [`Operator`] for create the comparison
147154 /// or equality binary operator
148- /// * `value` - Any implementor of [`QueryParameter] that will be the value to filter
149- fn r#where ( self , column : & ' a str , op : Comp , value : & ' a dyn QueryParameter ) -> Self ;
155+ ///
156+ /// It will generate a SQL statement with the where constraint value generated as a placeholder,
157+ /// depending on the underlying database driver and the number of elements already added to the
158+ /// querybuilder
159+ fn r#where ( self , column : & ' a str , op : Comp ) -> Self ;
150160
151161 /// Generates a `WHERE` SQL clause for constraint the query.
152162 ///
@@ -198,10 +208,4 @@ pub trait QueryBuilderOps<'a> {
198208 /// * `op` - Any element that implements [`Operator`] for create the comparison
199209 /// or equality binary operator
200210 fn or < Z : FieldValueIdentifier > ( self , column : & ' a Z , op : Comp ) -> Self ;
201-
202- /// Generates a `ORDER BY` SQL clause for constraint the query.
203- ///
204- /// * `order_by` - A [`FieldIdentifier`] that will provide the target column name
205- /// * `desc` - a boolean indicating if the generated `ORDER_BY` must be in ascending or descending order
206- fn order_by < Z : FieldIdentifier > ( self , order_by : Z , desc : bool ) -> Self ;
207211}
0 commit comments