propelorm / Propel2

Propel2 is an open-source high-performance Object-Relational Mapping (ORM) for modern PHP
http://propelorm.org/
MIT License
1.26k stars 397 forks source link

Add support for native UUID column type #1915

Closed mringler closed 1 year ago

mringler commented 1 year ago

As discussed in #1914, this allows to use UUID as column type in schema.xml. Underlying columns are set to the native uuid type of the database system (uuid in Postgres and Oracle, UNIQUEIDENTIFIER in mssql). In Mysql/MariaDB and SQLite, an error is thrown. Inside the model and query classes, the uuid columns use string values.

This is pretty straight forward, a new type literal is registered and associated with strings, and register the type in the vendor adapters with the corresponding type. For Postgres, I added cast statements used during migration. Tests check generated create and alter statements and internal mapping of uuid to string.

I have played around with it on Postgres, and it seems to work there.

I also added a commit with two fixes for the test setup scripts:

codecov-commenter commented 1 year ago

:warning: Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 92.85714% with 2 lines in your changes missing coverage. Please review.

Project coverage is 88.44%. Comparing base (12c23e1) to head (1db89c3). Report is 107 commits behind head on master.

Files with missing lines Patch % Lines
src/Propel/Runtime/Map/ColumnMap.php 0.00% 2 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1915 +/- ## ============================================ + Coverage 88.41% 88.44% +0.02% - Complexity 7849 7854 +5 ============================================ Files 224 224 Lines 20981 20988 +7 ============================================ + Hits 18551 18562 +11 + Misses 2430 2426 -4 ``` | [Flag](https://app.codecov.io/gh/propelorm/Propel2/pull/1915/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=propelorm) | Coverage Δ | | |---|---|---| | [5-max](https://app.codecov.io/gh/propelorm/Propel2/pull/1915/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=propelorm) | `88.44% <92.85%> (+0.02%)` | :arrow_up: | | [7.4](https://app.codecov.io/gh/propelorm/Propel2/pull/1915/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=propelorm) | `88.44% <92.85%> (+0.02%)` | :arrow_up: | | [agnostic](https://app.codecov.io/gh/propelorm/Propel2/pull/1915/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=propelorm) | `67.39% <89.28%> (+0.11%)` | :arrow_up: | | [mysql](https://app.codecov.io/gh/propelorm/Propel2/pull/1915/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=propelorm) | `69.09% <28.57%> (-0.02%)` | :arrow_down: | | [pgsql](https://app.codecov.io/gh/propelorm/Propel2/pull/1915/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=propelorm) | `69.05% <71.42%> (-0.03%)` | :arrow_down: | | [sqlite](https://app.codecov.io/gh/propelorm/Propel2/pull/1915/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=propelorm) | `66.93% <28.57%> (-0.02%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=propelorm#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

dereuromark commented 1 year ago

Do we have a way to update docs here accordingly, so it is clear what to expect and what support across the DB types has been achieved yet?

mringler commented 1 year ago

Do we have a way to update docs

Not sure, the only doc for Propel 2 that I know of is at http://propelorm.org/documentation/, but I am not really familiar with it

dereuromark commented 1 year ago

Right, we probably want to add UUID info at https://github.com/propelorm/propelorm.github.com then to be published after we merged.

dereuromark commented 1 year ago

Small conflict then we should be good to go

mringler commented 1 year ago

Oh, hadn't realized, thank you for the notice!