Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
194 commits
Select commit Hold shift + click to select a range
44c19f9
Extract query lib
abnegate Mar 3, 2026
d942f2b
fix: resolve PHPStan type errors from query lib extraction
abnegate Mar 3, 2026
b0a1faf
fix: use static return types and remove PHPStan stubs
abnegate Mar 3, 2026
782ed2d
fix: update utopia-php/query to 0.1.1 for static return types
abnegate Mar 3, 2026
e130b88
(chore): switch to paratest and local query lib path dependency
abnegate Mar 12, 2026
6ae1a54
(refactor): extract enums, adapter features, hooks, and traits from D…
abnegate Mar 12, 2026
7910547
(refactor): decompose Database class and update adapters and validators
abnegate Mar 12, 2026
2e37e8e
(test): update tests and docs for Database class decomposition
abnegate Mar 12, 2026
4072192
(fix): add RetryClient proxy to suppress Swoole recv() EAGAIN warning…
abnegate Mar 12, 2026
801b29b
(refactor): use supports(Capability::Spatial) instead of instanceof S…
abnegate Mar 12, 2026
5339254
(fix): propagate tenantPerDocument setting to pooled adapter connections
abnegate Mar 12, 2026
aea4931
(fix): propagate relationship hook to Mirror source and destination d…
abnegate Mar 12, 2026
2546230
(style): remove section-style header comments
abnegate Mar 12, 2026
fe003f2
(chore): trigger CI
abnegate Mar 12, 2026
777f4d1
(chore): add workflow_dispatch trigger to tests workflow
abnegate Mar 12, 2026
574d55c
(chore): add workflow_dispatch trigger to linter and codeql workflows
abnegate Mar 12, 2026
18c883e
(fix): fix CI build context for query lib dependency and workflow_dis…
abnegate Mar 12, 2026
97400a8
(fix): checkout query lib dependency in linter and codeql CI workflows
abnegate Mar 12, 2026
1125cf1
(style): auto-fix lint issues with pint
abnegate Mar 12, 2026
ca2e1b6
(fix): use COMPOSER_MIRROR_PATH_REPOS in CI for proper query lib reso…
abnegate Mar 12, 2026
ae623f1
(style): fix pint issues for PHP 8.3 compatibility
abnegate Mar 12, 2026
64cf39e
(fix): patch composer.lock path in CI for proper query lib resolution
abnegate Mar 12, 2026
1830938
(fix): patch composer.lock path in Dockerfile for query lib resolution
abnegate Mar 12, 2026
213c8ef
(fix): replace symlinked query lib with copy in CI for PHPStan compat…
abnegate Mar 12, 2026
b202550
(fix): remove dump-autoload to preserve platform check from initial i…
abnegate Mar 12, 2026
1fc920f
(fix): use composer update in CodeQL CI for proper query lib resolution
abnegate Mar 12, 2026
6eda974
(fix): checkout feat-builder branch of query lib in CI workflows
abnegate Mar 12, 2026
9f2577f
(fix): force copy query lib in CodeQL CI to fix PHPStan symlink resol…
abnegate Mar 12, 2026
7344bf2
(fix): add debug output for CodeQL query lib resolution
abnegate Mar 12, 2026
08e737e
(fix): use PHP 8.4 container for CodeQL to support query lib syntax
abnegate Mar 12, 2026
940915b
(fix): update phpstan for PHP 8.4 compatibility in CodeQL CI
abnegate Mar 12, 2026
8c5bf27
(fix): upgrade to PHPStan 2.x for PHP 8.4 runtime compatibility in Co…
abnegate Mar 12, 2026
e44c71a
(fix): force copy query lib in Dockerfile and add diagnostics
abnegate Mar 12, 2026
16bb001
(chore): upgrade to PHPStan 2.x with baseline for PHP 8.4 query lib c…
abnegate Mar 12, 2026
d1ddad0
(fix): ensure query lib is copied into vendor in Docker final stage
abnegate Mar 12, 2026
0e6ec7c
(fix): ignore Swoole extension class errors in PHPStan for CI compati…
abnegate Mar 12, 2026
87afa86
(fix): resolve 29 PHPStan errors in Index validator by using typed ob…
abnegate Mar 13, 2026
7f8a6ca
(chore): add utopia-php/async dependency
abnegate Mar 14, 2026
ee2c93f
(chore): update docker-compose configuration
abnegate Mar 14, 2026
9744868
(chore): simplify PHPStan config and remove baseline
abnegate Mar 14, 2026
bbe2cb0
(feat): add Event enum to replace string event constants
abnegate Mar 14, 2026
98e1474
(feat): add Lifecycle hook interface for database events
abnegate Mar 14, 2026
8b638ef
(feat): add QueryTransform hook interface for SQL query modification
abnegate Mar 14, 2026
5106488
(feat): add Async trait for parallel database operations
abnegate Mar 14, 2026
7ea6ef2
(feat): add query validators for aggregation, distinct, group by, hav…
abnegate Mar 14, 2026
28a886e
(test): add e2e test scopes for aggregation and join queries
abnegate Mar 14, 2026
d722b94
(refactor): remove local CursorDirection and OrderDirection enums in …
abnegate Mar 14, 2026
e12b5c2
(refactor): remove Mongo RetryClient in favor of built-in retry handling
abnegate Mar 14, 2026
92160fe
(refactor): use import alias for base Exception class and add docblocks
abnegate Mar 14, 2026
aa16406
(docs): add class-level docblocks to all exception subclasses
abnegate Mar 14, 2026
4b59b42
(refactor): improve ID helper with import alias and enhanced docblocks
abnegate Mar 14, 2026
ebbb5c9
(refactor): improve Role helper with import alias and enhanced docblocks
abnegate Mar 14, 2026
ff0175b
(refactor): improve Permission helper with enhanced docblocks
abnegate Mar 14, 2026
5d04b1a
(refactor): update DateTime helper with improved type safety
abnegate Mar 14, 2026
016a6ba
(refactor): update Connection class with improved docblocks
abnegate Mar 14, 2026
72460e2
(refactor): update PDO wrapper with improved type safety
abnegate Mar 14, 2026
5629360
(docs): add docblocks to enum and model classes
abnegate Mar 14, 2026
21cb52d
(feat): extend OperatorType enum with new cases and docblocks
abnegate Mar 14, 2026
54ca313
(refactor): change Operator method from string to OperatorType enum
abnegate Mar 14, 2026
314edd0
(refactor): remove backward compat constants and add aggregation/join…
abnegate Mar 14, 2026
38d9ec9
(refactor): improve Document type safety with PHPStan annotations and…
abnegate Mar 14, 2026
9879391
(refactor): improve Attribute model with PHPStan type annotations
abnegate Mar 14, 2026
c01b969
(refactor): improve Index model with PHPStan type annotations
abnegate Mar 14, 2026
672ac4c
(refactor): improve Relationship model with PHPStan type annotations
abnegate Mar 14, 2026
6528c41
(refactor): update adapter feature interfaces with docblocks and type…
abnegate Mar 14, 2026
cf22762
(refactor): replace string-based event system with Event enum and Que…
abnegate Mar 14, 2026
29c7ac7
(refactor): overhaul SQL adapter with query builder integration and t…
abnegate Mar 14, 2026
b9b58e2
(refactor): update MariaDB adapter for query lib integration
abnegate Mar 14, 2026
db306e5
(refactor): update MySQL adapter for query lib integration
abnegate Mar 14, 2026
382e89d
(refactor): update Postgres adapter for query lib integration
abnegate Mar 14, 2026
e8f5f64
(refactor): update SQLite adapter for query lib integration
abnegate Mar 14, 2026
ff015e9
(refactor): update Mongo adapter for query lib integration
abnegate Mar 14, 2026
bcc08e4
(refactor): update Pool adapter with typed delegates and query transf…
abnegate Mar 14, 2026
be9d715
(refactor): update Read, Write, and WriteContext hooks with docblocks
abnegate Mar 14, 2026
bab6d2d
(refactor): update permission hooks with type safety improvements
abnegate Mar 14, 2026
d4cbda7
(refactor): update tenant hooks with type safety improvements
abnegate Mar 14, 2026
5e03323
(refactor): update relationship hooks with type safety and docblocks
abnegate Mar 14, 2026
dd29e18
(refactor): replace event/listener system with Lifecycle hooks and si…
abnegate Mar 14, 2026
49598d6
(refactor): update Attributes trait for typed objects and Event enum
abnegate Mar 14, 2026
730d706
(refactor): update Collections trait for typed objects and Event enum
abnegate Mar 14, 2026
bf24dd0
(refactor): update Databases trait for Event enum
abnegate Mar 14, 2026
fd148e9
(refactor): update Documents trait for typed objects, Event enum, and…
abnegate Mar 14, 2026
cc64fb9
(refactor): update Indexes trait for typed objects and Event enum
abnegate Mar 14, 2026
9e9a526
(refactor): update Relationships trait for typed objects and Event enum
abnegate Mar 14, 2026
7280fd0
(docs): add docblock to Transactions trait
abnegate Mar 14, 2026
098e5e3
(refactor): update Mirror class for Lifecycle hooks and Event enum
abnegate Mar 14, 2026
d02398a
(refactor): update Mirroring Filter with type safety improvements
abnegate Mar 14, 2026
02a8b44
(refactor): update query validators with type safety and docblocks
abnegate Mar 14, 2026
2601f52
(refactor): update Attribute validator to use typed Attribute objects
abnegate Mar 14, 2026
10d348f
(refactor): update Index validators to use typed objects
abnegate Mar 14, 2026
85324a8
(refactor): update Operator validator for OperatorType enum
abnegate Mar 14, 2026
b41d2e2
(refactor): update Structure validators with type safety
abnegate Mar 14, 2026
aa7ef09
(refactor): update Queries validators with type safety and docblocks
abnegate Mar 14, 2026
c67dea4
(refactor): update Authorization validator with docblocks
abnegate Mar 14, 2026
9a86037
(refactor): update remaining validators with type safety and docblocks
abnegate Mar 14, 2026
f843e23
(test): update Operator tests for OperatorType enum changes
abnegate Mar 14, 2026
a18e4c5
(test): update Query tests for removed backward compat constants
abnegate Mar 14, 2026
fca7473
(test): update Document tests for type safety changes
abnegate Mar 14, 2026
445dbce
(test): update ID test import
abnegate Mar 14, 2026
b44043e
(test): update Attribute validator tests
abnegate Mar 14, 2026
e01d4bb
(test): update Index validator tests for typed objects
abnegate Mar 14, 2026
f6f9081
(test): update Structure validator tests
abnegate Mar 14, 2026
a7c3aa5
(test): update Query and Documents query validator tests
abnegate Mar 14, 2026
258ae8e
(test): update remaining unit validator tests
abnegate Mar 14, 2026
26946ce
(test): update e2e base adapter test class
abnegate Mar 14, 2026
9939205
(test): update Collection e2e tests for typed objects and Event enum
abnegate Mar 14, 2026
1b85a53
(test): update Document e2e tests for type safety changes
abnegate Mar 14, 2026
7b10d06
(test): update Attribute e2e tests
abnegate Mar 14, 2026
5d9fe92
(test): update Index e2e tests for typed objects
abnegate Mar 14, 2026
6a0f624
(test): update Spatial e2e tests for query lib changes
abnegate Mar 14, 2026
bb32e93
(test): update Relationship e2e tests for typed objects and Event enum
abnegate Mar 14, 2026
abbc77e
(test): update remaining e2e test scopes
abnegate Mar 14, 2026
1e702a2
(test): update SQL adapter e2e test configurations
abnegate Mar 14, 2026
1054409
(test): update MongoDB e2e test configurations
abnegate Mar 14, 2026
ebedcd2
(test): update Mirror e2e tests for Lifecycle hooks
abnegate Mar 14, 2026
62576d8
(test): update Pool adapter e2e test
abnegate Mar 14, 2026
4ecbe6f
(test): update SharedTables e2e test configurations
abnegate Mar 14, 2026
79cb0c2
(fix): resolve PHPStan errors in Mirror and Queries validator
abnegate Mar 16, 2026
577d710
(feat): add Collection model with toDocument/fromDocument
abnegate Mar 16, 2026
299c2e5
(feat): add optimistic locking with auto-incrementing document version
abnegate Mar 16, 2026
99b8eea
(feat): add rawQuery escape hatch and full-text search relevance scoring
abnegate Mar 16, 2026
73fc17e
(fix): add finally blocks for shared tables test cleanup and skip ten…
abnegate Mar 16, 2026
c993582
(feat): add ORM entity mapping with PHP 8.4 attributes and unit of work
abnegate Mar 19, 2026
2da66f8
(feat): add custom type registry, repository pattern, and specifications
abnegate Mar 19, 2026
5e5df73
(feat): add database seeding with factories, fixtures, and dependency…
abnegate Mar 19, 2026
43ad9e8
(feat): add typed domain events with PSR-14 compatible dispatcher
abnegate Mar 19, 2026
dd2a8d8
(feat): add second-level query cache with region config and auto-inva…
abnegate Mar 19, 2026
47a3d89
(feat): add eager/lazy loading with batch resolution and N+1 detection
abnegate Mar 19, 2026
d97d4e5
(feat): add query profiler with slow query detection and adapter inst…
abnegate Mar 19, 2026
18b3359
(feat): add fluent QueryBuilder exposing full utopia-php/query builde…
abnegate Mar 19, 2026
453878f
(feat): add schema introspection, migrations, and zero-downtime strat…
abnegate Mar 19, 2026
3c3640a
(feat): add read/write pool adapter with replica routing and sticky c…
abnegate Mar 19, 2026
fe5cc74
(test): add 301 unit tests for ORM, types, repository, seeder, events…
abnegate Mar 19, 2026
c7cc7ae
(feat): integrate utopia-php/query with performance optimizations and…
abnegate Mar 24, 2026
79e4c10
(test): refactor test suite with unit test coverage and PHPUnit 12 at…
abnegate Mar 24, 2026
8d002e0
(chore): upgrade to PHPUnit 12 and PHP 8.4
abnegate Mar 24, 2026
474f215
(fix): resolve SQLite execute override and Mirror constructor initial…
abnegate Mar 24, 2026
21d6c20
(test): restore e2e coverage and close unit test gaps for full covera…
abnegate Mar 24, 2026
c5d25bb
(fix): clone fixture documents to prevent test state leakage and re-c…
abnegate Mar 24, 2026
b078980
(fix): revert spatial Query::covers to Query::contains for cross-adap…
abnegate Mar 24, 2026
64b671e
Merge remote-tracking branch 'origin/main' into feat-query-lib
abnegate Mar 24, 2026
a6949b8
fix: add async library checkout to CI and regenerate composer.lock
abnegate Mar 24, 2026
980a619
fix: switch to VCS repos for query/async and simplify CI
abnegate Mar 24, 2026
d21d4ce
fix: resolve lint errors, add PHPStan baseline for max level, remove …
abnegate Mar 24, 2026
8d235cd
fix: resolve test failures for CacheKey, ORM entities, and Collection…
abnegate Mar 24, 2026
15d8eed
fix: resolve adapter test failures across all databases
abnegate Mar 24, 2026
f86a80d
fix: wrap user:x removal in try/finally and relax testGetDocumentSelect
abnegate Mar 24, 2026
6b8203f
fix: resolve cursor validation, Pool stale transforms, MySQL timeout,…
abnegate Mar 24, 2026
23fd044
fix: make test fixtures idempotent for paratest functional mode
abnegate Mar 24, 2026
a99ad70
fix: revert PermissionTests fixture and Documents.php NotFoundExcepti…
abnegate Mar 24, 2026
9815a9f
fix: use UUID collection names for paratest isolation and fix test or…
abnegate Mar 25, 2026
042aa09
fix: resolve Console class namespace, SharedTables update detection, …
abnegate Mar 25, 2026
a55ef9d
fix: narrow internal key skip list to only system-managed keys
abnegate Mar 25, 2026
9f57454
fix: use unique collection names in aggregation, relationship, and Sh…
abnegate Mar 25, 2026
94b44f9
fix: add PHPStan type annotation for createdProductCollections array
abnegate Mar 25, 2026
79eaeb4
fix: SharedTables multi-tenant cleanup and Pool timeout propagation
abnegate Mar 25, 2026
f558e40
fix: Pool setTimeout state tracking and MySQL timeout dirty flag
abnegate Mar 25, 2026
4de656f
fix: use docker stop instead of docker kill for Redis-Destructive tests
abnegate Mar 25, 2026
582d2cb
fix: reconnect cache after Redis restart in destructive tests
abnegate Mar 25, 2026
98a4fa8
fix: address review — add missing syncReadHooks in Mongo and tenant g…
abnegate Mar 25, 2026
93d3108
fix: replace slow waitForRedis polling with direct reconnect
abnegate Mar 25, 2026
be5a1f8
fix: set read_timeout on Redis reconnect and use instant docker stop
abnegate Mar 25, 2026
f08deea
fix: remove redundant testCacheReconnect, already covered by utopia-p…
abnegate Mar 25, 2026
617cf69
fix: replace docker-based Redis test with mock, remove Redis-Destruct…
abnegate Mar 25, 2026
9107f2f
Selective startup
abnegate Mar 25, 2026
ed945f0
fix: use docker-compose profiles to only start needed services per CI…
abnegate Mar 25, 2026
08c10f2
fix: keep xdebug.so in image, restore volume mount
abnegate Mar 25, 2026
2150f9b
fix: disable xdebug in CI with XDEBUG_MODE=off
abnegate Mar 25, 2026
4767099
refactor: break SQLite inheritance from MariaDB, use Feature interfaces
abnegate Mar 25, 2026
25b1fe2
fix: add relationship guards for SQLite, fix lint issues
abnegate Mar 25, 2026
9ccb3e1
fix: add remaining relationship guards, make Pool implement Features
abnegate Mar 25, 2026
13a60f0
fix: update PHPStan baseline, remove redundant instanceof checks
abnegate Mar 25, 2026
1f65132
fix: correct malformed datetime test value
abnegate Mar 25, 2026
f952c28
fix: use ISO datetime format in test, MySQL rejects text format
abnegate Mar 25, 2026
5a53446
refactor: promote shared methods from concrete adapters to SQL.php
abnegate Mar 25, 2026
476aef4
fix: align spatial method signatures, fix import ordering
abnegate Mar 25, 2026
7be2b74
feat: expose schema builder, rename BuildResult to Plan, add permissi…
abnegate Mar 26, 2026
141df88
(chore): update lock
abnegate Mar 26, 2026
a99e777
(feat): unified addHook API, Decorator/Interceptor/Permissions/Tenanc…
abnegate Mar 26, 2026
ab86d6f
(fix): remove parse error from dangling statement and inline assignme…
abnegate Mar 26, 2026
a51656c
(fix): accept any PDO-compatible object in SQL adapter constructor
abnegate Mar 26, 2026
3006ceb
(fix): use object type for PDO parameter
abnegate Mar 26, 2026
57b4d17
(fix): remove DatabasePDO type constraints from SQL adapter
abnegate Mar 26, 2026
0946667
(fix): pass PermissionType enum to getPermissionsByType
abnegate Mar 26, 2026
6a256be
(fix): pass PermissionType enum to Input constructor
abnegate Mar 26, 2026
e6d2504
(fix): handle ColumnType::Float in row size calculation
abnegate Mar 26, 2026
f51f4a5
(fix): handle ColumnType::Float everywhere alongside Double
abnegate Mar 26, 2026
5efffc0
(fix): restore syncWriteHooks auto-registration for Permissions and T…
abnegate Mar 26, 2026
c0f0c20
(fix): pass PermissionType enum to getPermissionsByType in Permission…
abnegate Mar 26, 2026
3f2e0ef
(fix): revert syncWriteHooks - manual registration only for user data…
abnegate Mar 26, 2026
d55beb5
(fix): auto-register Permissions hook in syncWriteHooks for all DB in…
abnegate Mar 27, 2026
9ad4baf
(revert): remove auto-registration, back to empty syncWriteHooks
abnegate Mar 27, 2026
be29e8e
(fix): sync write hooks from Pool adapter to inner adapter on delegate
abnegate Mar 27, 2026
ec959e3
(fix): sync write hooks from Pool only for DML operations, empty sync…
abnegate Mar 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 7 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: "CodeQL"

on: [ pull_request ]
on: [ pull_request, workflow_dispatch ]
jobs:
lint:
name: CodeQL
Expand All @@ -13,8 +13,12 @@ jobs:
fetch-depth: 2

- run: git checkout HEAD^2
if: github.event_name == 'pull_request'

- name: Run CodeQL
run: |
docker run --rm -v $PWD:/app -w /app phpswoole/swoole:5.1.8-php8.3-alpine sh -c \
"composer install --profile --ignore-platform-reqs && composer check"
docker run --rm -v $PWD:/app -w /app php:8.4-cli-alpine sh -c \
"php -r \"copy('https://getcomposer.org/installer', '/tmp/composer-setup.php');\" && \
php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer && \
composer install --profile --ignore-platform-reqs && \
composer check"
6 changes: 4 additions & 2 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: "Linter"

on: [ pull_request ]
on: [ pull_request, workflow_dispatch ]
jobs:
lint:
name: Linter
Expand All @@ -13,8 +13,10 @@ jobs:
fetch-depth: 2

- run: git checkout HEAD^2
if: github.event_name == 'pull_request'

- name: Run Linter
run: |
docker run --rm -v $PWD:/app -w /app phpswoole/swoole:5.1.8-php8.3-alpine sh -c \
"composer install --profile --ignore-platform-reqs && composer lint"
"composer install --profile --ignore-platform-reqs && \
composer lint"
56 changes: 34 additions & 22 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ concurrency:

env:
IMAGE: databases-dev
CACHE_KEY: databases-dev-${{ github.event.pull_request.head.sha }}
CACHE_KEY: databases-dev-${{ github.event.pull_request.head.sha || github.sha }}

on: [pull_request]
on: [pull_request, workflow_dispatch]

jobs:
setup:
Expand All @@ -25,6 +25,7 @@ jobs:
uses: docker/build-push-action@v3
with:
context: .
file: Dockerfile
push: false
tags: ${{ env.IMAGE }}
load: true
Expand Down Expand Up @@ -60,31 +61,42 @@ jobs:
docker compose up -d --wait

- name: Run Unit Tests
run: docker compose exec tests vendor/bin/phpunit /usr/src/code/tests/unit
run: docker compose exec -e XDEBUG_MODE=off tests vendor/bin/paratest --configuration phpunit.xml --functional --processes 4 /usr/src/code/tests/unit

adapter_test:
name: Adapter Tests
name: "Adapter Tests (${{ matrix.adapter }})"
runs-on: ubuntu-latest
needs: setup
strategy:
fail-fast: false
matrix:
adapter:
[
MongoDB,
MariaDB,
MySQL,
Postgres,
SQLite,
Mirror,
Pool,
SharedTables/MongoDB,
SharedTables/MariaDB,
SharedTables/MySQL,
SharedTables/Postgres,
SharedTables/SQLite,
Schemaless/MongoDB,
]
include:
- adapter: MongoDB
profiles: "--profile mongo"
- adapter: MariaDB
profiles: "--profile mariadb"
- adapter: MySQL
profiles: "--profile mysql"
- adapter: Postgres
profiles: "--profile postgres"
- adapter: SQLite
profiles: ""
- adapter: Mirror
profiles: "--profile mariadb --profile mariadb-mirror --profile redis-mirror"
- adapter: Pool
profiles: "--profile mysql"
- adapter: SharedTables/MongoDB
profiles: "--profile mongo"
- adapter: SharedTables/MariaDB
profiles: "--profile mariadb"
- adapter: SharedTables/MySQL
profiles: "--profile mysql"
- adapter: SharedTables/Postgres
profiles: "--profile postgres"
- adapter: SharedTables/SQLite
profiles: ""
- adapter: Schemaless/MongoDB
profiles: "--profile mongo"

steps:
- name: checkout
Expand All @@ -100,7 +112,7 @@ jobs:
- name: Load and Start Services
run: |
docker load --input /tmp/${{ env.IMAGE }}.tar
docker compose up -d --wait
docker compose ${{ matrix.profiles }} up -d --wait

- name: Run Tests
run: docker compose exec -T tests vendor/bin/phpunit /usr/src/code/tests/e2e/Adapter/${{matrix.adapter}}Test.php --debug
run: docker compose exec -T -e XDEBUG_MODE=off tests vendor/bin/paratest --configuration phpunit.xml --functional --processes 4 /usr/src/code/tests/e2e/Adapter/${{matrix.adapter}}Test.php
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ Makefile
.envrc
.vscode
tmp
*.sql
10 changes: 4 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ WORKDIR /usr/src/code
RUN echo extension=redis.so >> /usr/local/etc/php/conf.d/redis.ini
RUN echo extension=swoole.so >> /usr/local/etc/php/conf.d/swoole.ini
RUN echo extension=pcov.so >> /usr/local/etc/php/conf.d/pcov.ini
RUN echo extension=xdebug.so >> /usr/local/etc/php/conf.d/xdebug.ini

RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"

RUN echo "opcache.enable_cli=1" >> $PHP_INI_DIR/php.ini
Expand All @@ -110,14 +108,14 @@ COPY --from=redis /usr/local/lib/php/extensions/no-debug-non-zts-20240924/redis.
COPY --from=pcov /usr/local/lib/php/extensions/no-debug-non-zts-20240924/pcov.so /usr/local/lib/php/extensions/no-debug-non-zts-20240924/
COPY --from=xdebug /usr/local/lib/php/extensions/no-debug-non-zts-20240924/xdebug.so /usr/local/lib/php/extensions/no-debug-non-zts-20240924/

COPY ./bin /usr/src/code/bin
COPY ./src /usr/src/code/src
COPY ./dev /usr/src/code/dev
COPY bin /usr/src/code/bin
COPY src /usr/src/code/src
COPY dev /usr/src/code/dev

# Add Debug Configs
RUN if [ "$DEBUG" = "true" ]; then cp /usr/src/code/dev/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini; fi
RUN if [ "$DEBUG" = "true" ]; then mkdir -p /tmp/xdebug; fi
RUN if [ "$DEBUG" = "false" ]; then rm -rf /usr/src/code/dev; fi
RUN if [ "$DEBUG" = "false" ]; then rm -f /usr/local/lib/php/extensions/no-debug-non-zts-20240924/xdebug.so; fi
RUN if [ "$DEBUG" = "false" ]; then rm -f /usr/local/etc/php/conf.d/xdebug.ini; fi

CMD [ "tail", "-f", "/dev/null" ]
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -633,22 +633,22 @@ $database->createRelationship(
);

// Relationship onDelete types
Database::RELATION_MUTATE_CASCADE,
Database::RELATION_MUTATE_SET_NULL,
Database::RELATION_MUTATE_RESTRICT,
ForeignKeyAction::Cascade->value,
ForeignKeyAction::SetNull->value,
ForeignKeyAction::Restrict->value,

// Update the relationship with the default reference attributes
$database->updateRelationship(
collection: 'movies',
id: 'users',
onDelete: Database::RELATION_MUTATE_CASCADE
onDelete: ForeignKeyAction::Cascade->value
);

// Update the relationship with custom reference attributes
$database->updateRelationship(
collection: 'movies',
id: 'users',
onDelete: Database::RELATION_MUTATE_CASCADE,
onDelete: ForeignKeyAction::Cascade->value,
newKey: 'movies_id',
newTwoWayKey: 'users_id',
twoWay: true
Expand Down Expand Up @@ -755,25 +755,25 @@ $database->decreaseDocumentAttribute(
// Update the value of an attribute in a document

// Set types
Document::SET_TYPE_ASSIGN, // Assign the new value directly
Document::SET_TYPE_APPEND, // Append the new value to end of the array
Document::SET_TYPE_PREPEND // Prepend the new value to start of the array
SetType::Assign, // Assign the new value directly
SetType::Append, // Append the new value to end of the array
SetType::Prepend // Prepend the new value to start of the array
Note: Using append/prepend with an attribute which is not an array, it will be set to an array containing the new value.

$document->setAttribute(key: 'name', 'Chris Smoove')
->setAttribute(key: 'age', 33, Document::SET_TYPE_ASSIGN);
->setAttribute(key: 'age', 33, SetType::Assign);

$database->updateDocument(
collection: 'users',
id: $document->getId(),
collection: 'users',
id: $document->getId(),
document: $document
);
);

// Update the permissions of a document
$document->setAttribute('$permissions', Permission::read(Role::any()), Document::SET_TYPE_APPEND)
->setAttribute('$permissions', Permission::create(Role::any()), Document::SET_TYPE_APPEND)
->setAttribute('$permissions', Permission::update(Role::any()), Document::SET_TYPE_APPEND)
->setAttribute('$permissions', Permission::delete(Role::any()), Document::SET_TYPE_APPEND)
$document->setAttribute('$permissions', Permission::read(Role::any()), SetType::Append)
->setAttribute('$permissions', Permission::create(Role::any()), SetType::Append)
->setAttribute('$permissions', Permission::update(Role::any()), SetType::Append)
->setAttribute('$permissions', Permission::delete(Role::any()), SetType::Append)

$database->updateDocument(
collection: 'users',
Expand Down
3 changes: 2 additions & 1 deletion bin/tasks/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@
],
];

if (!isset($dbAdapters[$adapter])) {
if (! isset($dbAdapters[$adapter])) {
Console::error("Adapter '{$adapter}' not supported");

return;
}

Expand Down
28 changes: 12 additions & 16 deletions bin/tasks/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
$genresPool = ['fashion', 'food', 'travel', 'music', 'lifestyle', 'fitness', 'diy', 'sports', 'finance'];
$tagsPool = ['short', 'quick', 'easy', 'medium', 'hard'];


/**
* @Example
* docker compose exec tests bin/load --adapter=mariadb --limit=1000
Expand All @@ -35,11 +34,10 @@
->desc('Load database with mock data for testing')
->param('adapter', '', new Text(0), 'Database adapter')
->param('limit', 0, new Integer(true), 'Total number of records to add to database')
->param('name', 'myapp_' . uniqid(), new Text(0), 'Name of created database.', true)
->param('name', 'myapp_'.uniqid(), new Text(0), 'Name of created database.', true)
->param('sharedTables', false, new Boolean(true), 'Whether to use shared tables', true)
->action(function (string $adapter, int $limit, string $name, bool $sharedTables) {


$createSchema = function (Database $database): void {
if ($database->exists($database->getDatabase())) {
$database->delete($database->getDatabase());
Expand All @@ -61,14 +59,13 @@
$database->createIndex('articles', 'text', Database::INDEX_FULLTEXT, ['text']);
};


$start = null;
$namespace = '_ns';
$cache = new Cache(new NoCache());

Console::info("Filling {$adapter} with {$limit} records: {$name}");

//Runtime::enableCoroutine();
// Runtime::enableCoroutine();

$dbAdapters = [
'mariadb' => [
Expand Down Expand Up @@ -103,15 +100,16 @@
],
];

if (!isset($dbAdapters[$adapter])) {
if (! isset($dbAdapters[$adapter])) {
Console::error("Adapter '{$adapter}' not supported");

return;
}

$cfg = $dbAdapters[$adapter];
$dsn = ($cfg['dsn'])($cfg['host'], $cfg['port']);

//Co\run(function () use (&$start, $limit, $name, $sharedTables, $namespace, $cache, $cfg) {
// Co\run(function () use (&$start, $limit, $name, $sharedTables, $namespace, $cache, $cfg) {
$pdo = new PDO(
$dsn,
$cfg['user'],
Expand All @@ -132,7 +130,7 @@
->withHost($cfg['host'])
->withPort($cfg['port'])
->withDbName($name)
//->withCharset('utf8mb4')
// ->withCharset('utf8mb4')
->withUsername($cfg['user'])
->withPassword($cfg['pass']),
128
Expand All @@ -141,29 +139,27 @@
$start = \microtime(true);

for ($i = 0; $i < $limit / 1000; $i++) {
//\go(function () use ($cfg, $pool, $name, $namespace, $sharedTables, $cache) {
// \go(function () use ($cfg, $pool, $name, $namespace, $sharedTables, $cache) {
try {
//$pdo = $pool->get();
// $pdo = $pool->get();

$database = (new Database(new ($cfg['adapter'])($pdo), $cache))
->setDatabase($name)
->setNamespace($namespace)
->setSharedTables($sharedTables);

createDocuments($database);
//$pool->put($pdo);
// $pool->put($pdo);
} catch (\Throwable $error) {
Console::error('Coroutine error: ' . $error->getMessage());
Console::error('Coroutine error: '.$error->getMessage());
}
//});
// });
}

$time = microtime(true) - $start;
Console::success("Completed in {$time} seconds");
});



function createDocuments(Database $database): void
{
global $namesPool, $genresPool, $tagsPool;
Expand All @@ -176,7 +172,7 @@ function createDocuments(Database $database): void
$bytes = \random_bytes(intdiv($length + 1, 2));
$text = \substr(\bin2hex($bytes), 0, $length);
$tagCount = \mt_rand(1, count($tagsPool));
$tagKeys = (array)\array_rand($tagsPool, $tagCount);
$tagKeys = (array) \array_rand($tagsPool, $tagCount);
$tags = \array_map(fn ($k) => $tagsPool[$k], $tagKeys);

$documents[] = new Document([
Expand Down
Loading