Browse Source

Fix MustExist logic.

Kestrel 2 years ago
parent
commit
22ec52a5ab
1 changed files with 5 additions and 4 deletions
  1. 5 4
      microrm/src/lib.rs

+ 5 - 4
microrm/src/lib.rs

@@ -122,18 +122,19 @@ impl DB {
                     "SELECT * FROM \"sqlite_master\" WHERE \"type\"='table' AND \"name\"='{}'",
                     Metaschema::table_name()
                 ),
-                |row| {
-                    println!("row: {:?}", row);
+                |_row| {
                     has_metaschema = true;
                     true
                 },
             )
             .map_err(DBError::EarlyFailure)?;
 
-        if mode != CreateMode::MustExist {
-            println!("Creating schema!");
+        if !has_metaschema && mode != CreateMode::MustExist {
             return self.create_schema();
         }
+        else if !has_metaschema && mode == CreateMode::MustExist {
+            return Err(DBError::NoSchema)
+        }
 
         let qi = query::QueryInterface::new(self);
         let hash = qi.get_one_by(meta::MetaschemaColumns::Key, "schema_hash");