File tree Expand file tree Collapse file tree 3 files changed +20
-5
lines changed
Expand file tree Collapse file tree 3 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -2,18 +2,20 @@ use std::future::join;
22
33use sqlx:: postgres:: PgPool ;
44
5- use crate :: schemas:: Schemas ;
5+ use crate :: schemas:: Schema ;
6+ use crate :: tables:: Table ;
67
78#[ derive( Debug , Clone , Default ) ]
89pub struct SchemaCache {
9- pub schemas : Schemas ,
10+ pub schemas : Vec < Schema > ,
11+ pub tables : Vec < Table > ,
1012}
1113
1214impl SchemaCache {
1315 pub async fn load ( pool : & PgPool ) -> SchemaCache {
14- let ( schemas) = join ! ( Schemas :: load( pool) ) . await ;
16+ let ( schemas, tables ) = join ! ( Schema :: load ( pool ) , Table :: load( pool) ) . await ;
1517
16- SchemaCache { schemas }
18+ SchemaCache { schemas, tables }
1719 }
1820
1921 /// Applies an AST node to the repository
@@ -26,5 +28,7 @@ impl SchemaCache {
2628}
2729
2830pub trait SchemaCacheItem {
29- async fn load ( pool : & PgPool ) -> Vec < Self > ;
31+ type Item ;
32+
33+ async fn load ( pool : & PgPool ) -> Vec < Self :: Item > ;
3034}
Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ pub struct Schema {
1010}
1111
1212impl SchemaCacheItem for Schema {
13+ type Item = Schema ;
14+
1315 async fn load ( pool : & PgPool ) -> Vec < Schema > {
1416 sqlx:: query_as!(
1517 Schema ,
Original file line number Diff line number Diff line change @@ -2,13 +2,20 @@ use sqlx::PgPool;
22
33use crate :: schema_cache:: SchemaCacheItem ;
44
5+ #[ derive( Debug , Clone , PartialEq ) ]
56pub enum ReplicaIdentity {
67 Default ,
78 Index ,
89 Full ,
910 Nothing ,
1011}
1112
13+ impl Default for ReplicaIdentity {
14+ fn default ( ) -> Self {
15+ ReplicaIdentity :: Default
16+ }
17+ }
18+
1219impl From < String > for ReplicaIdentity {
1320 fn from ( s : String ) -> Self {
1421 match s. as_str ( ) {
@@ -37,6 +44,8 @@ pub struct Table {
3744}
3845
3946impl SchemaCacheItem for Table {
47+ type Item = Table ;
48+
4049 async fn load ( pool : & PgPool ) -> Vec < Table > {
4150 sqlx:: query_as!(
4251 Table ,
You can’t perform that action at this time.
0 commit comments