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

Add object functions #10

Closed
7 tasks done
ziflex opened this issue Sep 18, 2018 · 13 comments
Closed
7 tasks done

Add object functions #10

ziflex opened this issue Sep 18, 2018 · 13 comments
Labels
area/stdlib Standard library issue good first issue Good for newcomers type/enhancement New feature or request

Comments

@ziflex
Copy link
Member

ziflex commented Sep 18, 2018

  • KEYS(object, sort) → strArray
  • HAS(object, keyName) → isPresent
    LENGTH(object) → count (Implemented here)
  • MERGE(object1, object2, ... objectN) → newMergedObject
  • MERGE_RECURSIVE(object1, object2, ... objectN) → newMergedObject
  • VALUES(document, removeInternal) → anyArray
  • ZIP(keys, values) → newObj
  • KEEP(object, key1, key2, ... key) → newObj
@ziflex ziflex added type/enhancement New feature or request good first issue Good for newcomers area/stdlib Standard library issue labels Sep 18, 2018
@3timeslazy
Copy link
Member

I wanted to work on this issue. If there is any useful additional information - I will be glad to know it.

@ziflex
Copy link
Member Author

ziflex commented Oct 5, 2018

@3timeslazy great!

  1. Read the documentation
  2. Do not implement those methods that are related to ArangoDB Collections like IS_SAME_COLLECTION, PARSE_IDENTIFIER and etc.
  3. Do not mutate values itself - return only new instances.
  4. Here is an example how to create function. I will merge my work on Array functions, that will be even better reference.

Let's do the work in small chunks. 1 PR per function. It will be easier to review and track progress.

@3timeslazy
Copy link
Member

I understand correctly that function KEYS the same with ATTRIBUTES function from the doc?
https://docs.arangodb.com/3.4/AQL/Functions/Document.html#attributes
First of all, Im interesting in the sort argument. Does it have the same purpose?

@ziflex
Copy link
Member Author

ziflex commented Oct 6, 2018

@3timeslazy you are right. Pretty much the same. Go maps also do not guarantee consistent order, so the sort argument makes sense here.

@3timeslazy
Copy link
Member

link inside #10 (comment) is no longer valid.

@ziflex
Copy link
Member Author

ziflex commented Oct 7, 2018

@3timeslazy updated.

ziflex added a commit that referenced this issue Oct 7, 2018
@3timeslazy
Copy link
Member

Question about the MERGE function. The documentation supports 2 function signatures:

  1. MERGE(object1, object2, ... objectN) → mergedObject
  2. MERGE(objArray) → mergedObject

In this case need to implement only one (1th signature) or both?

@ziflex
Copy link
Member Author

ziflex commented Oct 7, 2018

@3timeslazy let's implement both.
Just do a check for a type when you deal with an array.
Which means if any of an array elements is not an object - return None.

Here is ArangoDB's behavior.
screenshot 2018-10-07 18 06 54

@3timeslazy
Copy link
Member

3timeslazy commented Oct 7, 2018

@ziflex OK no problem :)

ziflex pushed a commit that referenced this issue Oct 13, 2018
* added prototype of ZIP function

* add unit test for ZIP function

* change comment for ZIP function

* added some new tests

* small change in unit tests

* added ZIP function
3timeslazy referenced this issue in 3timeslazy/ferret Oct 14, 2018
@3timeslazy
Copy link
Member

Question about VALUES function. There is optional parameter removeInternal into the doc that responsible for the internal keys (they start with _, such as _id, _key etc.). It is necessary to implement it or not?

@ziflex
Copy link
Member Author

ziflex commented Oct 14, 2018

Nope, our objects do not have these properties. They are ArangoDB collections related.

@3timeslazy
Copy link
Member

How AQL works?
1th query
screenshot 2018-10-15 at 02 49 04
2th query
screenshot 2018-10-15 at 02 48 45
3th query
screenshot 2018-10-15 at 02 47 45

@ziflex
Copy link
Member Author

ziflex commented Oct 15, 2018

Looks good. Ferret has some differences in how it works.
And one of them is that RETURN statement in FQL returns expression result as it is.
Contrary to that,RETURN statement in AQL returns an expression result in array.

Maybe it was not a good decision to change the behavior but that’s how it is now.

3timeslazy referenced this issue in 3timeslazy/ferret Oct 22, 2018
ziflex pushed a commit that referenced this issue Oct 22, 2018
* added VALUES function
* updated object.Compare
ziflex pushed a commit that referenced this issue Oct 25, 2018
@ziflex ziflex closed this as completed Oct 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/stdlib Standard library issue good first issue Good for newcomers type/enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants