Skip to content

Commit 2e5d6b9

Browse files
ScottSpittleFlambe
authored andcommitted
Merge latest (#4)
* 👷 Travis * Add arg PHP-VERSION in Dockerfile * Delete empty row * Add build arg in docker-compose.yml * Add changes to Dcokerfile * Separate installing vendors by composer use official image of composer * Delete use composer image * Add default value PHP_VERSION * 🐳 Provide default docker arg * Fix issue using query builder first method * EmbedsMany respect primaryKey on association * fix typos * laravel/lumen 5.7.14 compatibility Updated model to be compatible with laravel/lumen 5.7.14 * Overrided whereIn method retrieval for relations, to force use standart whereIn nor whereInRawInteger * fix bug The main solution is to solve the bugs encountered in using database alone * reassigned getDatabaseName method * Remove dead code * Update Model.php * Update supported versions * Require Laravel 5.8 * Fix tests (mongodb#1724) *   Update Dockerfile, add for methods setUp and tearDown return type hint in all tests, replace fire on dispatch * Resolve error test with touch * Use COMPOSER_VERSION in Dockerfile * Add alias for composer * Change parent method's names Broken commit in laravel: laravel/framework@2ee1892 * Remove changes in .travis.yml * Remove changes from Dockerfile * Revert changes in docker-compose.yml * Update image with mysql * 🐳 New travis docker setup * Update phpunit.xml (mongodb#1733) * Add arg options for creating collections with options (mongodb#1734) * fix chunkById for types other than ObjectId and laravel >= 5.6.25 (mongodb#1543) * Adds support for _id of binary type (mongodb#1611) * Create FUNDING.yml * Update FUNDING.yml * Update FUNDING.yml * Add hasIndex and dropIndexIfExists methods * Revert changes in Builder and Model for id keys, fix test for Queue (mongodb#1795) * Revert changes in Builder and Model for id keys, fix test for Queue * Fix format in Model * Get base query before update so that scopes are applied (mongodb#1799) Fixes mongodb#1798 * Return proper value instead of _id on QueryBuilder (mongodb#1747) Fixes mongodb#1741 * fix for non string id * use env values from phpunit.xml, update database.php and queue.php (mongodb#1738) * use env values from phpunit.xml, update database.php and queue.php * Add .editorconfig * Update QueueTest.php * Update phpunit.xml.dist * Use in casting instead intval * Change operator (-> to ::) * Code cleanup * Add hasIndex and dropIndexIfExists methods * ⬆️ Support for laravel 6 * ♻️ Make tests compatible with latest phpunit version * 🚨 Linting * ✅ Replace str_random usage * Update src/Jenssegers/Mongodb/Relations/EmbedsMany.php Co-Authored-By: Jens Segers <segers.jens@gmail.com> * fix filtering with operator not like issue * replcae string operation with exact match of (not like) * add test to not like oepration fix * fix regex demo code
1 parent 6c95962 commit 2e5d6b9

Some content is hidden

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

67 files changed

+1378
-943
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true

.github/FUNDING.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github: jenssegers
2+
open_collective: laravel-mongodb

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ composer.lock
77
*.sublime-workspace
88
*.project
99
.idea/
10+
.phpunit.result.cache

.travis.yml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
1-
sudo: required
2-
dist: trusty
3-
language: php
4-
php:
5-
- "7.2"
6-
- "7.1"
1+
language: minimal
2+
3+
matrix:
4+
include:
5+
- name: "7.1"
6+
env: PHP_VERSION=7.1
7+
- name: "7.2"
8+
env: PHP_VERSION=7.2
9+
- name: "7.3"
10+
env: PHP_VERSION=7.3
711

812
services:
913
- docker
1014

15+
cache:
16+
directories:
17+
- $HOME/.composer/cache
18+
1119
install:
1220
- docker version
1321
- sudo pip install docker-compose
1422
- docker-compose version
15-
- sed -i -e "s/php:cli/php:${TRAVIS_PHP_VERSION}-cli/g" Dockerfile
16-
- cat Dockerfile
17-
- docker-compose build
23+
- docker-compose build --build-arg PHP_VERSION=${PHP_VERSION}
24+
- docker-compose run --rm tests composer install --no-interaction
1825

1926
script:
20-
- docker-compose up --exit-code-from php
27+
- docker-compose run --rm tests ./vendor/bin/phpunit --coverage-clover ./clover.xml

Dockerfile

Lines changed: 0 additions & 14 deletions
This file was deleted.

README.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ composer require jenssegers/mongodb
4343
5.4.x | 3.2.x
4444
5.5.x | 3.3.x
4545
5.6.x | 3.4.x
46+
5.7.x | 3.4.x
47+
5.8.x | 3.5.x
4648

4749
And add the service provider in `config/app.php`:
4850

@@ -63,8 +65,10 @@ The service provider will register a mongodb database extension with the origina
6365
For usage outside Laravel, check out the [Capsule manager](https://github.com/illuminate/database/blob/master/README.md) and add:
6466

6567
```php
66-
$capsule->getDatabaseManager()->extend('mongodb', function($config)
68+
$capsule->getDatabaseManager()->extend('mongodb', function($config, $name)
6769
{
70+
$config['name'] = $name;
71+
6872
return new Jenssegers\Mongodb\Connection($config);
6973
});
7074
```
@@ -298,7 +302,7 @@ This service provider will slightly modify the internal DatabaseReminderReposito
298302

299303
### Queues
300304

301-
If you want to use MongoDB as your database backend, change the the driver in `config/queue.php`:
305+
If you want to use MongoDB as your database backend, change the driver in `config/queue.php`:
302306

303307
```php
304308
'connections' => [
@@ -480,7 +484,7 @@ User::where('name', 'Jaques')->decrement('weight', 50);
480484
The number of updated objects is returned:
481485

482486
```php
483-
$count = User->increment('age');
487+
$count = User::increment('age');
484488
```
485489

486490
You may also specify additional columns to update:
@@ -545,13 +549,13 @@ User::where('name', 'regex', new \MongoDB\BSON\Regex("/.*doe/i"))->get();
545549
**NOTE:** you can also use the Laravel regexp operations. These are a bit more flexible and will automatically convert your regular expression string to a MongoDB\BSON\Regex object.
546550

547551
```php
548-
User::where('name', 'regexp', '/.*doe/i'))->get();
552+
User::where('name', 'regexp', '/.*doe/i')->get();
549553
```
550554

551555
And the inverse:
552556

553557
```php
554-
User::where('name', 'not regexp', '/.*doe/i'))->get();
558+
User::where('name', 'not regexp', '/.*doe/i')->get();
555559
```
556560

557561
**Type**
@@ -689,7 +693,7 @@ For more information about model manipulation, check http://laravel.com/docs/elo
689693

690694
### Dates
691695

692-
Eloquent allows you to work with Carbon/DateTime objects instead of MongoDate objects. Internally, these dates will be converted to MongoDate objects when saved to the database. If you wish to use this functionality on non-default date fields you will need to manually specify them as described here: http://laravel.com/docs/eloquent#date-mutators
696+
Eloquent allows you to work with Carbon/DateTime objects instead of MongoDate objects. Internally, these dates will be converted to MongoDate objects when saved to the database. If you wish to use this functionality on non-default date fields, you will need to manually specify them as described here: http://laravel.com/docs/eloquent#date-mutators
693697

694698
Example:
695699

@@ -806,7 +810,7 @@ class User extends Eloquent {
806810
}
807811
```
808812

809-
You access the embedded models through the dynamic property:
813+
You can access the embedded models through the dynamic property:
810814

811815
```php
812816
$books = User::first()->books;
@@ -868,7 +872,7 @@ Embedded relations will return a Collection of embedded items instead of a query
868872

869873
### EmbedsOne Relations
870874

871-
The embedsOne relation is similar to the EmbedsMany relation, but only embeds a single model.
875+
The embedsOne relation is similar to the embedsMany relation, but only embeds a single model.
872876

873877
```php
874878
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
@@ -883,7 +887,7 @@ class Book extends Eloquent {
883887
}
884888
```
885889

886-
You access the embedded models through the dynamic property:
890+
You can access the embedded models through the dynamic property:
887891

888892
```php
889893
$author = Book::first()->author;
@@ -1033,7 +1037,7 @@ DB::collection('items')->paginate($limit, $projections);
10331037

10341038
**Push**
10351039

1036-
Add an items to an array.
1040+
Add items to an array.
10371041

10381042
```php
10391043
DB::collection('users')->where('name', 'John')->push('items', 'boots');

composer.json

Lines changed: 59 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,59 @@
1-
{
2-
"name": "jenssegers/mongodb",
3-
"description": "A MongoDB based Eloquent model and Query builder for Laravel (Moloquent)",
4-
"keywords": ["laravel","eloquent","mongodb","mongo","database","model","moloquent"],
5-
"homepage": "https://github.com/jenssegers/laravel-mongodb",
6-
"authors": [
7-
{
8-
"name": "Jens Segers",
9-
"homepage": "https://jenssegers.com"
10-
}
11-
],
12-
"license" : "MIT",
13-
"require": {
14-
"illuminate/support": "^5.6",
15-
"illuminate/container": "^5.6",
16-
"illuminate/database": "^5.6",
17-
"illuminate/events": "^5.6",
18-
"mongodb/mongodb": "^1.0.0"
19-
},
20-
"require-dev": {
21-
"phpunit/phpunit": "^6.0|^7.0",
22-
"orchestra/testbench": "^3.1",
23-
"mockery/mockery": "^1.0",
24-
"satooshi/php-coveralls": "^2.0",
25-
"doctrine/dbal": "^2.5"
26-
},
27-
"autoload": {
28-
"psr-0": {
29-
"Jenssegers\\Mongodb": "src/"
30-
}
31-
},
32-
"autoload-dev": {
33-
"classmap": [
34-
"tests/TestCase.php",
35-
"tests/models",
36-
"tests/seeds"
37-
]
38-
},
39-
"suggest": {
40-
"jenssegers/mongodb-session": "Add MongoDB session support to Laravel-MongoDB",
41-
"jenssegers/mongodb-sentry": "Add Sentry support to Laravel-MongoDB"
42-
},
43-
"extra": {
44-
"laravel": {
45-
"providers": [
46-
"Jenssegers\\Mongodb\\MongodbServiceProvider",
47-
"Jenssegers\\Mongodb\\MongodbQueueServiceProvider"
48-
]
49-
}
50-
}
51-
}
1+
{
2+
"name": "jenssegers/mongodb",
3+
"description": "A MongoDB based Eloquent model and Query builder for Laravel (Moloquent)",
4+
"keywords": [
5+
"laravel",
6+
"eloquent",
7+
"mongodb",
8+
"mongo",
9+
"database",
10+
"model",
11+
"moloquent"
12+
],
13+
"homepage": "https://github.com/jenssegers/laravel-mongodb",
14+
"authors": [
15+
{
16+
"name": "Jens Segers",
17+
"homepage": "https://jenssegers.com"
18+
}
19+
],
20+
"license": "MIT",
21+
"require": {
22+
"illuminate/support": "^5.8|^6.0",
23+
"illuminate/container": "^5.8|^6.0",
24+
"illuminate/database": "^5.8|^6.0",
25+
"illuminate/events": "^5.8|^6.0",
26+
"mongodb/mongodb": "^1.4"
27+
},
28+
"require-dev": {
29+
"phpunit/phpunit": "^6.0|^7.0|^8.0",
30+
"orchestra/testbench": "^3.1|^4.0",
31+
"mockery/mockery": "^1.0",
32+
"satooshi/php-coveralls": "^2.0",
33+
"doctrine/dbal": "^2.5"
34+
},
35+
"autoload": {
36+
"psr-0": {
37+
"Jenssegers\\Mongodb": "src/"
38+
}
39+
},
40+
"autoload-dev": {
41+
"classmap": [
42+
"tests/TestCase.php",
43+
"tests/models",
44+
"tests/seeds"
45+
]
46+
},
47+
"suggest": {
48+
"jenssegers/mongodb-session": "Add MongoDB session support to Laravel-MongoDB",
49+
"jenssegers/mongodb-sentry": "Add Sentry support to Laravel-MongoDB"
50+
},
51+
"extra": {
52+
"laravel": {
53+
"providers": [
54+
"Jenssegers\\Mongodb\\MongodbServiceProvider",
55+
"Jenssegers\\Mongodb\\MongodbQueueServiceProvider"
56+
]
57+
}
58+
}
59+
}

docker-compose.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
version: '3'
22

33
services:
4-
5-
php:
6-
container_name: php
4+
tests:
5+
container_name: tests
76
build:
87
context: .
98
dockerfile: Dockerfile
109
volumes:
1110
- .:/code
1211
working_dir: /code
13-
command: bash -c "composer install --prefer-source --no-interaction && php ./vendor/bin/phpunit"
1412
depends_on:
15-
- mysql
1613
- mongodb
14+
- mysql
1715

1816
mysql:
1917
container_name: mysql
20-
image: mysql
18+
image: mysql:5.7
2119
environment:
2220
MYSQL_ROOT_PASSWORD:
2321
MYSQL_DATABASE: unittest
@@ -28,5 +26,7 @@ services:
2826
mongodb:
2927
container_name: mongodb
3028
image: mongo
29+
ports:
30+
- 27017:27017
3131
logging:
3232
driver: none

phpunit.xml.dist

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,46 @@
77
convertNoticesToExceptions="true"
88
convertWarningsToExceptions="true"
99
processIsolation="false"
10-
stopOnFailure="false"
11-
syntaxCheck="false"
12-
verbose="true"
13-
>
10+
stopOnFailure="false">
1411
<testsuites>
1512
<testsuite name="all">
1613
<directory>tests/</directory>
17-
<exclude>tests/MysqlRelationsTest.php</exclude>
1814
</testsuite>
1915
<testsuite name="schema">
20-
<directory>tests/SchemaTest.php</directory>
16+
<file>tests/SchemaTest.php</file>
2117
</testsuite>
2218
<testsuite name="seeder">
23-
<directory>tests/SeederTest.php</directory>
19+
<file>tests/SeederTest.php</file>
2420
</testsuite>
2521
<testsuite name="cache">
26-
<directory>tests/CacheTest.php</directory>
22+
<file>tests/CacheTest.php</file>
2723
</testsuite>
2824
<testsuite name="builder">
29-
<directory>tests/QueryBuilderTest.php</directory>
30-
<directory>tests/QueryTest.php</directory>
25+
<file>tests/QueryBuilderTest.php</file>
26+
<file>tests/QueryTest.php</file>
3127
</testsuite>
3228
<testsuite name="model">
33-
<directory>tests/ModelTest.php</directory>
34-
<directory>tests/RelationsTest.php</directory>
29+
<file>tests/ModelTest.php</file>
30+
<file>tests/RelationsTest.php</file>
3531
</testsuite>
3632
<testsuite name="relations">
37-
<directory>tests/RelationsTest.php</directory>
38-
<directory>tests/EmbeddedRelationsTest.php</directory>
33+
<file>tests/RelationsTest.php</file>
34+
<file>tests/EmbeddedRelationsTest.php</file>
3935
</testsuite>
4036
<testsuite name="mysqlrelations">
41-
<directory>tests/RelationsTest.php</directory>
42-
<directory>tests/MysqlRelationsTest.php</directory>
37+
<file>tests/RelationsTest.php</file>
4338
</testsuite>
4439
<testsuite name="validation">
45-
<directory>tests/ValidationTest.php</directory>
40+
<file>tests/ValidationTest.php</file>
4641
</testsuite>
4742
</testsuites>
43+
<php>
44+
<env name="MONGO_HOST" value="mongodb"/>
45+
<env name="MONGO_DATABASE" value="unittest"/>
46+
<env name="MONGO_PORT" value="27017"/>
47+
<env name="MYSQL_HOST" value="mysql"/>
48+
<env name="MYSQL_DATABASE" value="unittest"/>
49+
<env name="MYSQL_USERNAME" value="root"/>
50+
<env name="QUEUE_CONNECTION" value="database"/>
51+
</php>
4852
</phpunit>

0 commit comments

Comments
 (0)