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

Fix Laravel 9.31 breaking update #2452

Closed
wants to merge 1 commit into from
Closed

Fix Laravel 9.31 breaking update #2452

wants to merge 1 commit into from

Conversation

The-Hasanov
Copy link
Contributor

@The-Hasanov The-Hasanov commented Sep 22, 2022

Issue #2451

@codecov-commenter
Copy link

codecov-commenter commented Sep 22, 2022

Codecov Report

Base: 87.63% // Head: 87.65% // Increases project coverage by +0.01% 🎉

Coverage data is based on head (0cd90f8) compared to base (61cc6ed).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #2452      +/-   ##
============================================
+ Coverage     87.63%   87.65%   +0.01%     
- Complexity      677      678       +1     
============================================
  Files            31       31              
  Lines          1553     1555       +2     
============================================
+ Hits           1361     1363       +2     
  Misses          192      192              
Impacted Files Coverage Δ
src/Eloquent/Model.php 93.78% <100.00%> (+0.07%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@fosron
Copy link

fosron commented Sep 22, 2022

@The-Hasanov thank you for your solution 🙇

@Smolevich can we get this into a release soon? It's a breaking change for L9. Thanks 🙏

@driesvints
Copy link

Hi all. First of all apologies that things broke for this library. I'd like to know more about what happened here. Why are string keys incremental for MongoDB?

@The-Hasanov
Copy link
Contributor Author

The-Hasanov commented Sep 22, 2022

Hi all. First of all apologies that things broke for this library. I'd like to know more about what happened here. Why are string keys incremental for MongoDB?

Problem is here https://github.com/laravel/framework/blob/9.x/src/Illuminate/Database/Eloquent/Model.php#L1209
model not get string uuid after create

@driesvints
Copy link

Hi all. First of all apologies that things broke for this library. I'd like to know more about what happened here. Why are string keys incremental for MongoDB?

Problem is here https://github.com/laravel/framework/blob/9.x/src/Illuminate/Database/Eloquent/Model.php#L1209 model not get string uuid after create

Heya. I realize that but given it's a string based ID, the ID should be set as an attribute up front. Is MongoDB not doing that? How are ID's generated now?

@The-Hasanov
Copy link
Contributor Author

i don't know about technical side. But id or _id is generated on mongo side automatically. Also this id is unique and incremental.

@driesvints
Copy link

Thanks for that. I've sent in a PR to framework to revert this change: laravel/framework#44247

@alcaeus
Copy link
Member

alcaeus commented Sep 22, 2022

Is MongoDB not doing that? How are ID's generated now?

The MongoDB server will add an _id field and generate an ObjectId for it if a document being inserted does not contain one. In addition to that, the MongoDB driver for PHP will also create an ObjectId when inserting a document without an _id field. If an application wants to use a different key (e.g. a UUID), this has to be created on the application side before passing the document on to the driver.

@fosron
Copy link

fosron commented Sep 23, 2022

Thank you @driesvints 🙇‍♂️

@divine divine closed this Sep 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants