Skip to content

Refactor SQL Server code for calling stored procedures#6796

Merged
morozov merged 1 commit intodoctrine:4.3.xfrom
morozov:refactor-sql-server-comments
Feb 17, 2025
Merged

Refactor SQL Server code for calling stored procedures#6796
morozov merged 1 commit intodoctrine:4.3.xfrom
morozov:refactor-sql-server-comments

Conversation

@morozov
Copy link
Member

@morozov morozov commented Feb 17, 2025

I want to unify the SQL Server platform code for calling stored procedures. This is a backport of the backward-compatible part of the changes that I'm planning for 5.0.x:

  1. Instead of using string concatenation in every method that needs to execute a stored procedure, use SQLServerPlatform#getExecSQL().
  2. Instead of manually prepending N to national string literals, use SQLServerPlatform#quoteNationalStringLiteral().

Eventually, it will allow to get rid of the methods with the signatures like this:

* @param string $name The name of the property to add.
* @param string|null $value The value of the property to add.
* @param string|null $level0Type The type of the object at level 0 the property belongs to.
* @param string|null $level0Name The name of the object at level 0 the property belongs to.
* @param string|null $level1Type The type of the object at level 1 the property belongs to.
* @param string|null $level1Name The name of the object at level 1 the property belongs to.
* @param string|null $level2Type The type of the object at level 2 the property belongs to.
* @param string|null $level2Name The name of the object at level 2 the property belongs to.
*/
protected function getAddExtendedPropertySQL(
string $name,
?string $value = null,
?string $level0Type = null,
?string $level0Name = null,
?string $level1Type = null,
?string $level1Name = null,
?string $level2Type = null,
?string $level2Name = null,
): string {

They are just boilerplate that mimics the signatures of the corresponding stored procedures. They don't enforce the contract that the arguments need to be passed in pairs and can generate syntactically invalid SQL. For instance, here, if $level2Type is not null but $level2Name is:

($level2Type !== null || $level2Name !== null
? ', N' . $this->quoteStringLiteral($level2Type ?? '') . ', ' . $level2Name
: ''
);

@morozov morozov added this to the 4.3.0 milestone Feb 17, 2025
@morozov morozov marked this pull request as ready for review February 17, 2025 21:59
@morozov morozov requested a review from greg0ire February 17, 2025 21:59
@greg0ire
Copy link
Member

Refactor comment code in SQL Server platform

Sorry, what does this have to do with comments? Or did you mean to write "common"?

@morozov
Copy link
Member Author

morozov commented Feb 17, 2025

No, most of the affected methods (e.g. SQLServerPlatform#getAddExtendedPropertySQL) are used for managing table and column comments. Although, I guess, focusing on stored procedures in the subject would be more appropriate.

@morozov morozov force-pushed the refactor-sql-server-comments branch from c17f856 to 5906136 Compare February 17, 2025 22:30
@morozov morozov changed the title Refactor comment code in SQL Server platform Refactor SQL Server code for calling stored procedures Feb 17, 2025
@morozov morozov merged commit 113744f into doctrine:4.3.x Feb 17, 2025
67 checks passed
@morozov morozov deleted the refactor-sql-server-comments branch February 17, 2025 22:44
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants