Skip to content

Commit b5ab1f8

Browse files
authored
Merge branch '4.7' into 4.5
2 parents ca0285f + 5e8dcfb commit b5ab1f8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+2105
-1061
lines changed

.github/workflows/coding-standards.yml

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -67,59 +67,3 @@ jobs:
6767
uses: stefanzweifel/git-auto-commit-action@v5
6868
with:
6969
commit_message: "apply phpcbf formatting"
70-
71-
analysis:
72-
runs-on: "ubuntu-22.04"
73-
continue-on-error: true
74-
strategy:
75-
matrix:
76-
php:
77-
- '8.1'
78-
- '8.2'
79-
steps:
80-
- name: Checkout
81-
uses: actions/checkout@v4
82-
83-
- name: Setup PHP
84-
uses: shivammathur/setup-php@v2
85-
with:
86-
php-version: ${{ matrix.php }}
87-
extensions: curl, mbstring
88-
tools: composer:v2
89-
coverage: none
90-
91-
- name: Cache dependencies
92-
id: composer-cache
93-
uses: actions/cache@v4
94-
with:
95-
path: ./vendor
96-
key: composer-${{ hashFiles('**/composer.lock') }}
97-
98-
- name: Install dependencies
99-
run: composer install
100-
101-
- name: Restore cache PHPStan results
102-
id: phpstan-cache-restore
103-
uses: actions/cache/restore@v4
104-
with:
105-
path: .cache
106-
key: "phpstan-result-cache-${{ github.run_id }}"
107-
restore-keys: |
108-
phpstan-result-cache-
109-
110-
- name: Run PHPStan
111-
run: ./vendor/bin/phpstan analyse --no-interaction --no-progress --ansi --error-format=sarif > phpstan.sarif
112-
113-
- name: "Upload SARIF report"
114-
if: always()
115-
uses: "github/codeql-action/upload-sarif@v3"
116-
with:
117-
sarif_file: phpstan.sarif
118-
119-
- name: Save cache PHPStan results
120-
id: phpstan-cache-save
121-
if: always()
122-
uses: actions/cache/save@v4
123-
with:
124-
path: .cache
125-
key: ${{ steps.phpstan-cache-restore.outputs.cache-primary-key }}

.github/workflows/release.yml

Lines changed: 60 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,11 @@ jobs:
2222
- name: "Create release output"
2323
run: echo '🎬 Release process for version ${{ inputs.version }} started by @${{ github.triggering_actor }}' >> $GITHUB_STEP_SUMMARY
2424

25-
- name: "Create temporary app token"
26-
uses: actions/create-github-app-token@v1
27-
id: app-token
25+
- name: "Generate token and checkout repository"
26+
uses: mongodb-labs/drivers-github-tools/secure-checkout@v2
2827
with:
29-
app-id: ${{ vars.APP_ID }}
30-
private-key: ${{ secrets.APP_PRIVATE_KEY }}
31-
32-
- name: "Store GitHub token in environment"
33-
run: echo "GH_TOKEN=${{ steps.app-token.outputs.token }}" >> "$GITHUB_ENV"
34-
shell: bash
35-
36-
- uses: actions/checkout@v4
37-
with:
38-
submodules: true
39-
token: ${{ env.GH_TOKEN }}
28+
app_id: ${{ vars.APP_ID }}
29+
private_key: ${{ secrets.APP_PRIVATE_KEY }}
4030

4131
- name: "Store version numbers in env variables"
4232
run: |
@@ -71,11 +61,11 @@ jobs:
7161
- name: "Create draft release"
7262
run: echo "RELEASE_URL=$(gh release create ${{ inputs.version }} --target ${{ github.ref_name }} --title "${{ inputs.version }}" --generate-notes --draft)" >> "$GITHUB_ENV"
7363

74-
# This step creates the signed release tag
7564
- name: "Create release tag"
76-
uses: mongodb-labs/drivers-github-tools/git-sign@v2
65+
uses: mongodb-labs/drivers-github-tools/tag-version@v2
7766
with:
78-
command: "git tag -m 'Release ${{ inputs.version }}' -s --local-user=${{ env.GPG_KEY_ID }} ${{ inputs.version }}"
67+
version: ${{ inputs.version }}
68+
tag_message_template: 'Release ${VERSION}'
7969

8070
# TODO: Manually merge using ours strategy. This avoids merge-up pull requests being created
8171
# Process is:
@@ -84,14 +74,60 @@ jobs:
8474
# 3. push next branch
8575
# 4. switch back to release branch, then push
8676

87-
- name: "Push changes from release branch"
88-
run: git push
89-
90-
# Pushing the release tag starts build processes that then produce artifacts for the release
91-
- name: "Push release tag"
92-
run: git push origin ${{ inputs.version }}
93-
9477
- name: "Set summary"
9578
run: |
9679
echo '🚀 Created tag and drafted release for version [${{ inputs.version }}](${{ env.RELEASE_URL }})' >> $GITHUB_STEP_SUMMARY
9780
echo '✍️ You may now update the release notes and publish the release when ready' >> $GITHUB_STEP_SUMMARY
81+
82+
static-analysis:
83+
needs: prepare-release
84+
name: "Run Static Analysis"
85+
uses: ./.github/workflows/static-analysis.yml
86+
with:
87+
ref: refs/tags/${{ inputs.version }}
88+
permissions:
89+
security-events: write
90+
id-token: write
91+
92+
publish-ssdlc-assets:
93+
needs: static-analysis
94+
environment: release
95+
name: "Publish SSDLC Assets"
96+
runs-on: ubuntu-latest
97+
permissions:
98+
security-events: read
99+
id-token: write
100+
contents: write
101+
102+
steps:
103+
- name: "Generate token and checkout repository"
104+
uses: mongodb-labs/drivers-github-tools/secure-checkout@v2
105+
with:
106+
app_id: ${{ vars.APP_ID }}
107+
private_key: ${{ secrets.APP_PRIVATE_KEY }}
108+
ref: refs/tags/${{ inputs.version }}
109+
110+
# Sets the S3_ASSETS environment variable used later
111+
- name: "Set up drivers-github-tools"
112+
uses: mongodb-labs/drivers-github-tools/setup@v2
113+
with:
114+
aws_role_arn: ${{ secrets.AWS_ROLE_ARN }}
115+
aws_region_name: ${{ vars.AWS_REGION_NAME }}
116+
aws_secret_id: ${{ secrets.AWS_SECRET_ID }}
117+
118+
- name: "Generate SSDLC Reports"
119+
uses: mongodb-labs/drivers-github-tools/full-report@v2
120+
with:
121+
product_name: "MongoDB Laravel Integration"
122+
release_version: ${{ inputs.version }}
123+
silk_asset_group: mongodb-laravel-integration
124+
125+
- name: "Upload SBOM as release artifact"
126+
run: gh release upload ${{ inputs.version }} ${{ env.S3_ASSETS }}/cyclonedx.sbom.json
127+
continue-on-error: true
128+
129+
- name: Upload S3 assets
130+
uses: mongodb-labs/drivers-github-tools/upload-s3-assets@v2
131+
with:
132+
version: ${{ inputs.version }}
133+
product_name: laravel-mongodb

.github/workflows/static-analysis.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: "Static Analysis"
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_call:
7+
inputs:
8+
ref:
9+
description: "The git ref to check"
10+
type: string
11+
required: true
12+
13+
env:
14+
PHP_VERSION: "8.2"
15+
DRIVER_VERSION: "stable"
16+
17+
jobs:
18+
phpstan:
19+
runs-on: "ubuntu-22.04"
20+
continue-on-error: true
21+
strategy:
22+
matrix:
23+
php:
24+
- '8.1'
25+
- '8.2'
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
with:
30+
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.ref || github.ref }}
31+
32+
- name: "Get SHA hash of checked out ref"
33+
if: ${{ github.event_name == 'workflow_dispatch' }}
34+
run: |
35+
echo CHECKED_OUT_SHA=$(git rev-parse HEAD) >> $GITHUB_ENV
36+
37+
- name: Setup PHP
38+
uses: shivammathur/setup-php@v2
39+
with:
40+
php-version: ${{ matrix.php }}
41+
extensions: curl, mbstring
42+
tools: composer:v2
43+
coverage: none
44+
45+
- name: Cache dependencies
46+
id: composer-cache
47+
uses: actions/cache@v4
48+
with:
49+
path: ./vendor
50+
key: composer-${{ hashFiles('**/composer.lock') }}
51+
52+
- name: Install dependencies
53+
run: composer install
54+
55+
- name: Restore cache PHPStan results
56+
id: phpstan-cache-restore
57+
uses: actions/cache/restore@v4
58+
with:
59+
path: .cache
60+
key: "phpstan-result-cache-${{ matrix.php }}-${{ github.run_id }}"
61+
restore-keys: |
62+
phpstan-result-cache-
63+
64+
- name: Run PHPStan
65+
run: ./vendor/bin/phpstan analyse --no-interaction --no-progress --ansi --error-format=sarif > phpstan.sarif
66+
continue-on-error: true
67+
68+
- name: "Upload SARIF report"
69+
if: ${{ github.event_name != 'workflow_dispatch' }}
70+
uses: "github/codeql-action/upload-sarif@v3"
71+
with:
72+
sarif_file: phpstan.sarif
73+
74+
- name: "Upload SARIF report"
75+
if: ${{ github.event_name == 'workflow_dispatch' }}
76+
uses: "github/codeql-action/upload-sarif@v3"
77+
with:
78+
sarif_file: phpstan.sarif
79+
ref: ${{ inputs.ref }}
80+
sha: ${{ env.CHECKED_OUT_SHA }}
81+
82+
- name: Save cache PHPStan results
83+
id: phpstan-cache-save
84+
if: always()
85+
uses: actions/cache/save@v4
86+
with:
87+
path: .cache
88+
key: ${{ steps.phpstan-cache-restore.outputs.cache-primary-key }}

CHANGELOG.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4-
## [4.5.0] - upcoming
4+
## [4.7.0] - coming soon
5+
6+
* Add `Connection::getServerVersion()` by @GromNaN in [#3043](https://github.com/mongodb/laravel-mongodb/pull/3043)
7+
* Add `Schema\Builder::getTables()` and `getTableListing()` by @GromNaN in [#3044](https://github.com/mongodb/laravel-mongodb/pull/3044)
8+
* Add `Schema\Builder::getColumns()` and `getIndexes()` by @GromNaN in [#3045](https://github.com/mongodb/laravel-mongodb/pull/3045)
9+
* Add `Schema\Builder::hasColumn` and `hasColumns` method by @Alex-Belyi in [#3002](https://github.com/mongodb/laravel-mongodb/pull/3001)
10+
11+
## [4.6.0] - 2024-07-09
12+
13+
* Add `DocumentModel` trait to use any 3rd party model with MongoDB @GromNaN in [#2580](https://github.com/mongodb/laravel-mongodb/pull/2580)
14+
* Add `HasSchemaVersion` trait to help implementing the [schema versioning pattern](https://www.mongodb.com/docs/manual/tutorial/model-data-for-schema-versioning/) @florianJacques in [#3021](https://github.com/mongodb/laravel-mongodb/pull/3021)
15+
* Add support for Closure for Embed pagination @GromNaN in [#3027](https://github.com/mongodb/laravel-mongodb/pull/3027)
16+
17+
## [4.5.0] - 2024-06-20
18+
19+
* Add GridFS integration for Laravel File Storage by @GromNaN in [#2985](https://github.com/mongodb/laravel-mongodb/pull/2985)
520

6-
* Add GridFS integration for Laravel File Storage by @GromNaN in [#2984](https://github.com/mongodb/laravel-mongodb/pull/2985)
7-
* Add `hasColumn` and `hasColumns` method by @Alex-Belyi in [#3002](https://github.com/mongodb/laravel-mongodb/pull/3001)
821
## [4.4.0] - 2024-05-31
922

1023
* Support collection name prefix by @GromNaN in [#2930](https://github.com/mongodb/laravel-mongodb/pull/2930)

docs/fundamentals/read-operations.txt

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,13 @@ You can use Laravel's Eloquent object-relational mapper (ORM) to create models
5757
that represent MongoDB collections and chain methods on them to specify
5858
query criteria.
5959

60-
To retrieve documents that match a set of criteria, pass a query filter to the
61-
``where()`` method.
60+
To retrieve documents that match a set of criteria, call the ``where()``
61+
method on the collection's corresponding Eloquent model, then pass a query
62+
filter to the method.
6263

6364
A query filter specifies field value requirements and instructs the find
6465
operation to return only documents that meet these requirements.
6566

66-
You can use Laravel's Eloquent object-relational mapper (ORM) to create models
67-
that represent MongoDB collections. To retrieve documents from a collection,
68-
call the ``where()`` method on the collection's corresponding Eloquent model.
69-
7067
You can use one of the following ``where()`` method calls to build a query:
7168

7269
- ``where('<field name>', <value>)`` builds a query that matches documents in
@@ -79,7 +76,7 @@ You can use one of the following ``where()`` method calls to build a query:
7976
To apply multiple sets of criteria to the find operation, you can chain a series
8077
of ``where()`` methods together.
8178

82-
After building your query with the ``where()`` method, chain the ``get()``
79+
After building your query by using the ``where()`` method, chain the ``get()``
8380
method to retrieve the query results.
8481

8582
This example calls two ``where()`` methods on the ``Movie`` Eloquent model to
@@ -150,6 +147,60 @@ retrieve documents that meet the following criteria:
150147
To learn how to query by using the Laravel query builder instead of the
151148
Eloquent ORM, see the :ref:`laravel-query-builder` page.
152149

150+
Match Array Field Elements
151+
~~~~~~~~~~~~~~~~~~~~~~~~~~
152+
153+
You can specify a query filter to match array field elements when
154+
retrieving documents. If your documents contain an array field, you can
155+
match documents based on if the value contains all or some specified
156+
array elements.
157+
158+
You can use one of the following ``where()`` method calls to build a
159+
query on an array field:
160+
161+
- ``where('<array field>', <array>)`` builds a query that matches documents in
162+
which the array field value is exactly the specified array
163+
164+
- ``where('<array field>', 'in', <array>)`` builds a query
165+
that matches documents in which the array field value contains one or
166+
more of the specified array elements
167+
168+
After building your query by using the ``where()`` method, chain the ``get()``
169+
method to retrieve the query results.
170+
171+
Select from the following :guilabel:`Exact Array Match` and
172+
:guilabel:`Element Match` tabs to view the query syntax for each pattern:
173+
174+
.. tabs::
175+
176+
.. tab:: Exact Array Match
177+
:tabid: exact-array
178+
179+
This example retrieves documents in which the ``countries`` array is
180+
exactly ``['Indonesia', 'Canada']``:
181+
182+
.. literalinclude:: /includes/fundamentals/read-operations/ReadOperationsTest.php
183+
:language: php
184+
:dedent:
185+
:start-after: start-exact-array
186+
:end-before: end-exact-array
187+
188+
.. tab:: Element Match
189+
:tabid: element-match
190+
191+
This example retrieves documents in which the ``countries`` array
192+
contains one of the values in the array ``['Canada', 'Egypt']``:
193+
194+
.. literalinclude:: /includes/fundamentals/read-operations/ReadOperationsTest.php
195+
:language: php
196+
:dedent:
197+
:start-after: start-elem-match
198+
:end-before: end-elem-match
199+
200+
To learn how to query array fields by using the Laravel query builder instead of the
201+
Eloquent ORM, see the :ref:`laravel-query-builder-elemMatch` section in
202+
the Query Builder guide.
203+
153204
.. _laravel-retrieve-all:
154205

155206
Retrieve All Documents in a Collection
@@ -200,7 +251,7 @@ by the ``$search`` field in your query filter that you pass to the
200251
``where()`` method. The ``$text`` operator performs a text search on the
201252
text-indexed fields. The ``$search`` field specifies the text to search for.
202253

203-
After building your query with the ``where()`` method, chain the ``get()``
254+
After building your query by using the ``where()`` method, chain the ``get()``
204255
method to retrieve the query results.
205256

206257
This example calls the ``where()`` method on the ``Movie`` Eloquent model to

0 commit comments

Comments
 (0)