From 3eb898566b954da1988c20d721d87c04f6d0a596 Mon Sep 17 00:00:00 2001 From: Richard Newman Date: Tue, 20 Jun 2017 09:12:19 -0700 Subject: [PATCH] Add commented-out failing tests for type code expansion. --- query-translator/tests/translate.rs | 49 +++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/query-translator/tests/translate.rs b/query-translator/tests/translate.rs index 431d79c0..d3402b66 100644 --- a/query-translator/tests/translate.rs +++ b/query-translator/tests/translate.rs @@ -754,6 +754,55 @@ fn test_unbound_attribute_with_ground() { `all_datoms00`.value_type_tag = 5)"); } +/* +#[test] +fn test_colliding_values_unbound_types() { + let schema = prepopulated_schema(); + let query = r#"[:find ?x ?a ?y + :where + [?x _ ?y] + [?a _ ?y]]"#; + let SQLQuery { sql, .. } = translate(&schema, query); + assert_eq!(sql, "SELECT DISTINCT `all_datoms00`.e AS `?x`, \ + `all_datoms01`.e AS `?a`, \ + `all_datoms00`.v AS `?y`, \ + `all_datoms00`.value_type_tag AS `?y_value_type_tag` \ + FROM `all_datoms` AS `all_datoms00`, `all_datoms` AS `all_datoms01` \ + WHERE `all_datoms00`.v = `all_datoms01`.v \ + AND `all_datoms00`.value_type_tag = `all_datoms01`.value_type_tag"); +} + +#[test] +fn test_restricted_types() { + let schema = prepopulated_schema(); + let query = r#"[:find ?x ?y + :where + [?x _ ?y] + [(< ?y 10)]]"#; + let SQLQuery { sql, .. } = translate(&schema, query); + + // #385: use `datoms` instead of `all_datoms`. + // No need to project the type code -- long and double are distinguishable. + assert_eq!(sql, "SELECT DISTINCT `all_datoms00`.e AS `?x`, \ + `all_datoms00`.v AS `?y` \ + FROM `all_datoms` AS `all_datoms00` \ + WHERE `all_datoms00`.v < 10 \ + AND `all_datoms00`.value_type_tag = 5"); +} + +#[test] +fn test_known_type_range() { + let schema = prepopulated_schema(); + let query = r#"[:find ?x ?y :where [?x :foo/bar] [?y _ ?x]]"#; + let SQLQuery { sql, .. } = translate(&schema, query); + assert_eq!(sql, "SELECT DISTINCT `datoms00`.e AS `?x`, \ + `datoms00`.e AS `?y` \ + FROM `datoms` AS `datoms00`, `datoms` AS `datoms01` \ + WHERE `datoms00`.a = 66 \ + AND `datoms01`.v = `datoms00`.e \ + AND `datoms01`.value_type_tag = 1"); +} +*/ #[test] fn test_not_with_ground() {