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 5376 improve the select query #287

Closed

Conversation

faisalill
Copy link
Contributor

No description provided.

@faisalill
Copy link
Contributor Author

faisalill commented Jul 10, 2023

@fogelito can you review this PR please.

Copy link
Contributor

@TorstenDittmann TorstenDittmann left a comment

Choose a reason for hiding this comment

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

starting CI now as well 👍🏻

src/Database/Database.php Outdated Show resolved Hide resolved
@faisalill faisalill marked this pull request as draft July 18, 2023 18:31
src/Database/Database.php Outdated Show resolved Hide resolved
src/Database/Database.php Outdated Show resolved Hide resolved
src/Database/Database.php Outdated Show resolved Hide resolved
Combine $createdAt and $updatedAt to in_array
Use static internal parameteres array rather than $stringToRemove
src/Database/Database.php Outdated Show resolved Hide resolved
src/Database/Adapter/MariaDB.php Outdated Show resolved Hide resolved
src/Database/Adapter/MariaDB.php Show resolved Hide resolved
Comment on lines 1335 to 1336
$projection['_createdAt'] = 1;
$projection['_updatedAt'] = 1;
Copy link
Member

Choose a reason for hiding this comment

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

We need to make sure these are not set by default the same as maraidb

Copy link
Contributor Author

@faisalill faisalill Jul 26, 2023

Choose a reason for hiding this comment

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

Except _collection and _id rest have to be set because.

Copy link
Member

Choose a reason for hiding this comment

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

Can we make it so that they are not required at this point? I think we should be able to if we can do it for MariaDB

Copy link
Contributor Author

@faisalill faisalill Jul 27, 2023

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@faisalill faisalill Jul 27, 2023

Choose a reason for hiding this comment

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

For Postgres I am querying all the internal attributes and if any internal attribute is in the query I am removing it from selection then before the document is returned I check which internal attributes were in the query and only keep those internal attributes in the document.
But for all the adapters internal attributes won't be returned. Unless queried specificly.
https://github.com/faisalill/database/blob/feat-5376-improve-the-select-query/tests/Database/Base.php#L1042
All these tests work fine.
It's a mess ik.
I will close this PR start from scratch and update u on the same.

src/Database/Database.php Outdated Show resolved Hide resolved
src/Database/Adapter/Postgres.php Outdated Show resolved Hide resolved
src/Database/Database.php Outdated Show resolved Hide resolved
src/Database/Database.php Outdated Show resolved Hide resolved
foreach ($queries as $query) {
if ($query->getMethod() === Query::TYPE_SELECT) {
foreach ($results as $result) {
foreach (Database::INTERNAL_PARAMETERS as $parameter) {
Copy link
Member

Choose a reason for hiding this comment

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

This will remove internal attributes even if they were selected, we need to make sure they are only removed when not selected

Let's add a test to cover this case as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://github.com/faisalill/database/blob/feat-5376-improve-the-select-query/tests/Database/Base.php#L1042

Tests here check whether only the queried internal attribute is returned.

src/Database/Database.php Outdated Show resolved Hide resolved
$this->assertArrayNotHasKey('$collection', $document);
$this->assertArrayNotHasKey('$createdAt', $document);
$this->assertArrayNotHasKey('$updatedAt', $document);
$this->assertArrayNotHasKey('$permissions', $document);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Let's add a test for the find method when selecting internal attributes

@faisalill
Copy link
Contributor Author

I will close this PR start from scratch and update u guys on the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants