Ver Fonte

Moved migration behind feature gate, fixed tests.

Kestrel há 2 semanas atrás
pai
commit
5b90239bec

+ 1 - 1
microrm-macros/src/schema.rs

@@ -45,7 +45,7 @@ pub fn derive(tokens: proc_macro::TokenStream) -> proc_macro::TokenStream {
         let item_type = &field.1;
 
         quote! {
-            <#item_type as Default>::default().accept_item_visitor(v);
+            <#item_type as ::microrm::schema::DatabaseItem>::accept_item_visitor(&<#item_type as Default>::default(), v);
         }
     });
 

+ 1 - 0
microrm/Cargo.toml

@@ -16,6 +16,7 @@ all-features = true
 [features]
 clap = ["dep:clap"]
 bundled_sqlite = ["libsqlite3-sys/bundled"]
+unstable_migration = []
 
 [dependencies]
 libsqlite3-sys = "0.28"

+ 1 - 0
microrm/src/schema.rs

@@ -28,6 +28,7 @@ pub mod relation;
 /// Types related to indexes.
 pub mod index;
 
+#[cfg(feature = "unstable_migration")]
 pub mod migration;
 
 mod build;

+ 1 - 1
microrm/src/schema/migration.rs

@@ -8,7 +8,7 @@ use std::collections::HashSet;
 use crate::{
     db::ConnectionLease,
     query::Queryable,
-    schema::{entity::EntityList, Schema},
+    schema::Schema,
     DBResult,
 };
 

+ 2 - 11
microrm/tests/manual_construction.rs

@@ -126,20 +126,11 @@ struct SimpleDatabase {
 }
 
 impl Schema for SimpleDatabase {
-    fn build() -> Self
+    fn accept_item_visitor(&self, visitor: &mut impl DatabaseItemVisitor)
     where
         Self: Sized,
     {
-        Self {
-            strings: IDMap::build(),
-        }
-    }
-
-    fn accept_item_visitor(visitor: &mut impl DatabaseItemVisitor)
-    where
-        Self: Sized,
-    {
-        <IDMap<SimpleEntity> as DatabaseItem>::accept_item_visitor(visitor);
+        <IDMap<SimpleEntity> as DatabaseItem>::accept_item_visitor(&IDMap::default(), visitor);
     }
 }
 

+ 2 - 0
microrm/tests/migration.rs

@@ -1,3 +1,5 @@
+#![cfg(feature = "unstable_migration")]
+
 use microrm::{
     prelude::*,
     schema::migration::{Migration, Migrator},