diff --git a/.github/.commitlint.config.mjs b/.github/.commitlint.config.mjs new file mode 100644 index 00000000..fcc475c4 --- /dev/null +++ b/.github/.commitlint.config.mjs @@ -0,0 +1,43 @@ +// More info: https://github.com/wayofdev/npm-shareable-configs/blob/master/packages/commitlint-config/src/index.js +const automaticCommitPattern = /^chore\(release\):.*\[skip ci]/ + +export default { + extends: ['@commitlint/config-conventional'], + /* + This resolves a linting conflict between commitlint's body-max-line-length + due to @semantic-release/git putting release notes in the commit body + https://github.com/semantic-release/git/issues/331 + */ + ignores: [(commitMessage) => automaticCommitPattern.test(commitMessage)], + rules: { + 'body-leading-blank': [1, 'always'], + 'body-max-line-length': [2, 'always', 100], + 'footer-leading-blank': [1, 'always'], + 'footer-max-line-length': [2, 'always', 100], + 'header-max-length': [2, 'always', 100], + 'scope-case': [2, 'always', 'lower-case'], + 'subject-case': [2, 'never', ['sentence-case', 'start-case', 'pascal-case', 'upper-case']], + 'subject-empty': [2, 'never'], + 'subject-full-stop': [2, 'never', '.'], + 'type-case': [2, 'always', 'lower-case'], + 'type-empty': [2, 'never'], + 'type-enum': [ + 2, + 'always', + [ + 'feat', + 'fix', + 'perf', + 'docs', + 'style', + 'deps', + 'refactor', + 'ci', + 'test', + 'revert', + 'build', + 'chore', + ], + ], + }, +} diff --git a/.github/.release-please-config.json b/.github/.release-please-config.json new file mode 100644 index 00000000..db09ae86 --- /dev/null +++ b/.github/.release-please-config.json @@ -0,0 +1,83 @@ +{ + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", + "release-type": "node", + "include-component-in-tag": false, + "packages": { + ".": { + "package-name": "database", + "changelog-path": "/CHANGELOG.md" + } + }, + "changelog-sections": [ + { + "type": "feat", + "section": "Features", + "hidden": false + }, + { + "type": "fix", + "section": "Bug Fixes", + "hidden": false + }, + { + "type": "perf", + "section": "Performance Improvements", + "hidden": false + }, + { + "type": "docs", + "section": "Documentation", + "hidden": false + }, + { + "type": "style", + "section": "Styles", + "hidden": false + }, + { + "type": "deps", + "section": "Dependencies", + "hidden": false + }, + { + "type": "refactor", + "section": "Code Refactoring", + "hidden": false + }, + { + "type": "test", + "section": "Tests", + "hidden": false + }, + { + "type": "ci", + "section": "Continuous Integration", + "hidden": false + }, + { + "type": "chore", + "section": "Miscellaneous", + "hidden": true + }, + { + "type": "revert", + "section": "Reverts", + "hidden": true + }, + { + "type": "build", + "section": "Build System", + "hidden": true + }, + { + "type": "security", + "section": "Security", + "hidden": true + }, + { + "type": "translation", + "section": "Translations", + "hidden": true + } + ] +} diff --git a/.github/.release-please-manifest.json b/.github/.release-please-manifest.json new file mode 100644 index 00000000..6bb50d96 --- /dev/null +++ b/.github/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "2.9.0" +} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..dc1fbff6 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,27 @@ +--- + +on: # yamllint disable-line rule:truthy + pull_request: + branches: + - 2.x + +name: 🔍 Integration + +jobs: + lint-commits: + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read + steps: + - name: 📦 Check out the codebase + uses: actions/checkout@v4.1.1 + + # See: https://github.com/wagoid/commitlint-github-action + - name: 🧐 Lint commits using "commitlint" + uses: wagoid/commitlint-github-action@v6.0.0 + with: + configFile: ${{ github.workspace }}/.github/commitlint.config.mjs + failOnWarnings: false + failOnErrors: true + helpURL: 'https://github.com/conventional-changelog/commitlint/#what-is-commitlint' diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml new file mode 100644 index 00000000..e21d01da --- /dev/null +++ b/.github/workflows/create-release.yml @@ -0,0 +1,26 @@ +--- + +# https://github.com/wayofdev/gh-actions/blob/master/.github/workflows/create-release.yml +# https://github.com/google-github-actions/release-please-action#release-types-supported + +on: # yamllint disable-line rule:truthy + push: + branches: + - 2.x + +name: 📦 Create release + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: 🎉 Create release + uses: google-github-actions/release-please-action@v4 + id: release + with: + token: ${{ secrets.GITHUB_TOKEN }} + config-file: .github/.release-please-config.json + manifest-file: .github/.release-please-manifest.json + target-branch: 2.x + +... diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e7c3d59..7c0fd915 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,94 +1,106 @@ -# CHANGELOG - -v2.10.0 (04.04.2024) --------------------- -- Add support for the `NOT` operator in SQL queries. New methods `whereNot`, `andWhereNot`, and `orWhereNot` - have been added to the query builder by @msmakouz (#185) -- Add support **JSON** columns in **orderBy** statement by @msmakouz (#184) -- Add `mediumText` column type by @msmakouz (#178) -- Fix caching of SQL insert query with Fragment values by @msmakouz (#177) -- Fix detection of enum values in PostgreSQL when a enum field has only one value by @msmakouz (#181) - -v2.9.0 (27.03.2024) -------------------- +# Changelog + +## [2.9.0](https://github.com/cycle/database/compare/2.8.1...2.9.0) (2024-03-27) + +### Features - Added `logInterpolatedQueries` for detailed query logging and refined `logQueryParameters` to accurately log query parameters as arrays, enhancing ORM debugging and monitoring. @lotyp (#165) - Improved logging with enriched context in Driver.php, including driver details and query parameters. @lotyp (#165) - Improved `orderBy` method to accept a null direction parameter, providing more flexibility when constructing queries by @butschster (#167) - Added support for PostgreSQL-specific directions **NULLS FIRST** and **NULLS LAST** for more control over null value ordering in result sets by @butschster (#167) -v2.8.1 (08.02.2024) -------------------- +## [2.8.1](https://github.com/cycle/database/compare/2.8.0...2.8.1) (2024-02-08) + +### Bug Fixes - Fix compiling of Fragment with parameters in the returning() definition by @msmakouz (#161) - Fix comparison of Fragment in Column default value by @msmakouz (#162) -v2.8.0 (08.02.2024) -------------------- +## [2.8.0](https://github.com/cycle/database/compare/2.7.1...2.8.0) (2024-02-08) + +### Features - The `withDatetimeMicroseconds` option now affects the interpolator by @msmakouz (#155) - Postgres: support for multiple returning columns by @roxblnfk and @msmakouz (#157) - MSSQL: support for multiple returning columns by @msmakouz (#160) -v2.7.1 (22.12.2023) -------------------- +## [2.7.1](https://github.com/cycle/database/compare/2.7.0...2.7.1) (2023-12-22) + +### Bug Fixes - Fix setting `precision` and `scale` through attributes by @msmakouz (#148) - Fix quoting with an underscore at the beginning by @msmakouz (#151) - Fix behavior of the `Column::type()` method by adding default size to column type mappings by @msmakouz (#150) -v2.7.0 (04.12.2023) -------------------- +## [2.7.0](https://github.com/cycle/database/compare/2.6.0...2.7.0) (2023-12-04) + +### Features - Add `varbinary` support in MySQL; optimize `size` attribute by @msmakouz (#146) -- Add the ability to use WHERE IN and WHERE NOT IN with array values - The value sequence may contain `FragmentInterface` objets by @msmakouz and @roxblnfk (#147) +- Add the ability to use WHERE IN and WHERE NOT IN with array values. The value sequence may contain `FragmentInterface` objets by @msmakouz and @roxblnfk (#147) -v2.6.0 (02.11.2023) -------------------- -- Fix incorrect parameters processing for JOIN subqueries by @smelesh (#133) +## [2.6.0](https://github.com/cycle/database/compare/2.5.2...2.6.0) (2023-11-02) + +### Features - MySQL driver: - - Add the type `smallInteger` by @gam6itko (#128) - - Change mapping of the JSON type from `text` to `json` by @romanpravda (#121) + - Add the type `smallInteger` by @gam6itko (#128) + - Change mapping of the JSON type from `text` to `json` by @romanpravda (#121) - Postgres driver: - - Add the `restartIdentity` parameter to the `eraseTable` method by @msmakouz (#132) - - Change mapping of the JSON type from `text` to `json` by @msmakouz (#134) -- All the drivers: - - Add `enableForeignKeyConstraints` and `disableForeignKeyConstraints` methods in Driver Handlers by @msmakouz (#130) - - Add an ability to disable the query cache before query using `withoutCache()` by @msmakouz and @roxblnfk (#137) + - Add the `restartIdentity` parameter to the `eraseTable` method by @msmakouz (#132) + - Change mapping of the JSON type from `text` to `json` by @msmakouz (#134) +- All the drivers: + - Add `enableForeignKeyConstraints` and `disableForeignKeyConstraints` methods in Driver Handlers by @msmakouz (#130) + - Add an ability to disable the query cache before query using `withoutCache()` by @msmakouz and @roxblnfk (#137) - JSON support: - - Add methods to work with JSON columns by @msmakouz and @roxblnfk (#135) - - Add an ability to set JSON default value as an array by @msmakouz and @roxblnfk (#138) + - Add methods to work with JSON columns by @msmakouz and @roxblnfk (#135) + - Add an ability to set JSON default value as an array by @msmakouz and @roxblnfk (#138) + +### Bug Fixes +- Fix incorrect parameters processing for JOIN subqueries by @smelesh (#133) + +## [2.5.2](https://github.com/cycle/database/compare/2.5.1...2.5.2) (2023-07-03) -v2.5.2 (03.07.2023) -------------------- +### Bug Fixes - Fix Postgres schema restoring after reconnect by @msmakouz in (#126) -v2.5.1 (09.06.2023) -------------------- +## [2.5.1](https://github.com/cycle/database/compare/2.5.0...2.5.1) (2023-06-09) + +### Bug Fixes - Fix drastic increase of insert statements on pg driver with complex primary keys by @wolfy-j (#122) -v2.5.0 (12.05.2023) -------------------- +## [2.5.0](https://github.com/cycle/database/compare/2.4.1...2.5.0) (2023-05-12) + +### Features - Add ability to use non-primary serial column by @msmakouz (#106) - Add ability to configure DB port passing a string by @msmakouz (#109) - Add ability to define a custom type column by @msmakouz (#104) - Add the ability to define `readonlySchema` for columns by @msmakouz (#116) - Add `AbstractForeignKey::$index` property to enable/disable index creation by @msmakouz (#119) + +### Bug Fixes - Fix inserting an array of rowsets without calling the columns method by @msmakouz (#120) + +### Miscellaneous - Improve types for `TableInterface` and `ColumnInterface` by @vjik (#108) - Fix typos by @arogachev (#110, #111) -v2.4.1 (08.03.2023) -------------------- +## [2.4.1](https://github.com/cycle/database/compare/2.4.0...2.4.1) (2023-03-08) + +### Bug Fixes - Fix: add schema to Postgres dependency table names by @msmakouz (#102) - Fix: don't add a table prefix when a column is quoting by @msmakouz (#103) -v2.4.0 (01.02.2023) -------------------- -- Add option `logQueryParameters` in the driver `options` to enable interpolation in SQL query logs. - Since **v2.4.0**, interpolation in logs is **disabled** by default by @msmakouz (#95) +## [2.4.0](https://github.com/cycle/database/compare/2.3.0...2.4.0) (2023-02-01) + +### ⚠ BREAKING CHANGES +* Since **v2.4.0**, interpolation in logs is **disabled** by default + +### Features +- Add option `logQueryParameters` in the driver `options` to enable interpolation in SQL query logs by @msmakouz (#95) - Add PostgreSQL specific data types by @msmakouz (#93) - Add MySQL `SET` type support by @msmakouz (#92) + +### Bug Fixes - Fix Interpolator performance by @msmakouz (#94) thx @hustlahusky -v2.3.0 (27.12.2022) -------------------- +## [2.3.0](https://github.com/cycle/database/compare/2.2.2...2.3.0) (2022-12-27) + +### Features - Add support for array values in the `IN` and `NOT IN` operators by @roxblnfk (#69, #70, #71) - Add `PdoInterface` as a possible return type for the `Driver::getPDO()` method by @roxblnfk (#76) - Add the `options` array parameter to all driver configs to pass additional driver options. @@ -97,53 +109,72 @@ v2.3.0 (27.12.2022) - Add the ability to define the `size` of a `datetime` column by @msmakouz (#86) - Add support for the unsigned and zerofill properties in MySQL Integer types by @roxblnfk (#88) -v2.2.2 (27.09.2022) -------------------- +## [2.2.2](https://github.com/cycle/database/compare/2.2.1...2.2.2) (2022-09-27) + +### Bug Fixes - Fix transaction level changing on disconnect when transaction is starting by @roxblnfk (#76) -v2.2.1 (02.07.2022) -------------------- +## [2.2.1](https://github.com/cycle/database/compare/2.2.0...2.2.1) (2022-07-02) + +### Bug Fixes - Hotfix: make the `$config` parameter of the `DatabaseConfig` constructor optional again by @roxblnfk -v2.2.0 (23.06.2022) -------------------- +## [2.2.0](https://github.com/cycle/database/compare/2.1.3...2.2.0) (2022-06-23) + +### Features - Add supporting for PHP 8.1 Enumerations by @roxblnfk (#67) - Add supporting for smallint column type by @gam6itko (#58) + +### Bug Fixes - Fix typo in the `\Cycle\Database\Schema\State::forgerForeignKey` method by @BeMySlaveDarlin (#53) - Fix compatibility with Spiral Framework 3 packages: - - Remove overriding of the `$config` property in the `DatabaseConfig` class by @roxblnfk (#64) - - Update `composer.json` dependencies + - Remove overriding of the `$config` property in the `DatabaseConfig` class by @roxblnfk (#64) + - Update `composer.json` dependencies -v2.1.3 (20.05.2022) -------------------- +## [2.1.3](https://github.com/cycle/database/compare/2.1.2...2.1.3) (2022-05-20) + +### Bug Fixes - Fix query interpolation by @roxblnfk (#60) -v2.1.2 (20.01.2022) -------------------- +## [2.1.2](https://github.com/cycle/database/compare/2.1.1...2.1.2) (2022-01-20) + +### Bug Fixes - Fix wrong bind parameter order in a select query with join by @roxblnfk (#48) - Fix access to unitialized driver property on `ActiveQuery::__debugInfo()` call by @roxblnfk (#46) -v2.1.1 (12.01.2022) -------------------- +## [2.1.1](https://github.com/cycle/database/compare/2.1.0...2.1.1) (2022-01-12) + +### Miscellaneous - Fix phpdoc for the `SelectQuery::orderBy` method by @butschster (#45) - Fix problem with driver cloning by @butschster (#44) -v2.1.0 (31.12.2021) -------------------- -- Add `psr/log` dependency by @thgs (#35) +## [2.1.0](https://github.com/cycle/database/compare/2.0.0...2.1.0) (2021-12-31) + +### Features +- Added `psr/log` dependency by @thgs (#35) - Add ability to get/set driver name by @butschster (#38) - Optimize fetching indexes and primary keys in Postgres driver by @hustlahusky (#37) + +### Bug Fixes - Fix type casting for column size value in the PG Column class by @rauanmayemir (#34) + +### Miscellaneous +- Add `psr/log` dependency by @thgs (#35) - Downgrade spiral dependencies to stable by @roxblnfk (#40) -v2.0.0 (22.12.2021) -------------------- -- The package moved from `spiral/database` to `cycle/database` +## [2.0.0](https://github.com/cycle/database/compare/1.0.0...2.0.0) (2021-12-22) + +### ⚠ BREAKING CHANGES - Namespace `Spiral\Database` replaced with `Cycle\Database` @butschster (#1) -- Minimal PHP version is 8.0 (#26, #31) +- Minimal PHP version is 8.0 + +### Features - Added supporting for postgres schemas @butschster (#2) -- Added DTO configs @SerafimArts, @msmakouz (#10, #14) -- Improvements to `join` methods @butschster -- Tests have been restructured @butschster (#21) +- Added DTO configs @SerafimArts, @msmakouz (#10, #14) - Added method to get transaction level @msmakouz (#23) - Added `ColumnReturnableInterface` for database drivers @butschster (#25) + +### Miscellaneous +- The package moved from `spiral/database` to `cycle/database` +- Improvements to `join` methods @butschster +- Tests have been restructured @butschster (#21) diff --git a/src/DatabaseInterface.php b/src/DatabaseInterface.php index e53678c5..3d4b0a67 100644 --- a/src/DatabaseInterface.php +++ b/src/DatabaseInterface.php @@ -136,7 +136,7 @@ public function select(mixed $columns = '*'): SelectQuery; * * @template CallbackResult * - * @param callable(): CallbackResult $callback + * @param callable(DatabaseInterface): CallbackResult $callback * * @throws \Throwable *