Skip to content

# Micro ORM 6.0 - Major Release #25

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

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open

# Micro ORM 6.0 - Major Release #25

wants to merge 24 commits into from

Conversation

byjg
Copy link
Owner

@byjg byjg commented Mar 24, 2025

This PR introduces version 6.0 of the Micro ORM with significant improvements and breaking changes. The update aligns with the AnyDataset-DB 6.0 release and includes structural changes to improve code quality and maintainability.

Major Changes

  • Updated dependencies to support PHP 8.1 through 8.4
  • Upgraded to use AnyDataset-DB 6.0
  • Replaced SqlObject by SqlStatement from AnyDataset-DB
  • Refactored UpdateConstraint system to use interfaces
  • Added new property handlers for better data mapping
  • Updated query building system to use SqlStatement directly
  • Implemented PHP 8.1+ features including attributes and the Override attribute
  • Added the CustomConstraint and RequireChangedValuesConstraint classes
  • Improved documentation throughout the codebase

Breaking Compatibility Changes

Component Change Impact
Dependencies Updated to AnyDataset-DB 6.0 Projects using older versions need to upgrade
Dependencies Updated PHPUnit to 10.5/11.5 Test suites may need adjustments
Repository::save() Changed UpdateConstraint parameter to UpdateConstraintInterface Code using UpdateConstraint needs to be updated
SqlObject Removed class, replaced by SqlStatement Any direct usage of SqlObject must be updated
SqlObjectEnum Removed class Code using SqlObjectEnum must be updated
Database calls Now passing SqlStatement objects directly Custom extensions need updates
UpdateConstraint Class replaced by interface and implementations Code using UpdateConstraint needs to be updated
AllowOnlyNewValuesConstraintException Replaced by RequireChangedValuesConstraintException Exception handling code needs updates

New Features

  • Introduction of the UpdateConstraintInterface
  • New PropertyHandler classes for mapping data
  • Support for PHP 8.4
  • Added RequireChangedValuesConstraint and CustomConstraint
  • Enhanced error reporting and validation

Migration Guide

  1. Update your dependencies to use AnyDataset-DB 6.0
  2. Replace any direct usage of SqlObject with SqlStatement
  3. Update constraint usage to implement or use the new UpdateConstraintInterface
  4. Review exception handling for constraint validation
  5. Update any custom database execution code to handle SqlStatement objects

This release significantly improves the architecture while maintaining the core functionality and simplicity of the Micro ORM library.

Description by Korbit AI

What change is being made?

Introduce Micro ORM 6.0 with support for PHP 8.4, updated dependencies, enhanced documentation, and new features including custom update constraints, UUID primary key support, and enhanced query capabilities.

Why are these changes being made?

This major release aims to align the codebase with newer PHP versions and improve ORM functionality with more robust querying capabilities and custom update constraints. Enhancements to the documentation and minor code refactoring provide clearer guidelines for users and support seamless integration. The inclusion of test updates ensures comprehensive validation of the new features and changes.

Is this description stale? Ask me to generate a new description by commenting /korbit-generate-pr-description

Copy link

@korbit-ai korbit-ai bot left a comment

Choose a reason for hiding this comment

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

Review by Korbit AI

Korbit automatically attempts to detect when you fix issues in new commits.
Category Issue Status
Performance Redundant Field Mapping Storage ▹ view ✅ Fix detected
Functionality Database Values Override Issue ▹ view
Functionality Missing null check for dbDriver in buildAndGetIterator ▹ view
Performance Multiple Sequential Mapper Lookups ▹ view
Design Duplicate Method Existence Validation ▹ view
Error Handling Missing Exception Context ▹ view
Files scanned
File Path Reviewed
src/Exception/RequireChangedValuesConstraintException.php
src/Interface/UpdateConstraintInterface.php
src/Interface/UpdateBuilderInterface.php
src/Interface/QueryBuilderInterface.php
src/ORMHelper.php
src/Literal/Literal.php
src/Updatable.php
src/Constraint/CustomConstraint.php
src/DeleteQuery.php
src/PropertyHandler/PrepareToUpdateHandler.php
src/Recursive.php
src/Constraint/RequireChangedValuesConstraint.php
src/PropertyHandler/MapFromDbToInstanceHandler.php
src/WhereTrait.php
src/InsertQuery.php
src/Union.php
src/InsertSelectQuery.php
src/InsertBulkQuery.php
src/UpdateQuery.php
src/Query.php
src/QueryBasic.php
src/Mapper.php
src/Repository.php

Explore our documentation to understand the languages and file types we support and the files we ignore.

Need a new review? Comment /korbit-review on this PR and I'll review your latest changes.

Korbit Guide: Usage and Customization

Interacting with Korbit

  • You can manually ask Korbit to review your PR using the /korbit-review command in a comment at the root of your PR.
  • You can ask Korbit to generate a new PR description using the /korbit-generate-pr-description command in any comment on your PR.
  • Too many Korbit comments? I can resolve all my comment threads if you use the /korbit-resolve command in any comment on your PR.
  • On any given comment that Korbit raises on your pull request, you can have a discussion with Korbit by replying to the comment.
  • Help train Korbit to improve your reviews by giving a 👍 or 👎 on the comments Korbit posts.

Customizing Korbit

  • Check out our docs on how you can make Korbit work best for you and your team.
  • Customize Korbit for your organization through the Korbit Console.

Feedback and Support

if (count($this->getFieldMap()) > 0) {
ObjectCopy::copy($fieldValues, $instance);
}
$fieldValues = array_merge(Serialize::from($instance)->toArray(), $fieldValues);
Copy link

Choose a reason for hiding this comment

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

Database Values Override Issue category Functionality

Tell me more
What is the issue?

The array_merge operation in getEntity() overrides database values with empty instance values instead of the other way around

Why this matters

This will cause database-loaded values to be overwritten by default/empty values from the newly created instance, effectively nullifying the database data.

Suggested change ∙ Feature Preview

Reverse the array_merge parameters to prioritize database values over instance values:

$fieldValues = array_merge($fieldValues, Serialize::from($instance)->toArray());
Provide feedback to improve future suggestions

Nice Catch Incorrect Not in Scope Not in coding standard Other

💬 Looking for more details? Reply to this comment to chat with Korbit.

Comment on lines +7 to +10
class RequireChangedValuesConstraintException extends Exception
{

}
Copy link

Choose a reason for hiding this comment

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

Missing Exception Context category Error Handling

Tell me more
What is the issue?

The RequireChangedValuesConstraintException class is empty without any custom message or error code, making it difficult to identify the specific error condition when caught.

Why this matters

When this exception is thrown, developers catching it won't have context about what went wrong with the changed values constraint, leading to poor error handling and debugging experience.

Suggested change ∙ Feature Preview

Add a default constructor with a meaningful error message:

class RequireChangedValuesConstraintException extends Exception
{
    public function __construct(string $message = "Update operation requires at least one changed value", int $code = 0, ?Throwable $previous = null)
    {
        parent::__construct($message, $code, $previous);
    }
}
Provide feedback to improve future suggestions

Nice Catch Incorrect Not in Scope Not in coding standard Other

💬 Looking for more details? Reply to this comment to chat with Korbit.

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.

1 participant