diff --git a/README.md b/README.md index 040eaeb..025cb92 100644 --- a/README.md +++ b/README.md @@ -167,6 +167,8 @@ func main() { EnableLogParams: false, // enable open tracing. Ensure contexts have spans already. GoGM does not make root spans, only child spans OpentracingEnabled: false, + // specify the method gogm will use to generate Load queries + LoadStrategy: gogm.PATH_LOAD_STRATEGY // set to SCHEMA_LOAD_STRATEGY for schema-aware queries which may reduce load on the database } // register all vertices and edges diff --git a/decoder_test.go b/decoder_test.go index 683baa6..e4c28dd 100644 --- a/decoder_test.go +++ b/decoder_test.go @@ -926,4 +926,70 @@ func TestDecode2(t *testing.T) { req.Equal(int64(55), *readin9.Id) req.Equal("dasdfas", readin9.UUID) + // decode should be able to handle queries that return nested lists of paths, relationships, and nodes + decodeResultNested := [][]interface{}{ + { + neo4j.Node{ + Id: 18, + Labels: []string{"a"}, + Props: map[string]interface{}{ + "uuid": "2588baca-7561-43f8-9ddb-9c7aecf87284", + }, + }, + }, + { + []interface{}{ + []interface{}{ + []interface{}{ + []interface{}{ + neo4j.Relationship{ + Id: 0, + StartId: 19, + EndId: 18, + Type: "testm2o", + }, + neo4j.Node{ + Id: 19, + Labels: []string{"b"}, + Props: map[string]interface{}{ + "test_fielda": "1234", + "uuid": "b6d8c2ab-06c2-43d0-8452-89d6c4ec5d40", + }, + }, + }, + }, + []interface{}{}, + []interface{}{ + []interface{}{ + neo4j.Relationship{ + Id: 1, + StartId: 18, + EndId: 19, + Type: "special_single", + Props: map[string]interface{}{ + "test": "testing", + }, + }, + neo4j.Node{ + Id: 19, + Labels: []string{"b"}, + Props: map[string]interface{}{ + "test_fielda": "1234", + "uuid": "b6d8c2ab-06c2-43d0-8452-89d6c4ec5d40", + }, + }, + }, + }, + }, + []interface{}{}, + []interface{}{}, + }, + }, + } + var readinNested a + req.Nil(decode(gogm, newMockResult(decodeResultNested), &readinNested)) + req.Equal("2588baca-7561-43f8-9ddb-9c7aecf87284", readinNested.UUID) + req.Len(readinNested.ManyA, 1) + req.Equal("b6d8c2ab-06c2-43d0-8452-89d6c4ec5d40", readinNested.ManyA[0].UUID) + req.Equal(readinNested.ManyA[0], readinNested.SingleSpecA.End, "Two rels should have the same node instance") } diff --git a/integration_test.go b/integration_test.go index 1e4450a..3c9acb4 100644 --- a/integration_test.go +++ b/integration_test.go @@ -597,7 +597,7 @@ func (i *IntegrationTestSuite) TestSchemaLoadStrategy() { defer req.Nil(sess.Close()) // test raw query (verify SchemaLoadStrategy + Neo driver decoding) - query, err := SchemaLoadStrategyOne(i.gogm, "n", "a", "uuid", "uuid", false, 2, nil) + query, err := SchemaLoadStrategyOne(i.gogm, "n", "a", "uuid", "uuid", false, 1, nil) req.Nil(err, "error generating SchemaLoadStrategy query") cypher, err := query.ToCypher()