Skip to content

feat(database): Add replacements for deprecated fetch and fetchAll - #40655

Closed
ChristophWurst wants to merge 6 commits into
masterfrom
feat/database/query-result-fetch-associative-fetch-num
Closed

feat(database): Add replacements for deprecated fetch and fetchAll#40655
ChristophWurst wants to merge 6 commits into
masterfrom
feat/database/query-result-fetch-associative-fetch-num

Conversation

@ChristophWurst

@ChristophWurstChristophWurst commented Sep 27, 2023

Copy link
Copy Markdown
Member

Summary

DBAL deprecated these and will remove them it in the future.

TODO

  • Add missing methods
  • Delegate deprecations

Checklist

DBAL deprecated these and will remove them it in the future.
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
…hAll
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
@ChristophWurstChristophWurst added the pending documentation This pull request needs an associated documentation update label Sep 27, 2023
Comment threadlib/private/DB/ResultAdapter.php Fixed
Comment threadlib/private/DB/ResultAdapter.php Fixed
Comment threadlib/public/DB/IResult.php Outdated
*
* @since 21.0.0
*/
public function fetchFirstColumn(): array;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should be mixed?

@ChristophWurstChristophWurstOct 5, 2023

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

it returns the first column of all results as array<mixed>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The description is not phrased clearly about that imo, and for better consistency perhaps consider renaming the method to fetchAllFirstColumns or something like that?

Comment threadlib/public/DB/IResult.php Outdated
Comment threadlib/public/DB/IResult.php Outdated
* @return mixed
*
* @since 21.0.0
* @deprecated 28.0.0 use fetchAssociative, fetchNumeric or fetchOne

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This will be painful :D
Touching all the queries yet again (after query() replacement)

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also use the deprecation line from the docs here explaining the default replacement?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@ChristophWurst Out of context, but I'm just curious to know if there are any plans to introduce Rector to the project. Now that I've touched a bit of code from different parts of the code base, I think it would be a great addition to the mix if we could make everything more consistent across the code base by using an automated refactoring approach with Rector.

…hAll
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Comment threadlib/public/DB/IResult.php Outdated
…hAll
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
…hAll
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
* @return mixed
*
* @since 21.0.0
* @deprecated 28.0.0 use fetchAssociative instead of fetch(), fetchNumeric instead of fetch(\PDO::FETCH_NUM) and fetchOne instead of fetch(\PDO::FETCH_COLUMN)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
* @deprecated 28.0.0usefetchAssociative instead of fetch(), fetchNumeric instead of fetch(\PDO::FETCH_NUM) and fetchOne instead of fetch(\PDO::FETCH_COLUMN)
* @deprecated 28.0.0usefetchAssociative instead of fetch(), fetchNumeric() instead of fetch(\PDO::FETCH_NUM) and fetchOne() instead of fetch(\PDO::FETCH_COLUMN)

🤪

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

and more brackets for lonely fetchAssociative!

* @return mixed[]
*
* @since 21.0.0
* @deprecated 28.0.0 use fetchAllAssociative instead of fetchAll(), fetchAllNumeric instead of fetchAll(FETCH_NUM) and fetchOne instead of fetchAll(FETCH_COLUMN)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
* @deprecated 28.0.0usefetchAllAssociative instead of fetchAll(), fetchAllNumeric instead of fetchAll(FETCH_NUM) andfetchOne instead of fetchAll(FETCH_COLUMN)
* @deprecated 28.0.0usefetchAllAssociative instead of fetchAll(), fetchAllNumeric() instead of fetchAll(FETCH_NUM) andfetchFirstColumn() instead of fetchAll(FETCH_COLUMN)

🤪

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

I'm tired, boss

@solracsfsolracsf added this to the Nextcloud 28 milestone Oct 27, 2023
@skjnldsvskjnldsv mentioned this pull request Nov 1, 2023
@ChristophWurstChristophWurst added 0. Needs triage Pending check for reproducibility or if it fits our roadmap and removed 3. to review Waiting for reviews labels Nov 2, 2023
@ChristophWurst
ChristophWurst marked this pull request as draft November 2, 2023 10:08
@ChristophWurstChristophWurst removed this from the Nextcloud 28 milestone Nov 2, 2023
@solracsfsolracsf added this to the Nextcloud 28 milestone Nov 21, 2023
@blizzzblizzz mentioned this pull request Nov 22, 2023
5 tasks
@ChristophWurstChristophWurst removed this from the Nextcloud 28 milestone Nov 22, 2023
@blizzzblizzz added this to the Nextcloud 29 milestone Nov 23, 2023
@skjnldsvskjnldsv added 2. developing Work in progress and removed 0. Needs triage Pending check for reproducibility or if it fits our roadmap labels Feb 21, 2024
This was referenced Mar 12, 2024
@AltahrimAltahrim mentioned this pull request Mar 20, 2024
@blizzzblizzz modified the milestones: Nextcloud 31, Nextcloud 32Jan 29, 2025
@blizzzblizzz modified the milestones: Nextcloud 33, Nextcloud 34Feb 16, 2026
@ChristophWurst

Copy link
Copy Markdown
MemberAuthor

Superseded by #56494

@ChristophWurst
ChristophWurst deleted the feat/database/query-result-fetch-associative-fetch-num branch May 20, 2026 19:04
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2. developingWork in progresspending documentationThis pull request needs an associated documentation update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

@ChristophWurst@nickvergessen@blizzz@fsamapoor@github-advanced-security@joshtrichards@solracsf@skjnldsv