Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Serializer] Deprecate CsvEncoder as_collection false default value #27715

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
merged 1 commit into from
Jun 30, 2018
Merged

[Serializer] Deprecate CsvEncoder as_collection false default value #27715

merged 1 commit into from
Jun 30, 2018

Conversation

ogizanagi
Copy link
Contributor

@ogizanagi ogizanagi commented Jun 25, 2018

Q A
Branch? master
Bug fix? no
New feature? no
BC breaks? no
Deprecations? yes
Tests pass? yes
Fixed tickets N/A
License MIT
Doc PR N/A

As already expressed in #25369 and related issues, this behavior is quite counter-intuitive. It may be fine for write-API with a single document in the body but I think such CSV APIs are way less common than file-based ones, expecting collections. So I think this behavior should be opt-in explicitly in required cases, always dealing with collections by default.
This is still an arbitrary decision, but trying to make it based on use-cases and user's experience with CSV.

Note: perhaps we could find a better name for this as the semantic of setting as_collection to false to get the single row directly would not be really obvious.
Also, it could throw an exception when getting multiple rows where only one was expected.

@nicolas-grekas
Copy link
Member

(rebase needed)

@ogizanagi
Copy link
Contributor Author

Rebased

fabpot
fabpot previously requested changes Jun 30, 2018
UPGRADE-4.2.md Outdated
--------------

* The `lazy` attribute on `doctrine.event_listener` tags was removed.
Listeners are now lazy by default. So any `lazy` attributes can safely be removed from those tags.
Copy link
Member

Choose a reason for hiding this comment

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

Does not seem related to this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, indeed. It's just to respect the alpha order we use on UPGRADE files.
I can do another PR if you want, but IIRC we already accepted such changes inside unrelated PRs in the past.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See #27781

@ogizanagi ogizanagi dismissed fabpot’s stale review June 30, 2018 08:40

Unrelated changed reverted :)

@fabpot
Copy link
Member

fabpot commented Jun 30, 2018

Thank you @ogizanagi.

@fabpot fabpot merged commit bce59c8 into symfony:master Jun 30, 2018
fabpot added a commit that referenced this pull request Jun 30, 2018
…default value (ogizanagi)

This PR was merged into the 4.2-dev branch.

Discussion
----------

[Serializer] Deprecate CsvEncoder as_collection false default value

| Q             | A
| ------------- | ---
| Branch?       | master <!-- see below -->
| Bug fix?      | no
| New feature?  | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | yes <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | N/A   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | N/A

As already expressed in #25369 and related issues, this behavior is quite counter-intuitive. It may be fine for write-API with a single document in the body but I think such CSV APIs are way less common than file-based ones, expecting collections. So I think this behavior should be opt-in explicitly in required cases, always dealing with collections by default.
This is still an arbitrary decision, but trying to make it based on use-cases and user's experience with CSV.

Note: perhaps we could find a better name for this as the semantic of setting `as_collection` to `false` to get the single row directly would not be really obvious.
Also, it could throw an exception when getting multiple rows where only one was expected.

Commits
-------

bce59c8 [Serializer] Deprecate CsvEncoder as_collection false default value
@ogizanagi ogizanagi deleted the serializer/deprecate_as_collection_false_default branch June 30, 2018 09:28
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.2 Nov 1, 2018
This was referenced Nov 3, 2018
nicolas-grekas added a commit that referenced this pull request May 29, 2019
…on & change default value (ogizanagi)

This PR was merged into the 5.0-dev branch.

Discussion
----------

[Serializer] Remove CsvEncoder "as_collection" deprecation & change default value

| Q             | A
| ------------- | ---
| Branch?       | master <!-- see below -->
| Bug fix?      | no
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes  (AppVeyor failure unrelated. See https://github.com/symfony/symfony/pull/31685/files)  <!-- please add some, will be required by reviewers -->
| Fixed tickets | #27715   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | N/A <!-- required for new features -->

As planned in #27715

Commits
-------

22dd071 [Serializer] Remove CsvEncoder "as_collection" deprecation & change default value
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