Skip to content

Conversation

simon-mundy
Copy link
Collaborator

@simon-mundy simon-mundy commented Apr 28, 2025

This is a major update to the Laminas\Db\Sql components, working specifically on the following refactoring:-

  • Ability to pass SQL Literals, Values and Identifiers as live classes instead of lookup arrays for cleaner code and better durability
  • Ability to programmatically add SQL specifications to Predicate parts as well as Ddl components
  • Ability to store and manipulate SQL specifications in new ExpressionPart and ExpressionData containers
  • Standardise SQL generation
  • Refactor Unit Tests for all classes involved
  • The new Argument class handle the strict typing of types (using the ArgumentType Enum) and introduces static convenience methods to quickly generate each of the different types.

The new ExpressionPart allows a string specification (e.g. %s LIKE %s) as well as storing Argument values. This new storage container makes typing these values more robust and more flexible.

The ExpressionData container takes 1 or more ExpressionPart components and generates a space-delimited SQL string as required.

NOTE: Please ignore Rector files, the Rector requirement in composer.json and the temporary change in PHP to 8.3 - this is only for the convenience of using dev tools and will be reverted back to 8.1 in due course.

@simon-mundy simon-mundy self-assigned this Apr 28, 2025
@simon-mundy simon-mundy added enhancement New feature or request qa Improvements in quality assurance of the project Lang Feature Refactor Refactoring to new language features labels Apr 28, 2025
@simon-mundy simon-mundy added this to the 3.0.0 milestone Apr 28, 2025
…tion

# Conflicts:
#	test/integration/Platform/MysqlFixtureLoader.php
#	test/unit/Sql/Predicate/NotBetweenTest.php
#	test/unit/Sql/SelectTest.php
#	test/unit/TableGateway/Feature/MasterSlaveFeatureTest.php
@@ -61,7 +62,7 @@ public function __construct(

if (is_array($driver)) {
$parameters = $driver;
if ($profiler === null && isset($parameters['profiler'])) {
if (!$profiler instanceof \Laminas\Db\Adapter\Profiler\ProfilerInterface && isset($parameters['profiler'])) {
Copy link
Member

Choose a reason for hiding this comment

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

Is this not a violation of the coding standard?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In what way?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Also... this is being rewritten anyway isn't it?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, so its going to be a conflict that needs resolved either way.

The coding standard requires use statements vs fully qualified paths iirc. I'm pretty sure that was a Rector change which is the only reason I was pointing it out.

*/
public function getLastGeneratedValue($name = null)
#[Override] public function getLastGeneratedValue($name = null): string|null
Copy link
Collaborator

Choose a reason for hiding this comment

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

Didn't we have a discussion last week or so about nullable return types being, for example, ?string.

@@ -250,7 +243,7 @@ private function createErrorHandler()
* @throws ErrorException if error is not within the error_reporting mask.
*/
return function ($errno, $errstr, $errfile, $errline) {
if (! (error_reporting() & $errno)) {
if ((error_reporting() & $errno) === 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could a constant be used here, instead of 0?

) {
$this->isBuffered = true;
}
} elseif ($resource instanceof mysqli || $resource instanceof mysqli_result
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it be worth splitting the conditions across multiple lines so that they're that much easier to read?

Copy link
Collaborator

@settermjd settermjd left a comment

Choose a reason for hiding this comment

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

Just a few small things stood out for me, mate.

@tyrsson tyrsson linked an issue Jun 11, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Lang Feature Refactor Refactoring to new language features qa Improvements in quality assurance of the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Possible issue with Join
3 participants