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

feat: Add alias to groupBy related object #1579

Merged
merged 9 commits into from
Jun 20, 2023

Conversation

shahzadlone
Copy link
Member

@shahzadlone shahzadlone commented Jun 15, 2023

Resolves #1578
Resolves #1551
Part-of: #1279

Description

  • Add some tests of existing object_id functionality.
  • Add implementation for groupBy alias.
  • Add tests for groupBy alias ability.
  • Fix the previous panic using alias, with more user friendly error.
  • Add tests for panic fix.
  • Make a const for _id.
  • Schema Test to ensure the field we want to alias exists (even though it actually existed from before)

For Reviewers

  • Commit by commit review should be clean.
  • PR(MAIN): commit needs the most attention.
  • Happy to add more tests if you can think of any cases.
  • Happy to remove tests if I introduced any duplicates.

Tasks

  • I made sure the code is well commented, particularly hard-to-understand areas.
  • I made sure the repository-held documentation is changed accordingly.
  • I made sure the pull request title adheres to the conventional commit style (the subset used in the project can be found in tools/configs/chglog/config.yml).
  • I made sure to discuss its limitations such as threats to validity, vulnerability to mistake and misuse, robustness to invalidation of assumptions, resource requirements, ...

How has this been tested?

Integration Tests

Specify the platform(s) on which this was tested:

  • Manjaro/Arch WSL2

@shahzadlone shahzadlone added feature New feature or request area/testing Related to any test or testing suite priority/high labels Jun 15, 2023
@shahzadlone shahzadlone added this to the DefraDB v0.6 milestone Jun 15, 2023
@shahzadlone shahzadlone self-assigned this Jun 15, 2023
@codecov
Copy link

codecov bot commented Jun 15, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.02 🎉

Comparison is base (be619fd) 73.47% compared to head (ff9c480) 73.50%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1579      +/-   ##
===========================================
+ Coverage    73.47%   73.50%   +0.02%     
===========================================
  Files          187      188       +1     
  Lines        19291    19320      +29     
===========================================
+ Hits         14174    14200      +26     
- Misses        4069     4071       +2     
- Partials      1048     1049       +1     
Flag Coverage Δ
all-tests 73.50% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
client/request/select.go 100.00% <100.00%> (ø)
db/collection_update.go 72.91% <100.00%> (+0.13%) ⬆️
planner/mapper/errors.go 100.00% <100.00%> (ø)
planner/mapper/mapper.go 86.63% <100.00%> (+0.32%) ⬆️
planner/type_join.go 74.87% <100.00%> (ø)

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update be619fd...ff9c480. Read the comment docs.

@shahzadlone shahzadlone requested a review from a team June 15, 2023 19:22
Copy link
Collaborator

@fredcarle fredcarle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good Shahzad. I'm just wondering about the author_id being returned in the results without it being requested in the query. Was this behavious previously the same? In my mind that would be a bug.

@AndrewSisley
Copy link
Contributor

Changes look good Shahzad. I'm just wondering about the author_id being returned in the results without it being requested in the query. Was this behavious previously the same? In my mind that would be a bug

I think that is also against the GQL spec, IIRC only (and all) fields requested must be returned.

@shahzadlone
Copy link
Member Author

Changes look good Shahzad. I'm just wondering about the author_id being returned in the results without it being requested in the query. Was this behavious previously the same? In my mind that would be a bug.

I thought it was odd too and against the spec, but I am pretty sure that is the default behavior that already existed.

For example:

query {
	Users(groupBy: [Name]) {
		_group {
			Age
		}
	}
}

Would probably give:

[
	{
		{
			"Name": ...
			"_group": [
				{
					{
						"Age": ...
					}
					...
					{
						"Age": ...
					}
				]
			}
		}
		...
		{
			"Name": ...
			"_group": [
				{
					{
						"Age": ...
					}
					...
					{
						"Age": ...
					}
				]
			}
		}
	}
]

@shahzadlone
Copy link
Member Author

shahzadlone commented Jun 16, 2023

I will add a test case to confirm the behavior.

I think that is also against the GQL spec, IIRC only (and all) fields requested must be returned.

Can create an issue if this wasn't intentional for some thought-out reason.

@shahzadlone shahzadlone requested review from fredcarle and a team June 16, 2023 22:43
Copy link
Collaborator

@fredcarle fredcarle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I opened an issue so we can come back to fixing the inconsistency with the specs #1582

Thanks for adding the test. Maybe before merging, it would be nice to add a statement in the test that states that this is not wanted behaviour.

@shahzadlone shahzadlone merged commit e082fe1 into sourcenetwork:develop Jun 20, 2023
11 checks passed
@shahzadlone shahzadlone deleted the feat/alias-object-id branch June 20, 2023 21:16
@shahzadlone shahzadlone mentioned this pull request Jan 9, 2024
4 tasks
shahzadlone added a commit to shahzadlone/defradb that referenced this pull request Feb 23, 2024
Resolves sourcenetwork#1578
Resolves sourcenetwork#1551
Part-of: sourcenetwork#1279

## Description
- Add some tests of existing object_id functionality.
- Add implementation for groupBy alias.
- Add tests for groupBy alias ability.
- Fix the previous panic using alias, with more user friendly error.
- Add tests for panic fix.
- Make a const for `_id`.
- Schema Test to ensure the field we want to alias exists (even though
it actually existed from before)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/testing Related to any test or testing suite feature New feature or request priority/high
Projects
None yet
3 participants