Skip to content

Commit 7c29b74

Browse files
committed
fix: compiler
1 parent 86cd1e8 commit 7c29b74

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

crates/schema_cache/src/schema_cache.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@ use std::future::join;
22

33
use 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)]
89
pub struct SchemaCache {
9-
pub schemas: Schemas,
10+
pub schemas: Vec<Schema>,
11+
pub tables: Vec<Table>,
1012
}
1113

1214
impl 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

2830
pub trait SchemaCacheItem {
29-
async fn load(pool: &PgPool) -> Vec<Self>;
31+
type Item;
32+
33+
async fn load(pool: &PgPool) -> Vec<Self::Item>;
3034
}

crates/schema_cache/src/schemas.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ pub struct Schema {
1010
}
1111

1212
impl SchemaCacheItem for Schema {
13+
type Item = Schema;
14+
1315
async fn load(pool: &PgPool) -> Vec<Schema> {
1416
sqlx::query_as!(
1517
Schema,

crates/schema_cache/src/tables.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,20 @@ use sqlx::PgPool;
22

33
use crate::schema_cache::SchemaCacheItem;
44

5+
#[derive(Debug, Clone, PartialEq)]
56
pub 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+
1219
impl From<String> for ReplicaIdentity {
1320
fn from(s: String) -> Self {
1421
match s.as_str() {
@@ -37,6 +44,8 @@ pub struct Table {
3744
}
3845

3946
impl SchemaCacheItem for Table {
47+
type Item = Table;
48+
4049
async fn load(pool: &PgPool) -> Vec<Table> {
4150
sqlx::query_as!(
4251
Table,

0 commit comments

Comments
 (0)