diff --git a/query/linkedql/registry_test.go b/query/linkedql/registry_test.go index 51792a125..41ccf4a8c 100644 --- a/query/linkedql/registry_test.go +++ b/query/linkedql/registry_test.go @@ -97,7 +97,7 @@ var unmarshalCases = []struct { type TestStep struct { Limit int `json:"limit"` Tags []string `json:"tags"` - From PathStep `json:"from"` + From PathStep `json:"from" minCardinality:"0"` Sub []PathStep `json:"sub"` } diff --git a/query/linkedql/step_utils.go b/query/linkedql/step_utils.go new file mode 100644 index 000000000..83db85088 --- /dev/null +++ b/query/linkedql/step_utils.go @@ -0,0 +1,20 @@ +package linkedql + +import ( + "github.com/cayleygraph/cayley/graph" + "github.com/cayleygraph/cayley/query/path" + "github.com/cayleygraph/quad/voc" +) + +// BuildFromPath creates a path of a given from +// In case from is nil defaults to placeholder +func BuildFromPath(qs graph.QuadStore, ns *voc.Namespaces, from PathStep) (*path.Path, error) { + if from == nil { + return path.StartMorphism(), nil + } + fromPath, err := from.BuildPath(qs, ns) + if err != nil { + return nil, err + } + return fromPath, nil +} diff --git a/query/linkedql/steps/as.go b/query/linkedql/steps/as.go index 032642d4e..4360bd68a 100644 --- a/query/linkedql/steps/as.go +++ b/query/linkedql/steps/as.go @@ -26,7 +26,7 @@ func (s *As) Description() string { // BuildPath implements linkedql.PathStep. func (s *As) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) { - fromPath, err := s.From.BuildPath(qs, ns) + fromPath, err := linkedql.BuildFromPath(qs, ns, s.From) if err != nil { return nil, err } diff --git a/query/linkedql/steps/back.go b/query/linkedql/steps/back.go index 96d69d8a2..14d10520c 100644 --- a/query/linkedql/steps/back.go +++ b/query/linkedql/steps/back.go @@ -26,7 +26,7 @@ func (s *Back) Description() string { // BuildPath implements linkedql.PathStep. func (s *Back) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) { - fromPath, err := s.From.BuildPath(qs, ns) + fromPath, err := linkedql.BuildFromPath(qs, ns, s.From) if err != nil { return nil, err } diff --git a/query/linkedql/steps/both.go b/query/linkedql/steps/both.go index d089df71e..ac8120600 100644 --- a/query/linkedql/steps/both.go +++ b/query/linkedql/steps/both.go @@ -15,7 +15,7 @@ var _ linkedql.PathStep = (*Both)(nil) // Both corresponds to .both(). type Both struct { - From linkedql.PathStep `json:"from"` + From linkedql.PathStep `json:"from" minCardinality:"0"` Properties *linkedql.PropertyPath `json:"properties"` } @@ -26,7 +26,7 @@ func (s *Both) Description() string { // BuildPath implements linkedql.PathStep. func (s *Both) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) { - fromPath, err := s.From.BuildPath(qs, ns) + fromPath, err := linkedql.BuildFromPath(qs, ns, s.From) if err != nil { return nil, err } diff --git a/query/linkedql/steps/collect.go b/query/linkedql/steps/collect.go index 5aee7d84c..8a68873f3 100644 --- a/query/linkedql/steps/collect.go +++ b/query/linkedql/steps/collect.go @@ -33,7 +33,7 @@ var ( // BuildPath implements linkedql.PathStep. func (s *Collect) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) { - fromPath, err := s.From.BuildPath(qs, ns) + fromPath, err := linkedql.BuildFromPath(qs, ns, s.From) if err != nil { return nil, err } diff --git a/query/linkedql/steps/count.go b/query/linkedql/steps/count.go index e9762dbd1..ff9830b3d 100644 --- a/query/linkedql/steps/count.go +++ b/query/linkedql/steps/count.go @@ -15,7 +15,7 @@ var _ linkedql.PathStep = (*Count)(nil) // Count corresponds to .count(). type Count struct { - From linkedql.PathStep `json:"from"` + From linkedql.PathStep `json:"from" minCardinality:"0"` } // Description implements Step. @@ -25,7 +25,7 @@ func (s *Count) Description() string { // BuildPath implements linkedql.PathStep. func (s *Count) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) { - fromPath, err := s.From.BuildPath(qs, ns) + fromPath, err := linkedql.BuildFromPath(qs, ns, s.From) if err != nil { return nil, err } diff --git a/query/linkedql/steps/difference.go b/query/linkedql/steps/difference.go index 78c8eb115..60a03c30f 100644 --- a/query/linkedql/steps/difference.go +++ b/query/linkedql/steps/difference.go @@ -26,7 +26,7 @@ func (s *Difference) Description() string { // BuildPath implements linkedql.PathStep. func (s *Difference) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) { - fromPath, err := s.From.BuildPath(qs, ns) + fromPath, err := linkedql.BuildFromPath(qs, ns, s.From) if err != nil { return nil, err } diff --git a/query/linkedql/steps/greater_than.go b/query/linkedql/steps/greater_than.go index 52cab333c..f2c5097e3 100644 --- a/query/linkedql/steps/greater_than.go +++ b/query/linkedql/steps/greater_than.go @@ -17,7 +17,7 @@ var _ linkedql.PathStep = (*GreaterThan)(nil) // GreaterThan corresponds to gt(). type GreaterThan struct { - From linkedql.PathStep `json:"from"` + From linkedql.PathStep `json:"from" minCardinality:"0"` Value quad.Value `json:"value"` } @@ -28,7 +28,7 @@ func (s *GreaterThan) Description() string { // BuildPath implements linkedql.PathStep. func (s *GreaterThan) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) { - fromPath, err := s.From.BuildPath(qs, ns) + fromPath, err := linkedql.BuildFromPath(qs, ns, s.From) if err != nil { return nil, err } diff --git a/query/linkedql/steps/greater_than_equals.go b/query/linkedql/steps/greater_than_equals.go index 50b36a9e5..46fe7c915 100644 --- a/query/linkedql/steps/greater_than_equals.go +++ b/query/linkedql/steps/greater_than_equals.go @@ -17,7 +17,7 @@ var _ linkedql.PathStep = (*GreaterThanEquals)(nil) // GreaterThanEquals corresponds to gte(). type GreaterThanEquals struct { - From linkedql.PathStep `json:"from"` + From linkedql.PathStep `json:"from" minCardinality:"0"` Value quad.Value `json:"value"` } @@ -28,7 +28,7 @@ func (s *GreaterThanEquals) Description() string { // BuildPath implements linkedql.PathStep. func (s *GreaterThanEquals) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) { - fromPath, err := s.From.BuildPath(qs, ns) + fromPath, err := linkedql.BuildFromPath(qs, ns, s.From) if err != nil { return nil, err } diff --git a/query/linkedql/steps/has.go b/query/linkedql/steps/has.go index d8b47a746..3ed0c16d3 100644 --- a/query/linkedql/steps/has.go +++ b/query/linkedql/steps/has.go @@ -16,7 +16,7 @@ var _ linkedql.PathStep = (*Has)(nil) // Has corresponds to .has(). type Has struct { - From linkedql.PathStep `json:"from"` + From linkedql.PathStep `json:"from" minCardinality:"0"` Property *linkedql.PropertyPath `json:"property"` Values []quad.Value `json:"values"` } @@ -28,7 +28,7 @@ func (s *Has) Description() string { // BuildPath implements linkedql.PathStep. func (s *Has) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) { - fromPath, err := s.From.BuildPath(qs, ns) + fromPath, err := linkedql.BuildFromPath(qs, ns, s.From) if err != nil { return nil, err } diff --git a/query/linkedql/steps/has_reverse.go b/query/linkedql/steps/has_reverse.go index 4ae5a6bce..d30c7d082 100644 --- a/query/linkedql/steps/has_reverse.go +++ b/query/linkedql/steps/has_reverse.go @@ -16,7 +16,7 @@ var _ linkedql.PathStep = (*HasReverse)(nil) // HasReverse corresponds to .hasR(). type HasReverse struct { - From linkedql.PathStep `json:"from"` + From linkedql.PathStep `json:"from" minCardinality:"0"` Property *linkedql.PropertyPath `json:"property"` Values []quad.Value `json:"values"` } @@ -28,7 +28,7 @@ func (s *HasReverse) Description() string { // BuildPath implements linkedql.PathStep. func (s *HasReverse) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) { - fromPath, err := s.From.BuildPath(qs, ns) + fromPath, err := linkedql.BuildFromPath(qs, ns, s.From) if err != nil { return nil, err } diff --git a/query/linkedql/steps/intersect.go b/query/linkedql/steps/intersect.go index 9e48671ff..2e63eb992 100644 --- a/query/linkedql/steps/intersect.go +++ b/query/linkedql/steps/intersect.go @@ -26,7 +26,7 @@ func (s *Intersect) Description() string { // BuildPath implements linkedql.PathStep. func (s *Intersect) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) { - fromPath, err := s.From.BuildPath(qs, ns) + fromPath, err := linkedql.BuildFromPath(qs, ns, s.From) if err != nil { return nil, err } diff --git a/query/linkedql/steps/labels.go b/query/linkedql/steps/labels.go index 972f94c68..545173839 100644 --- a/query/linkedql/steps/labels.go +++ b/query/linkedql/steps/labels.go @@ -15,7 +15,7 @@ var _ linkedql.PathStep = (*Labels)(nil) // Labels corresponds to .labels(). type Labels struct { - From linkedql.PathStep `json:"from"` + From linkedql.PathStep `json:"from" minCardinality:"0"` } // Description implements Step. @@ -25,7 +25,7 @@ func (s *Labels) Description() string { // BuildPath implements linkedql.PathStep. func (s *Labels) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) { - fromPath, err := s.From.BuildPath(qs, ns) + fromPath, err := linkedql.BuildFromPath(qs, ns, s.From) if err != nil { return nil, err } diff --git a/query/linkedql/steps/less_than.go b/query/linkedql/steps/less_than.go index 32cbd82fd..6f55d3154 100644 --- a/query/linkedql/steps/less_than.go +++ b/query/linkedql/steps/less_than.go @@ -17,7 +17,7 @@ var _ linkedql.PathStep = (*LessThan)(nil) // LessThan corresponds to lt(). type LessThan struct { - From linkedql.PathStep `json:"from"` + From linkedql.PathStep `json:"from" minCardinality:"0"` Value quad.Value `json:"value"` } @@ -28,7 +28,7 @@ func (s *LessThan) Description() string { // BuildPath implements linkedql.PathStep. func (s *LessThan) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) { - fromPath, err := s.From.BuildPath(qs, ns) + fromPath, err := linkedql.BuildFromPath(qs, ns, s.From) if err != nil { return nil, err } diff --git a/query/linkedql/steps/less_than_equals.go b/query/linkedql/steps/less_than_equals.go index 65c02b469..e216970cc 100644 --- a/query/linkedql/steps/less_than_equals.go +++ b/query/linkedql/steps/less_than_equals.go @@ -17,7 +17,7 @@ var _ linkedql.PathStep = (*LessThanEquals)(nil) // LessThanEquals corresponds to lte(). type LessThanEquals struct { - From linkedql.PathStep `json:"from"` + From linkedql.PathStep `json:"from" minCardinality:"0"` Value quad.Value `json:"value"` } @@ -28,7 +28,7 @@ func (s *LessThanEquals) Description() string { // BuildPath implements linkedql.PathStep. func (s *LessThanEquals) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) { - fromPath, err := s.From.BuildPath(qs, ns) + fromPath, err := linkedql.BuildFromPath(qs, ns, s.From) if err != nil { return nil, err } diff --git a/query/linkedql/steps/like.go b/query/linkedql/steps/like.go index 875d944db..235550f0e 100644 --- a/query/linkedql/steps/like.go +++ b/query/linkedql/steps/like.go @@ -16,7 +16,7 @@ var _ linkedql.PathStep = (*Like)(nil) // Like corresponds to like(). type Like struct { - From linkedql.PathStep `json:"from"` + From linkedql.PathStep `json:"from" minCardinality:"0"` Pattern string `json:"likePattern"` } @@ -27,7 +27,7 @@ func (s *Like) Description() string { // BuildPath implements PathStep. func (s *Like) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) { - fromPath, err := s.From.BuildPath(qs, ns) + fromPath, err := linkedql.BuildFromPath(qs, ns, s.From) if err != nil { return nil, err } diff --git a/query/linkedql/steps/limit.go b/query/linkedql/steps/limit.go index 80627e738..c6161c382 100644 --- a/query/linkedql/steps/limit.go +++ b/query/linkedql/steps/limit.go @@ -26,7 +26,7 @@ func (s *Limit) Description() string { // BuildPath implements linkedql.PathStep. func (s *Limit) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) { - fromPath, err := s.From.BuildPath(qs, ns) + fromPath, err := linkedql.BuildFromPath(qs, ns, s.From) if err != nil { return nil, err } diff --git a/query/linkedql/steps/optional.go b/query/linkedql/steps/optional.go index f8a18085e..3f8bff7fd 100644 --- a/query/linkedql/steps/optional.go +++ b/query/linkedql/steps/optional.go @@ -15,7 +15,7 @@ var _ linkedql.PathStep = (*Optional)(nil) // Optional corresponds to .optional(). type Optional struct { - From linkedql.PathStep `json:"from"` + From linkedql.PathStep `json:"from" minCardinality:"0"` Step linkedql.PathStep `json:"step"` } @@ -26,7 +26,7 @@ func (s *Optional) Description() string { // BuildPath implements linkedql.PathStep. func (s *Optional) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) { - fromPath, err := s.From.BuildPath(qs, ns) + fromPath, err := linkedql.BuildFromPath(qs, ns, s.From) if err != nil { return nil, err } diff --git a/query/linkedql/steps/order.go b/query/linkedql/steps/order.go index 5bb459d26..b962f7088 100644 --- a/query/linkedql/steps/order.go +++ b/query/linkedql/steps/order.go @@ -25,7 +25,7 @@ func (s *Order) Description() string { // BuildPath implements linkedql.PathStep. func (s *Order) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) { - fromPath, err := s.From.BuildPath(qs, ns) + fromPath, err := linkedql.BuildFromPath(qs, ns, s.From) if err != nil { return nil, err } diff --git a/query/linkedql/steps/properties.go b/query/linkedql/steps/properties.go index d98f90b0a..74c60766b 100644 --- a/query/linkedql/steps/properties.go +++ b/query/linkedql/steps/properties.go @@ -18,7 +18,7 @@ var _ linkedql.PathStep = (*Properties)(nil) // Properties corresponds to .properties(). type Properties struct { - From linkedql.PathStep `json:"from"` + From linkedql.PathStep `json:"from" minCardinality:"0"` Names *linkedql.PropertyPath `json:"names"` } @@ -49,7 +49,7 @@ func resolveNames(names *linkedql.PropertyPath) (linkedql.PropertyIRIs, error) { // BuildPath implements linkedql.PathStep. func (s *Properties) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) { - fromPath, err := s.From.BuildPath(qs, ns) + fromPath, err := linkedql.BuildFromPath(qs, ns, s.From) if err != nil { return nil, err } diff --git a/query/linkedql/steps/property_names.go b/query/linkedql/steps/property_names.go index c75b51a65..df3b7e895 100644 --- a/query/linkedql/steps/property_names.go +++ b/query/linkedql/steps/property_names.go @@ -15,7 +15,7 @@ var _ linkedql.PathStep = (*PropertyNames)(nil) // PropertyNames corresponds to .propertyNames(). type PropertyNames struct { - From linkedql.PathStep `json:"from"` + From linkedql.PathStep `json:"from" minCardinality:"0"` } // Description implements Step. @@ -25,7 +25,7 @@ func (s *PropertyNames) Description() string { // BuildPath implements linkedql.PathStep. func (s *PropertyNames) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) { - fromPath, err := s.From.BuildPath(qs, ns) + fromPath, err := linkedql.BuildFromPath(qs, ns, s.From) if err != nil { return nil, err } diff --git a/query/linkedql/steps/property_names_as.go b/query/linkedql/steps/property_names_as.go index f755b2486..1d625b722 100644 --- a/query/linkedql/steps/property_names_as.go +++ b/query/linkedql/steps/property_names_as.go @@ -15,7 +15,7 @@ var _ linkedql.PathStep = (*PropertyNamesAs)(nil) // PropertyNamesAs corresponds to .propertyNamesAs(). type PropertyNamesAs struct { - From linkedql.PathStep `json:"from"` + From linkedql.PathStep `json:"from" minCardinality:"0"` Tag string `json:"tag"` } @@ -26,7 +26,7 @@ func (s *PropertyNamesAs) Description() string { // BuildPath implements linkedql.PathStep. func (s *PropertyNamesAs) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) { - fromPath, err := s.From.BuildPath(qs, ns) + fromPath, err := linkedql.BuildFromPath(qs, ns, s.From) if err != nil { return nil, err } diff --git a/query/linkedql/steps/regexp.go b/query/linkedql/steps/regexp.go index ce277a3b9..0f9987a49 100644 --- a/query/linkedql/steps/regexp.go +++ b/query/linkedql/steps/regexp.go @@ -29,7 +29,7 @@ func (s *RegExp) Description() string { // BuildPath implements PathStep. func (s *RegExp) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) { - fromPath, err := s.From.BuildPath(qs, ns) + fromPath, err := linkedql.BuildFromPath(qs, ns, s.From) if err != nil { return nil, err } diff --git a/query/linkedql/steps/reverse_properties.go b/query/linkedql/steps/reverse_properties.go index 601eae8a5..d371cbd1c 100644 --- a/query/linkedql/steps/reverse_properties.go +++ b/query/linkedql/steps/reverse_properties.go @@ -16,7 +16,7 @@ var _ linkedql.PathStep = (*ReverseProperties)(nil) // ReverseProperties corresponds to .reverseProperties(). type ReverseProperties struct { - From linkedql.PathStep `json:"from"` + From linkedql.PathStep `json:"from" minCardinality:"0"` Names *linkedql.PropertyPath `json:"names"` } @@ -27,7 +27,7 @@ func (s *ReverseProperties) Description() string { // BuildPath implements linkedql.PathStep. func (s *ReverseProperties) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) { - fromPath, err := s.From.BuildPath(qs, ns) + fromPath, err := linkedql.BuildFromPath(qs, ns, s.From) if err != nil { return nil, err } diff --git a/query/linkedql/steps/reverse_property_names.go b/query/linkedql/steps/reverse_property_names.go index 0c7dccd11..bdb9f8c1f 100644 --- a/query/linkedql/steps/reverse_property_names.go +++ b/query/linkedql/steps/reverse_property_names.go @@ -15,7 +15,7 @@ var _ linkedql.PathStep = (*ReversePropertyNames)(nil) // ReversePropertyNames corresponds to .reversePropertyNames(). type ReversePropertyNames struct { - From linkedql.PathStep `json:"from"` + From linkedql.PathStep `json:"from" minCardinality:"0"` } // Description implements Step. @@ -25,7 +25,7 @@ func (s *ReversePropertyNames) Description() string { // BuildPath implements linkedql.PathStep. func (s *ReversePropertyNames) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) { - fromPath, err := s.From.BuildPath(qs, ns) + fromPath, err := linkedql.BuildFromPath(qs, ns, s.From) if err != nil { return nil, err } diff --git a/query/linkedql/steps/reverse_property_names_as.go b/query/linkedql/steps/reverse_property_names_as.go index f30c74577..06475291a 100644 --- a/query/linkedql/steps/reverse_property_names_as.go +++ b/query/linkedql/steps/reverse_property_names_as.go @@ -15,7 +15,7 @@ var _ linkedql.PathStep = (*ReversePropertyNamesAs)(nil) // ReversePropertyNamesAs corresponds to .reversePropertyNamesAs(). type ReversePropertyNamesAs struct { - From linkedql.PathStep `json:"from"` + From linkedql.PathStep `json:"from" minCardinality:"0"` Tag string `json:"tag"` } @@ -26,7 +26,7 @@ func (s *ReversePropertyNamesAs) Description() string { // BuildPath implements linkedql.PathStep. func (s *ReversePropertyNamesAs) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) { - fromPath, err := s.From.BuildPath(qs, ns) + fromPath, err := linkedql.BuildFromPath(qs, ns, s.From) if err != nil { return nil, err } diff --git a/query/linkedql/steps/skip.go b/query/linkedql/steps/skip.go index 55e025be6..73e190244 100644 --- a/query/linkedql/steps/skip.go +++ b/query/linkedql/steps/skip.go @@ -26,7 +26,7 @@ func (s *Skip) Description() string { // BuildPath implements linkedql.PathStep. func (s *Skip) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) { - fromPath, err := s.From.BuildPath(qs, ns) + fromPath, err := linkedql.BuildFromPath(qs, ns, s.From) if err != nil { return nil, err } diff --git a/query/linkedql/steps/steps_final.go b/query/linkedql/steps/steps_final.go index 8537369a8..377c933e3 100644 --- a/query/linkedql/steps/steps_final.go +++ b/query/linkedql/steps/steps_final.go @@ -16,8 +16,8 @@ var _ linkedql.IteratorStep = (*Select)(nil) // Select corresponds to .select(). type Select struct { + From linkedql.PathStep `json:"from" minCardinality:"0"` Properties []string `json:"properties"` - From linkedql.PathStep `json:"from"` ExcludeID bool `json:"excludeID"` } @@ -40,7 +40,7 @@ var _ linkedql.IteratorStep = (*Documents)(nil) // Documents corresponds to .documents(). type Documents struct { - From linkedql.PathStep `json:"from"` + From linkedql.PathStep `json:"from" minCardinality:"0"` } // Description implements Step. diff --git a/query/linkedql/steps/union.go b/query/linkedql/steps/union.go index 1c9b981b6..779a0bb96 100644 --- a/query/linkedql/steps/union.go +++ b/query/linkedql/steps/union.go @@ -15,7 +15,7 @@ var _ linkedql.PathStep = (*Union)(nil) // Union corresponds to .union() and .or(). type Union struct { - From linkedql.PathStep `json:"from"` + From linkedql.PathStep `json:"from" minCardinality:"0"` Steps []linkedql.PathStep `json:"steps"` } @@ -26,7 +26,7 @@ func (s *Union) Description() string { // BuildPath implements linkedql.PathStep. func (s *Union) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) { - fromPath, err := s.From.BuildPath(qs, ns) + fromPath, err := linkedql.BuildFromPath(qs, ns, s.From) if err != nil { return nil, err } diff --git a/query/linkedql/steps/unique.go b/query/linkedql/steps/unique.go index bc6c68845..9f3ddf538 100644 --- a/query/linkedql/steps/unique.go +++ b/query/linkedql/steps/unique.go @@ -25,7 +25,7 @@ func (s *Unique) Description() string { // BuildPath implements linkedql.PathStep. func (s *Unique) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) { - fromPath, err := s.From.BuildPath(qs, ns) + fromPath, err := linkedql.BuildFromPath(qs, ns, s.From) if err != nil { return nil, err } diff --git a/query/linkedql/steps/visit.go b/query/linkedql/steps/visit.go index 460ca4cff..edecf161c 100644 --- a/query/linkedql/steps/visit.go +++ b/query/linkedql/steps/visit.go @@ -15,7 +15,7 @@ var _ linkedql.PathStep = (*Visit)(nil) // Visit corresponds to .view(). type Visit struct { - From linkedql.PathStep `json:"from"` + From linkedql.PathStep `json:"from" minCardinality:"0"` Properties *linkedql.PropertyPath `json:"properties"` } @@ -26,7 +26,7 @@ func (s *Visit) Description() string { // BuildPath implements linkedql.PathStep. func (s *Visit) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) { - fromPath, err := s.From.BuildPath(qs, ns) + fromPath, err := linkedql.BuildFromPath(qs, ns, s.From) if err != nil { return nil, err } diff --git a/query/linkedql/steps/visit_reverse.go b/query/linkedql/steps/visit_reverse.go index 8f3f0098d..b44f6fb57 100644 --- a/query/linkedql/steps/visit_reverse.go +++ b/query/linkedql/steps/visit_reverse.go @@ -15,7 +15,7 @@ var _ linkedql.PathStep = (*VisitReverse)(nil) // VisitReverse corresponds to .viewReverse(). type VisitReverse struct { - From linkedql.PathStep `json:"from"` + From linkedql.PathStep `json:"from" minCardinality:"0"` Properties *linkedql.PropertyPath `json:"properties"` } @@ -26,7 +26,7 @@ func (s *VisitReverse) Description() string { // BuildPath implements linkedql.PathStep. func (s *VisitReverse) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) { - fromPath, err := s.From.BuildPath(qs, ns) + fromPath, err := linkedql.BuildFromPath(qs, ns, s.From) if err != nil { return nil, err } diff --git a/query/linkedql/steps/where.go b/query/linkedql/steps/where.go index 2b7fc137e..f60da6e8f 100644 --- a/query/linkedql/steps/where.go +++ b/query/linkedql/steps/where.go @@ -26,7 +26,7 @@ func (s *Where) Description() string { // BuildPath implements linkedql.PathStep. func (s *Where) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) { - fromPath, err := s.From.BuildPath(qs, ns) + fromPath, err := linkedql.BuildFromPath(qs, ns, s.From) if err != nil { return nil, err }