From 95e95d735e46ec00027950e8a7d9b033cd3a9fdf Mon Sep 17 00:00:00 2001 From: Richard Newman Date: Wed, 17 Jan 2018 16:36:15 -0600 Subject: [PATCH] Correct an assert relating Datalog projection and SQL column counts. (#519) r=tcsc * Correct an assert relating Datalog projection and SQL column counts. (#517) * Fix a comment that shouldn't be a doc comment. --- db/src/db.rs | 12 ++++++------ query-projector/src/lib.rs | 6 ++++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/db/src/db.rs b/db/src/db.rs index ccdfc7d9..8b7fb887 100644 --- a/db/src/db.rs +++ b/db/src/db.rs @@ -69,12 +69,12 @@ pub fn new_connection(uri: T) -> rusqlite::Result where _ => rusqlite::Connection::open(uri)?, }; - /// See https://github.com/mozilla/mentat/issues/505 for details on temp_store - /// pragma and how it might interact together with consumers such as Firefox. - /// temp_store=2 is currently present to force SQLite to store temp files in memory. - /// Some of the platforms we support do not have a tmp partition (e.g. Android) - /// necessary to store temp files on disk. Ideally, consumers should be able to - /// override this behaviour (see issue 505). + // See https://github.com/mozilla/mentat/issues/505 for details on temp_store + // pragma and how it might interact together with consumers such as Firefox. + // temp_store=2 is currently present to force SQLite to store temp files in memory. + // Some of the platforms we support do not have a tmp partition (e.g. Android) + // necessary to store temp files on disk. Ideally, consumers should be able to + // override this behaviour (see issue 505). conn.execute_batch(" PRAGMA page_size=32768; PRAGMA journal_mode=wal; diff --git a/query-projector/src/lib.rs b/query-projector/src/lib.rs index fd59c5c2..37b0e1b7 100644 --- a/query-projector/src/lib.rs +++ b/query-projector/src/lib.rs @@ -374,7 +374,8 @@ impl TupleProjector { // This is exactly the same as for rel. fn collect_bindings<'a, 'stmt>(&self, row: Row<'a, 'stmt>) -> Result> { - assert_eq!(row.column_count(), self.len as i32); + // There will be at least as many SQL columns as Datalog columns. + assert!(row.column_count() >= self.len as i32); self.templates .iter() .map(|ti| ti.lookup(&row)) @@ -422,7 +423,8 @@ impl RelProjector { } fn collect_bindings<'a, 'stmt>(&self, row: Row<'a, 'stmt>) -> Result> { - assert_eq!(row.column_count(), self.len as i32); + // There will be at least as many SQL columns as Datalog columns. + assert!(row.column_count() >= self.len as i32); self.templates .iter() .map(|ti| ti.lookup(&row))