Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

PHPORM-215 Implement Schema::getColumns and getIndexes #3045

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

Merged
GromNaN merged 4 commits into mongodb:4.7 from GromNaN:PHPORM-215
Jul 16, 2024

Conversation

@GromNaN
Copy link
Member

@GromNaN GromNaN commented Jul 15, 2024

Fix PHPORM-215

This method is used by the command db:table:

Example of output:

php artisan db:table --database=mongodb users
 users ............................................................................................................. 
 Columns ......................................................................................................... 8 
 Size ..................................................................................................... 60.00 KB 
 Column ....................................................................................................... Type 
 _id objectId ............................................................................................. objectId 
 created_at date, nullable .................................................................................... date 
 email string, nullable ..................................................................................... string 
 email_verified_at date, nullable ............................................................................. date 
 name string, nullable ...................................................................................... string 
 password string, nullable .................................................................................. string 
 remember_token string, nullable ............................................................................ string 
 updated_at date, nullable .................................................................................... date 
 Index ............................................................................................................. 
 _id_ _id ......................................................................................... default, primary 
 email_1 email ..................................................................................... default, unique 

Checklist

  • Add tests and ensure they pass
  • Add an entry to the CHANGELOG.md file
  • Update documentation for new features

masterbater and hafezdivandari reacted with hooray emoji
@GromNaN GromNaN requested a review from a team as a code owner July 15, 2024 14:18
@GromNaN GromNaN requested a review from alcaeus July 15, 2024 14:18
return $collections;
}

public function getColumns($table)
Copy link
Member

Choose a reason for hiding this comment

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

This method could get slow for larger collections, so it may be worth adding a $sample pipeline stage down the road.

Depending on how much the feature is used, we can also consider expanding its functionality in a separate project to be more similar to Compass' schema analysis feature. For now, the current solution provides a good starting point.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think we should try to replicate what is done by Compass. I added $sample and $limit stages.

alcaeus reacted with thumbs up emoji
Copy link
Member Author

@GromNaN GromNaN Jul 16, 2024
edited
Loading

Choose a reason for hiding this comment

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

I tried on atlas sample dataset sample_airbnb.listingsAndReviews. With $sample, I get this error:

 PlanExecutor error during aggregation :: caused by :: Sort exceeded memory limit of 33554432 bytes, but did not opt in to external sorting. Aborting operation. Pass allowDiskUse:true to opt in.

It works without it. There might be an optimization on the server for this use-case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@alcaeus alcaeus alcaeus approved these changes

Assignees

No one assigned

Labels

Projects

None yet

Milestone

4.7

Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /