Skip to content

Conversation

@riesjart
Copy link
Contributor

@riesjart riesjart commented Nov 16, 2025

The new Eloquent Factory::insert() method currently instantiates and fills a model twice for every record, which I think seems inefficient. More importantly it unnecessarily casts raw attribute values back and forth to eventually insert them, which I think is an anti-pattern.

One of the issues this causes has been pointed out here. This PR aims to fix this issue of double quoting of array casted JSON columns, as an alternative to #57794.

@github-actions
Copy link

Thanks for submitting a PR!

Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

* @return array
*/
protected function getAttributesForInsert()
public function getAttributesForInsert()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made public so it can be called from the factory for clarity.

Copy link
Contributor

Choose a reason for hiding this comment

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

These would be breaking changes if anyone happened to extend these classes and modify the functions, no? Might have to target master in that case.

@riesjart riesjart marked this pull request as ready for review November 16, 2025 21:34
@taylorotwell
Copy link
Member

Will try @cosmastech's fix since it's non-breaking. Thanks. 🙏

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.

3 participants