@@ -146,12 +146,12 @@ impl Default for General {
146
146
#[ derive( Serialize , Deserialize , Debug , Clone , PartialEq ) ]
147
147
pub struct Pool {
148
148
pub pool_mode : String ,
149
- pub shards : HashMap < String , Shard > ,
150
- pub users : HashMap < String , User > ,
151
149
pub default_role : String ,
152
150
pub query_parser_enabled : bool ,
153
151
pub primary_reads_enabled : bool ,
154
152
pub sharding_function : String ,
153
+ pub shards : HashMap < String , Shard > ,
154
+ pub users : HashMap < String , User > ,
155
155
}
156
156
impl Default for Pool {
157
157
fn default ( ) -> Pool {
@@ -190,6 +190,17 @@ fn default_path() -> String {
190
190
/// Configuration wrapper.
191
191
#[ derive( Serialize , Deserialize , Debug , Clone , PartialEq ) ]
192
192
pub struct Config {
193
+ // Serializer maintains the order of fields in the struct
194
+ // so we should always put simple fields before nested fields
195
+ // in all serializable structs to avoid ValueAfterTable errors
196
+ // These errors occur when the toml serializer is about to produce
197
+ // ambigous toml structure like the one below
198
+ // [main]
199
+ // field1_under_main = 1
200
+ // field2_under_main = 2
201
+ // [main.subconf]
202
+ // field1_under_subconf = 1
203
+ // field3_under_main = 3 # This field will be interpreted as being under subconf and not under main
193
204
#[ serde( default = "default_path" ) ]
194
205
pub path : String ,
195
206
0 commit comments