@@ -7,7 +7,13 @@ pub trait Concat {
7
7
fn concat ( & self , fmts : & fmt:: Formatter ) -> String ;
8
8
}
9
9
10
- pub trait ConcatSqlStandard < Clause : PartialEq > {
10
+ /// Represents all commands that can be used in a transaction
11
+ pub trait TransactionQuery : Concat { }
12
+
13
+ /// Represents all commands that can be used inside the with method
14
+ pub trait WithQuery : Concat { }
15
+
16
+ pub ( crate ) trait ConcatSqlStandard < Clause : PartialEq > {
11
17
fn concat_from (
12
18
& self ,
13
19
items_raw_before : & Vec < ( Clause , String ) > ,
@@ -22,7 +28,7 @@ pub trait ConcatSqlStandard<Clause: PartialEq> {
22
28
let tables = items. join ( comma) ;
23
29
format ! ( "FROM{space}{tables}{space}{lb}" )
24
30
} else {
25
- "" . to_owned ( )
31
+ "" . to_string ( )
26
32
} ;
27
33
28
34
concat_raw_before_after ( items_raw_before, items_raw_after, query, fmts, clause, sql)
@@ -53,7 +59,7 @@ pub trait ConcatSqlStandard<Clause: PartialEq> {
53
59
let values = items. join ( & sep) ;
54
60
format ! ( "VALUES{space}{lb}{values}{space}{lb}" )
55
61
} else {
56
- "" . to_owned ( )
62
+ "" . to_string ( )
57
63
} ;
58
64
59
65
concat_raw_before_after ( items_raw_before, items_raw_after, query, fmts, clause, sql)
@@ -79,15 +85,15 @@ pub trait ConcatSqlStandard<Clause: PartialEq> {
79
85
80
86
format ! ( "WHERE{space}{conditions}{space}{lb}" )
81
87
} else {
82
- "" . to_owned ( )
88
+ "" . to_string ( )
83
89
} ;
84
90
85
91
concat_raw_before_after ( items_raw_before, items_raw_after, query, fmts, clause, sql)
86
92
}
87
93
}
88
94
89
95
#[ cfg( any( feature = "postgresql" , feature = "sqlite" ) ) ]
90
- pub trait ConcatCommon < Clause : PartialEq > {
96
+ pub ( crate ) trait ConcatCommon < Clause : PartialEq > {
91
97
fn concat_returning (
92
98
& self ,
93
99
items_raw_before : & Vec < ( Clause , String ) > ,
@@ -102,7 +108,7 @@ pub trait ConcatCommon<Clause: PartialEq> {
102
108
let output_names = items. join ( comma) ;
103
109
format ! ( "RETURNING{space}{output_names}{space}{lb}" )
104
110
} else {
105
- "" . to_owned ( )
111
+ "" . to_string ( )
106
112
} ;
107
113
108
114
concat_raw_before_after ( items_raw_before, items_raw_after, query, fmts, clause, sql)
@@ -125,7 +131,7 @@ pub trait ConcatCommon<Clause: PartialEq> {
125
131
..
126
132
} = fmts;
127
133
let sql = if items. is_empty ( ) == false {
128
- let with = items. iter ( ) . fold ( "" . to_owned ( ) , |acc, item| {
134
+ let with = items. iter ( ) . fold ( "" . to_string ( ) , |acc, item| {
129
135
let ( name, query) = item;
130
136
let inner_lb = format ! ( "{lb}{indent}" ) ;
131
137
let inner_fmts = fmt:: Formatter {
@@ -143,15 +149,15 @@ pub trait ConcatCommon<Clause: PartialEq> {
143
149
144
150
format ! ( "WITH{space}{lb}{with}{space}{lb}" )
145
151
} else {
146
- "" . to_owned ( )
152
+ "" . to_string ( )
147
153
} ;
148
154
149
155
concat_raw_before_after ( items_raw_before, items_raw_after, query, fmts, clause, sql)
150
156
}
151
157
}
152
158
153
159
#[ cfg( feature = "sqlite" ) ]
154
- pub trait ConcatSqlite {
160
+ pub ( crate ) trait ConcatSqlite {
155
161
fn concat_insert (
156
162
& self ,
157
163
items_raw_before : & Vec < ( InsertClause , String ) > ,
@@ -163,13 +169,13 @@ pub trait ConcatSqlite {
163
169
let fmt:: Formatter { lb, space, .. } = fmts;
164
170
165
171
let ( clause, sql) = match insert {
166
- ( InsertVars :: InsertInto , exp) if exp. is_empty ( ) => ( InsertClause :: InsertInto , "" . to_owned ( ) ) ,
172
+ ( InsertVars :: InsertInto , exp) if exp. is_empty ( ) => ( InsertClause :: InsertInto , "" . to_string ( ) ) ,
167
173
( InsertVars :: InsertInto , exp) => ( InsertClause :: InsertInto , format ! ( "INSERT INTO{space}{exp}{space}{lb}" ) ) ,
168
174
169
- ( InsertVars :: InsertOr , exp) if exp. is_empty ( ) => ( InsertClause :: InsertOr , "" . to_owned ( ) ) ,
175
+ ( InsertVars :: InsertOr , exp) if exp. is_empty ( ) => ( InsertClause :: InsertOr , "" . to_string ( ) ) ,
170
176
( InsertVars :: InsertOr , exp) => ( InsertClause :: InsertOr , format ! ( "INSERT OR{space}{exp}{space}{lb}" ) ) ,
171
177
172
- ( InsertVars :: ReplaceInto , exp) if exp. is_empty ( ) => ( InsertClause :: ReplaceInto , "" . to_owned ( ) ) ,
178
+ ( InsertVars :: ReplaceInto , exp) if exp. is_empty ( ) => ( InsertClause :: ReplaceInto , "" . to_string ( ) ) ,
173
179
( InsertVars :: ReplaceInto , exp) => (
174
180
InsertClause :: ReplaceInto ,
175
181
format ! ( "REPLACE INTO{space}{exp}{space}{lb}" ) ,
@@ -193,7 +199,7 @@ pub trait ConcatSqlite {
193
199
let joins = join. join ( format ! ( "{space}{lb}" ) . as_str ( ) ) ;
194
200
format ! ( "{joins}{space}{lb}" )
195
201
} else {
196
- "" . to_owned ( )
202
+ "" . to_string ( )
197
203
} ;
198
204
199
205
concat_raw_before_after ( & items_raw_before, & items_raw_after, query, fmts, clause, sql)
@@ -240,19 +246,13 @@ pub trait ConcatSqlite {
240
246
let values = values. join ( & sep) ;
241
247
( InsertClause :: Values , format ! ( "VALUES{space}{lb}{values}{space}{lb}" ) )
242
248
} else {
243
- ( InsertClause :: Values , "" . to_owned ( ) )
249
+ ( InsertClause :: Values , "" . to_string ( ) )
244
250
} ;
245
251
246
252
concat_raw_before_after ( items_raw_before, items_raw_after, query, fmts, clause, sql)
247
253
}
248
254
}
249
255
250
- /// Represents all commands that can be used in a transaction
251
- pub trait TransactionQuery : Concat { }
252
-
253
- /// Represents all commands that can be used inside the with method
254
- pub trait WithQuery : Concat { }
255
-
256
256
impl std:: fmt:: Display for LogicalOperator {
257
257
fn fmt ( & self , f : & mut std:: fmt:: Formatter ) -> std:: fmt:: Result {
258
258
let v = match self {
@@ -263,7 +263,7 @@ impl std::fmt::Display for LogicalOperator {
263
263
}
264
264
}
265
265
266
- pub fn concat_raw_before_after < Clause : PartialEq > (
266
+ pub ( crate ) fn concat_raw_before_after < Clause : PartialEq > (
267
267
items_before : & Vec < ( Clause , String ) > ,
268
268
items_after : & Vec < ( Clause , String ) > ,
269
269
query : String ,
@@ -280,14 +280,14 @@ pub fn concat_raw_before_after<Clause: PartialEq>(
280
280
format ! ( "{query}{raw_before}{space_before}{sql}{raw_after}{space_after}" )
281
281
}
282
282
283
- pub fn push_unique < T : PartialEq > ( list : & mut Vec < T > , value : T ) {
283
+ pub ( crate ) fn push_unique < T : PartialEq > ( list : & mut Vec < T > , value : T ) {
284
284
let prev_item = list. iter ( ) . find ( |& item| * item == value) ;
285
285
if prev_item. is_none ( ) {
286
286
list. push ( value) ;
287
287
}
288
288
}
289
289
290
- pub fn raw_queries < Clause : PartialEq > ( raw_list : & Vec < ( Clause , String ) > , clause : & Clause ) -> Vec < String > {
290
+ pub ( crate ) fn raw_queries < Clause : PartialEq > ( raw_list : & Vec < ( Clause , String ) > , clause : & Clause ) -> Vec < String > {
291
291
raw_list
292
292
. iter ( )
293
293
. filter ( |item| item. 0 == * clause)
0 commit comments