@@ -43,7 +43,7 @@ impl Display for ApplicationNodeType {
43
43
44
44
/// Entity related to the `app_version` database table.
45
45
#[ derive( Debug , PartialEq , Eq , Clone ) ]
46
- pub struct ApplicationVersion {
46
+ pub struct DatabaseVersion {
47
47
/// Semver of the database structure.
48
48
pub semver : Version ,
49
49
@@ -55,7 +55,7 @@ pub struct ApplicationVersion {
55
55
pub updated_at : NaiveDateTime ,
56
56
}
57
57
58
- impl SqLiteEntity for ApplicationVersion {
58
+ impl SqLiteEntity for DatabaseVersion {
59
59
fn hydrate ( row : Row ) -> Result < Self , HydrationError > {
60
60
Ok ( Self {
61
61
semver : Version :: parse ( & row. get :: < String , _ > ( 0 ) )
@@ -71,7 +71,7 @@ impl SqLiteEntity for ApplicationVersion {
71
71
}
72
72
}
73
73
74
- impl PartialOrd for ApplicationVersion {
74
+ impl PartialOrd for DatabaseVersion {
75
75
fn partial_cmp ( & self , other : & Self ) -> Option < Ordering > {
76
76
if self . application_type != other. application_type {
77
77
None
@@ -81,12 +81,12 @@ impl PartialOrd for ApplicationVersion {
81
81
}
82
82
}
83
83
84
- /// Projection dedicated to [ApplicationVersion ] entities.
85
- struct ApplicationVersionProjection {
84
+ /// Projection dedicated to [DatabaseVersion ] entities.
85
+ struct DatabaseVersionProjection {
86
86
fields : Vec < ProjectionField > ,
87
87
}
88
88
89
- impl Projection for ApplicationVersionProjection {
89
+ impl Projection for DatabaseVersionProjection {
90
90
fn set_field ( & mut self , field : ProjectionField ) {
91
91
self . fields . push ( field) ;
92
92
}
@@ -95,7 +95,7 @@ impl Projection for ApplicationVersionProjection {
95
95
& self . fields
96
96
}
97
97
}
98
- impl ApplicationVersionProjection {
98
+ impl DatabaseVersionProjection {
99
99
pub fn new ( ) -> Self {
100
100
let mut projection = Self { fields : Vec :: new ( ) } ;
101
101
projection. add_field ( "semver" , "{:app_version:}.semver" , "text" ) ;
@@ -110,18 +110,18 @@ impl ApplicationVersionProjection {
110
110
}
111
111
}
112
112
113
- /// Provider for the [ApplicationVersion ] entities using the `ApplicationVersionProjection `.
114
- pub struct VersionProvider < ' conn > {
113
+ /// Provider for the [DatabaseVersion ] entities using the `DatabaseVersionProjection `.
114
+ pub struct DatabaseVersionProvider < ' conn > {
115
115
connection : & ' conn Connection ,
116
- projection : ApplicationVersionProjection ,
116
+ projection : DatabaseVersionProjection ,
117
117
}
118
118
119
- impl < ' conn > VersionProvider < ' conn > {
120
- /// [VersionProvider ] constructor.
119
+ impl < ' conn > DatabaseVersionProvider < ' conn > {
120
+ /// [DatabaseVersionProvider ] constructor.
121
121
pub fn new ( connection : & ' conn Connection ) -> Self {
122
122
Self {
123
123
connection,
124
- projection : ApplicationVersionProjection :: new ( ) ,
124
+ projection : DatabaseVersionProjection :: new ( ) ,
125
125
}
126
126
}
127
127
@@ -153,7 +153,7 @@ create table app_version (application_type text not null primary key, semver tex
153
153
pub fn get_application_version (
154
154
& self ,
155
155
application_type : & ApplicationNodeType ,
156
- ) -> Result < Option < ApplicationVersion > , Box < dyn Error > > {
156
+ ) -> Result < Option < DatabaseVersion > , Box < dyn Error > > {
157
157
let condition = "application_type = ?" ;
158
158
let params = [ Value :: String ( format ! ( "{}" , application_type) ) ] ;
159
159
let result = self . find ( Some ( condition) , & params) ?. next ( ) ;
@@ -162,8 +162,8 @@ create table app_version (application_type text not null primary key, semver tex
162
162
}
163
163
}
164
164
165
- impl < ' conn > Provider < ' conn > for VersionProvider < ' conn > {
166
- type Entity = ApplicationVersion ;
165
+ impl < ' conn > Provider < ' conn > for DatabaseVersionProvider < ' conn > {
166
+ type Entity = DatabaseVersion ;
167
167
168
168
fn get_projection ( & self ) -> & dyn Projection {
169
169
& self . projection
@@ -189,24 +189,24 @@ where {where_clause}
189
189
}
190
190
}
191
191
192
- /// Write [Provider] for the [ApplicationVersion ] entities.
192
+ /// Write [Provider] for the [DatabaseVersion ] entities.
193
193
/// This will perform an UPSERT and return the updated entity.
194
- pub struct VersionUpdaterProvider < ' conn > {
194
+ pub struct DatabaseVersionUpdater < ' conn > {
195
195
connection : & ' conn Connection ,
196
- projection : ApplicationVersionProjection ,
196
+ projection : DatabaseVersionProjection ,
197
197
}
198
198
199
- impl < ' conn > VersionUpdaterProvider < ' conn > {
200
- /// [VersionUpdaterProvider ] constructor.
199
+ impl < ' conn > DatabaseVersionUpdater < ' conn > {
200
+ /// [DatabaseVersionUpdater ] constructor.
201
201
pub fn new ( connection : & ' conn Connection ) -> Self {
202
202
Self {
203
203
connection,
204
- projection : ApplicationVersionProjection :: new ( ) ,
204
+ projection : DatabaseVersionProjection :: new ( ) ,
205
205
}
206
206
}
207
207
208
208
/// Persist the given entity and return the projection of the saved entity.
209
- pub fn save ( & self , version : ApplicationVersion ) -> Result < ApplicationVersion , Box < dyn Error > > {
209
+ pub fn save ( & self , version : DatabaseVersion ) -> Result < DatabaseVersion , Box < dyn Error > > {
210
210
let params = [
211
211
Value :: String ( format ! ( "{}" , version. application_type) ) ,
212
212
Value :: String ( version. semver . to_string ( ) ) ,
@@ -220,8 +220,8 @@ impl<'conn> VersionUpdaterProvider<'conn> {
220
220
}
221
221
}
222
222
223
- impl < ' conn > Provider < ' conn > for VersionUpdaterProvider < ' conn > {
224
- type Entity = ApplicationVersion ;
223
+ impl < ' conn > Provider < ' conn > for DatabaseVersionUpdater < ' conn > {
224
+ type Entity = DatabaseVersion ;
225
225
226
226
fn get_projection ( & self ) -> & dyn Projection {
227
227
& self . projection
@@ -253,7 +253,7 @@ mod tests {
253
253
254
254
#[ test]
255
255
fn test_projection ( ) {
256
- let projection = ApplicationVersionProjection :: new ( ) ;
256
+ let projection = DatabaseVersionProjection :: new ( ) ;
257
257
let mut aliases: HashMap < String , String > = HashMap :: new ( ) ;
258
258
let _ = aliases. insert ( "{:app_version:}" . to_string ( ) , "whatever" . to_string ( ) ) ;
259
259
@@ -267,7 +267,7 @@ mod tests {
267
267
#[ test]
268
268
fn test_definition ( ) {
269
269
let connection = Connection :: open ( ":memory:" ) . unwrap ( ) ;
270
- let provider = VersionProvider :: new ( & connection) ;
270
+ let provider = DatabaseVersionProvider :: new ( & connection) ;
271
271
272
272
assert_eq ! (
273
273
r#"
@@ -282,7 +282,7 @@ where true
282
282
#[ test]
283
283
fn test_updated_entity ( ) {
284
284
let connection = Connection :: open ( ":memory:" ) . unwrap ( ) ;
285
- let provider = VersionUpdaterProvider :: new ( & connection) ;
285
+ let provider = DatabaseVersionUpdater :: new ( & connection) ;
286
286
287
287
assert_eq ! (
288
288
r#"
0 commit comments