Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use one implementation for finding path values #3087

Merged
merged 58 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
bce806c
create initial common implementation
chilagrow Jul 20, 2023
c4073da
rename
chilagrow Jul 20, 2023
d0c0334
distinct uses new impl
chilagrow Jul 20, 2023
33936ff
use new function in filter
chilagrow Jul 20, 2023
aea192d
some cleaning
chilagrow Jul 20, 2023
4594b67
update doc
chilagrow Jul 20, 2023
3a693bd
re-organise filter pair code
chilagrow Jul 20, 2023
1ef1ef9
handle empty key for filter
chilagrow Jul 20, 2023
bee2816
add tests, comments and refactor
chilagrow Jul 21, 2023
d1b8ff0
tidy up
chilagrow Jul 21, 2023
2e0eff7
Merge branch 'main' into issue-2348-get-path-value
chilagrow Jul 21, 2023
9e188b5
fix merge
chilagrow Jul 21, 2023
5ce3f80
fix merge
chilagrow Jul 21, 2023
7b65633
reorganise
chilagrow Jul 21, 2023
876744d
Merge branch 'main' into issue-2348-get-path-value
mergify[bot] Jul 24, 2023
292d897
Merge branch 'main' into issue-2348-get-path-value
mergify[bot] Jul 24, 2023
d0be65d
Merge branch 'main' into issue-2348-get-path-value
mergify[bot] Jul 24, 2023
cc4af16
Merge branch 'main' into issue-2348-get-path-value
mergify[bot] Jul 24, 2023
15aaf03
Merge branch 'main' into issue-2348-get-path-value
mergify[bot] Jul 24, 2023
faf7daa
Merge branch 'main' into issue-2348-get-path-value
mergify[bot] Jul 24, 2023
ae4f67d
Refactor `types.Path` a bit
AlekSi Jul 24, 2023
fc446a3
Small tweaks
AlekSi Jul 24, 2023
0313d17
update test
chilagrow Jul 26, 2023
51c106b
merge
chilagrow Jul 26, 2023
1d5051f
checkpoint
chilagrow Jul 26, 2023
20c464a
Tweak documentation a little bit
AlekSi Jul 26, 2023
aa74542
another checkpoint
chilagrow Jul 26, 2023
7bf0bdd
Merge branch 'issue-2348-get-path-value' of github.com:chilagrow/Ferr…
chilagrow Jul 26, 2023
789bae3
some update
chilagrow Jul 26, 2023
2885c85
more comment
chilagrow Jul 27, 2023
76f0724
projection returns correct error code
chilagrow Jul 27, 2023
b31332f
fmt
chilagrow Jul 27, 2023
85f509d
Merge branch 'main' into issue-2348-get-path-value
chilagrow Jul 27, 2023
74d4fc1
path does not return error on $ prefix
chilagrow Jul 27, 2023
ca376f4
Revert "projection returns correct error code"
chilagrow Jul 27, 2023
8147dfe
add todo for fixing projection positional operator
chilagrow Jul 27, 2023
e2fc0ff
aggregation projection checks valid path
chilagrow Jul 27, 2023
bac5eeb
add todo
chilagrow Jul 27, 2023
9f19a76
fmt
chilagrow Jul 27, 2023
8a41dc4
Merge branch 'main' into issue-2348-get-path-value
chilagrow Jul 27, 2023
d7c16a0
Revert "aggregation projection checks valid path"
chilagrow Jul 28, 2023
7e49bd4
review comment
chilagrow Jul 28, 2023
3811585
renaming
chilagrow Jul 28, 2023
bc74089
test empty and space keys for insert and find
chilagrow Jul 28, 2023
1316e0c
Revert "test empty and space keys for insert and find"
chilagrow Jul 28, 2023
ea14b20
clean up
chilagrow Jul 28, 2023
b047e14
Merge branch 'main' into issue-2348-get-path-value
AlekSi Aug 1, 2023
e00bd95
update expression documentation
chilagrow Aug 1, 2023
9c4899c
Merge branch 'issue-2348-get-path-value' of github.com:chilagrow/Ferr…
chilagrow Aug 1, 2023
b706f91
update comment
chilagrow Aug 1, 2023
aa3fecd
Merge branch 'main' into issue-2348-get-path-value
chilagrow Aug 2, 2023
f2f0106
update expression comments
chilagrow Aug 2, 2023
b93ea91
more comments
chilagrow Aug 2, 2023
8b205c2
from pairing session
chilagrow Aug 2, 2023
7c0c76f
add more comments
chilagrow Aug 3, 2023
fd19a7a
more update of inline comments
chilagrow Aug 3, 2023
76a63cf
minor comment update
chilagrow Aug 3, 2023
307792e
resolve merge conflict
chilagrow Aug 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions internal/types/array.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/FerretDB/FerretDB/internal/util/must"
)

// Array represents BSON array.
// Array represents BSON array: an ordered collection of BSON values, accessed by 0-based indexes.
//
// Zero value is a valid empty array.
type Array struct {
Expand Down Expand Up @@ -52,7 +52,7 @@ func (a *Array) DeepCopy() *Array {
return deepCopy(a).(*Array)
}

// Len returns the number of elements in the array.
// Len returns the number of values in the array.
//
// It returns 0 for nil Array.
func (a *Array) Len() int {
Expand All @@ -76,7 +76,7 @@ func (a *Array) Get(index int) (any, error) {
return a.s[index], nil
}

// GetByPath returns a value by path - a sequence of indexes and keys.
// GetByPath returns a value by path.
func (a *Array) GetByPath(path Path) (any, error) {
return getByPath(a, path)
}
Expand Down Expand Up @@ -105,7 +105,7 @@ func (a *Array) Append(values ...any) {
a.s = append(a.s, values...)
}

// RemoveByPath removes document by path, doing nothing if the key does not exist.
// RemoveByPath removes (cuts) value by path, doing nothing if path points to nothing.
func (a *Array) RemoveByPath(path Path) {
removeByPath(a, path)
}
Expand Down Expand Up @@ -145,7 +145,7 @@ func (a *Array) Max() any {
}

// FilterArrayByType returns a new array which contains
// only elements of the same BSON type as ref.
// only values of the same BSON type as ref.
// All numbers are treated as the same type.
func (a *Array) FilterArrayByType(ref any) *Array {
refType := detectDataType(ref)
Expand Down
7 changes: 4 additions & 3 deletions internal/types/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ type document interface {
Values() []any
}

// Document represents BSON document.
// Document represents BSON document: an ordered collection of fields
// (key/value pairs where key is a string and value is any BSON value).
type Document struct {
fields []field
}
Expand Down Expand Up @@ -126,7 +127,7 @@ func (d *Document) DeepCopy() *Document {
return deepCopy(d).(*Document)
}

// Len returns the number of elements in the document.
// Len returns the number of fields in the document.
//
// It returns 0 for nil Document.
func (d *Document) Len() int {
Expand Down Expand Up @@ -308,7 +309,7 @@ func (d *Document) HasByPath(path Path) bool {
return err == nil
}

// GetByPath returns a value by path - a sequence of indexes and keys.
// GetByPath returns a value by path.
// If the Path has only one element, it returns the value for the given key.
func (d *Document) GetByPath(path Path) (any, error) {
return getByPath(d, path)
Expand Down