コード例 #1
0
        public void Can_query_multiple_match_clauses_with_implicit_intersection()
        {
            using (var store = GetDocumentStore())
            {
                Samples.CreateMoviesData(store);
                using (var session = store.OpenSession())
                {
                    var results = session.Advanced.RawQuery <JObject>(@"
                       match(Users as u1)-[HasRated where Score > 1 select Movie]->(Movies as m where id() = 'movies/2')<-[HasRated select Movie]-(Users as u2)                              
                       select u1.Name as U1,u2.Name as U2
                    ").ToList().Select(x => new
                    {
                        u1 = x["U1"].Value <string>(),
                        u2 = x["U2"].Value <string>(),
                    }).ToList();

                    //since we didn't use "where" clause to make sure (u1 != u2), we would have all permutations
                    Assert.NotEmpty(results);
                    Assert.Equal(4, results.Count);
                    Assert.Contains(results, item => item.u1 == "Jack" && item.u2 == "Jill");
                    Assert.Contains(results, item => item.u1 == "Jack" && item.u2 == "Jack");
                    Assert.Contains(results, item => item.u1 == "Jill" && item.u2 == "Jill");
                    Assert.Contains(results, item => item.u1 == "Jack" && item.u2 == "Jack");
                }
            }
        }
コード例 #2
0
ファイル: BasicGraphQueries.cs プロジェクト: ikvm/ravendb
 public void Can_flatten_result_for_single_vertex_in_row()
 {
     using (var store = GetDocumentStore())
     {
         Samples.CreateMoviesData(store);
         using (var session = store.OpenSession())
         {
             var allVerticesQuery = session.Advanced.RawQuery <JObject>(@"match (_ as v)").ToList();
             Assert.False(allVerticesQuery.Any(row => row.ContainsKey("_ as v"))); //we have "flat" results
         }
     }
 }
コード例 #3
0
ファイル: BasicGraphQueries.cs プロジェクト: ikvm/ravendb
 public void Empty_vertex_node_should_work()
 {
     using (var store = GetDocumentStore())
     {
         Samples.CreateMoviesData(store);
         using (var session = store.OpenSession())
         {
             var results = session.Advanced.RawQuery <Movie>("match ()-[HasRated select Movie]->(Movies as m) select m").ToList();
             Assert.Equal(5, results.Count);
         }
     }
 }
コード例 #4
0
ファイル: BasicGraphQueries.cs プロジェクト: ikvm/ravendb
 public void Mutliple_results_in_row_wont_flatten_results()
 {
     using (var store = GetDocumentStore())
     {
         Samples.CreateMoviesData(store);
         using (var session = store.OpenSession())
         {
             var allVerticesQuery = session.Advanced.RawQuery <JObject>(@"match (_ as u)-[HasRated select Movie]->(_ as m)").ToList();
             Assert.True(allVerticesQuery.All(row => row.ContainsKey("m")));
             Assert.True(allVerticesQuery.All(row => row.ContainsKey("u")));
         }
     }
 }
コード例 #5
0
ファイル: RavenDB-12198.cs プロジェクト: ikvm/ravendb
        public void Select_in_node_without_alias_should_properly_throw()
        {
            using (var store = GetDocumentStore())
            {
                Samples.CreateMoviesData(store);
                using (var session = store.OpenSession())
                {
                    var e = Assert.Throws <InvalidQueryException>(() => session.Advanced.RawQuery <JObject>(@"
                       match (Users select Name)-[HasRated select Movie]->(Movies as m)
                    ").ToArray());

                    Assert.True(e.Message.Contains("select", StringComparison.OrdinalIgnoreCase) && e.Message.Contains("forbidden", StringComparison.OrdinalIgnoreCase));
                }
            }
        }
コード例 #6
0
ファイル: RavenDB-12198.cs プロジェクト: ikvm/ravendb
        public void Missing_as_keyword_in_node_without_additional_clauses_should_properly_throw_in_non_recursive_query()
        {
            using (var store = GetDocumentStore())
            {
                Samples.CreateMoviesData(store);
                using (var session = store.OpenSession())
                {
                    var e = Assert.Throws <InvalidQueryException>(() => session.Advanced.RawQuery <JObject>(@"
                       match (Users u1)-[HasRated select Movie]->(Movies as m)
                    ").ToArray());

                    Assert.True(e.Message.Contains("invalid", StringComparison.OrdinalIgnoreCase) && e.Message.Contains("alias", StringComparison.OrdinalIgnoreCase) && e.Message.Contains("u1", StringComparison.OrdinalIgnoreCase));
                }
            }
        }
コード例 #7
0
 public void Incomplete_union_query_should_properly_fail()
 {
     using (var store = GetDocumentStore())
     {
         Samples.CreateMoviesData(store);
         using (var session = store.OpenSession())
         {
             Assert.Throws <InvalidQueryException>(() =>
                                                   session.Advanced.RawQuery <JObject>(@"
                     match(Users as u1)-[HasRated where Score > 1 select Movie]->(Movies as m) OR
                     select u1,u2
                 ").ToList());
         }
     }
 }
コード例 #8
0
ファイル: BasicGraphQueries.cs プロジェクト: ikvm/ravendb
        public void Can_filter_vertices_with_explicit_with_clause()
        {
            using (var store = GetDocumentStore())
            {
                Samples.CreateMoviesData(store);
                using (var session = store.OpenSession())
                {
                    var results = session.Advanced.RawQuery <JObject>(@"
                        with {from Users where id() = 'users/2'} as u
                        match (u) select u.Name").ToList().Select(x => x["Name"].Value <string>()).ToArray();

                    Assert.Equal(1, results.Length);
                    results[0] = "Jill";
                }
            }
        }
コード例 #9
0
ファイル: BasicGraphQueries.cs プロジェクト: ikvm/ravendb
        public void Can_use_explicit_with_clause()
        {
            using (var store = GetDocumentStore())
            {
                Samples.CreateMoviesData(store);
                using (var session = store.OpenSession())
                {
                    var results = session.Advanced.RawQuery <JObject>(@"
                        with {from Users} as u
                        match (u)").ToList();

                    Assert.Equal(3, results.Count);
                    var docTypes = results.Select(x => x["@metadata"]["@collection"].Value <string>()).ToArray();
                    Assert.Equal(3, docTypes.Count(t => t == "Users"));
                }
            }
        }
コード例 #10
0
ファイル: BasicGraphQueries.cs プロジェクト: ikvm/ravendb
        public void Can_query_without_collection_identifier()
        {
            using (var store = GetDocumentStore())
            {
                Samples.CreateMoviesData(store);
                using (var session = store.OpenSession())
                {
                    var allVerticesQuery = session.Advanced.RawQuery <JObject>(@"match (_ as v)").ToList();

                    Assert.Equal(9, allVerticesQuery.Count);
                    var docTypes = allVerticesQuery.Select(x => x["@metadata"]["@collection"].Value <string>()).ToArray();

                    Assert.Equal(3, docTypes.Count(t => t == "Genres"));
                    Assert.Equal(3, docTypes.Count(t => t == "Movies"));
                    Assert.Equal(3, docTypes.Count(t => t == "Users"));
                }
            }
        }