-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[8.x] MySQL Builds #39415
[8.x] MySQL Builds #39415
Changes from 24 commits
31a4935
9574005
d7eefd2
58b9589
903e2b0
45518d0
c557679
853e5dd
675c099
edbfc97
d1677f5
923f35b
3939946
a148a64
8e57d1d
c33b439
3d8fe20
c8caab0
07471c8
5f2a79a
7338975
3c1fbff
fb96ca0
1f791f4
b48c479
e12a0da
6408970
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
name: databases | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
mysql_57: | ||
runs-on: ubuntu-20.04 | ||
|
||
services: | ||
mysql: | ||
image: mysql:5.7 | ||
env: | ||
MYSQL_ALLOW_EMPTY_PASSWORD: yes | ||
MYSQL_DATABASE: forge | ||
ports: | ||
- 3306:3306 | ||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
|
||
strategy: | ||
fail-fast: true | ||
|
||
name: MySQL 5.7 | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 8.1 | ||
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql | ||
tools: composer:v2 | ||
coverage: none | ||
|
||
- name: Install dependencies | ||
uses: nick-invision/retry@v1 | ||
with: | ||
timeout_minutes: 5 | ||
max_attempts: 5 | ||
command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress | ||
|
||
- name: Execute tests | ||
run: vendor/bin/phpunit tests/Integration/Database --verbose | ||
env: | ||
DB_CONNECTION: mysql | ||
DB_USERNAME: root | ||
|
||
mysql_8: | ||
runs-on: ubuntu-20.04 | ||
|
||
services: | ||
mysql: | ||
image: mysql:8 | ||
env: | ||
MYSQL_ALLOW_EMPTY_PASSWORD: yes | ||
MYSQL_DATABASE: forge | ||
ports: | ||
- 3306:3306 | ||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
|
||
strategy: | ||
fail-fast: true | ||
|
||
name: MySQL 8.0 | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 8.1 | ||
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql | ||
tools: composer:v2 | ||
coverage: none | ||
|
||
- name: Install dependencies | ||
uses: nick-invision/retry@v1 | ||
with: | ||
timeout_minutes: 5 | ||
max_attempts: 5 | ||
command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress | ||
|
||
- name: Execute tests | ||
run: vendor/bin/phpunit tests/Integration/Database --verbose | ||
env: | ||
DB_CONNECTION: mysql | ||
DB_USERNAME: root |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,7 @@ protected function setUp(): void | |
|
||
Schema::create('posts_tags', function (Blueprint $table) { | ||
$table->integer('post_id'); | ||
$table->integer('tag_id'); | ||
$table->string('tag_id'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In one test we're storing the |
||
$table->string('flag')->default('')->nullable(); | ||
$table->timestamps(); | ||
}); | ||
|
@@ -132,7 +132,7 @@ public function testCustomPivotClass() | |
$post->tagsWithCustomPivot()->attach($tag->id); | ||
|
||
$this->assertInstanceOf(PostTagPivot::class, $post->tagsWithCustomPivot[0]->pivot); | ||
$this->assertEquals('1507630210', $post->tagsWithCustomPivot[0]->pivot->getAttributes()['created_at']); | ||
$this->assertEquals('1507630210', $post->tagsWithCustomPivot[0]->pivot->created_at); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Switch to an accessor instead of relying on SQLite's |
||
|
||
$this->assertInstanceOf(PostTagPivot::class, $post->tagsWithCustomPivotClass[0]->pivot); | ||
$this->assertSame('posts_tags', $post->tagsWithCustomPivotClass()->getTable()); | ||
|
@@ -213,8 +213,8 @@ public function testCustomPivotClassUpdatesTimestamps() | |
DB::table('posts_tags')->insert([ | ||
[ | ||
'post_id' => $post->id, 'tag_id' => $tag->id, 'flag' => 'empty', | ||
'created_at' => '1507630210', | ||
'updated_at' => '1507630210', | ||
'created_at' => '2017-10-10 10:10:10', | ||
'updated_at' => '2017-10-10 10:10:10', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use universal date formats instead of SQLite specific timestamps. |
||
], | ||
]); | ||
|
||
|
@@ -226,8 +226,8 @@ public function testCustomPivotClassUpdatesTimestamps() | |
); | ||
foreach ($post->tagsWithCustomExtraPivot as $tag) { | ||
$this->assertSame('exclude', $tag->pivot->flag); | ||
$this->assertEquals('1507630210', $tag->pivot->getAttributes()['created_at']); | ||
$this->assertEquals('1507630220', $tag->pivot->getAttributes()['updated_at']); // +10 seconds | ||
$this->assertEquals('2017-10-10 10:10:10', $tag->pivot->getAttributes()['created_at']); | ||
$this->assertEquals('2017-10-10 10:10:20', $tag->pivot->getAttributes()['updated_at']); // +10 seconds | ||
} | ||
} | ||
|
||
|
@@ -1068,7 +1068,11 @@ class UserPostPivot extends Pivot | |
class PostTagPivot extends Pivot | ||
{ | ||
protected $table = 'posts_tags'; | ||
protected $dateFormat = 'U'; | ||
|
||
public function getCreatedAtAttribute($value) | ||
{ | ||
return Carbon::parse($value)->format('U'); | ||
} | ||
} | ||
|
||
class TagWithGlobalScope extends Model | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -180,7 +180,7 @@ public function testPaginationWithDistinctColumnsAndSelect() | |
TestPost::create(['title' => 'Goodbye world']); | ||
} | ||
|
||
$query = TestPost::query()->distinct('title')->select('title'); | ||
$query = TestPost::query()->orderBy('title')->distinct('title')->select('title'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cursor based pagination relies on an orderBy clause when selecting specific columns. |
||
|
||
$this->assertEquals(2, $query->get()->count()); | ||
$this->assertEquals(2, $query->count()); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,20 +45,20 @@ public function testDatesFormattedAttributeBindings() | |
$bindings = $query->bindings; | ||
}); | ||
|
||
$user = TestModel1::create([ | ||
'date_field' => '2019-10', | ||
TestModel1::create([ | ||
'date_field' => '2019-10-01', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Date fields in most engines need a full date to be inserted. |
||
'datetime_field' => '2019-10-01 10:15:20', | ||
'immutable_date_field' => '2019-10-01', | ||
'immutable_datetime_field' => '2019-10-01 10:15', | ||
]); | ||
|
||
$this->assertSame(['2019-10', '2019-10-01 10:15:20', '2019-10-01', '2019-10-01 10:15'], $bindings); | ||
$this->assertSame(['2019-10-01', '2019-10-01 10:15:20', '2019-10-01', '2019-10-01 10:15'], $bindings); | ||
} | ||
|
||
public function testDatesFormattedArrayAndJson() | ||
{ | ||
$user = TestModel1::create([ | ||
'date_field' => '2019-10', | ||
'date_field' => '2019-10-01', | ||
'datetime_field' => '2019-10-01 10:15:20', | ||
'immutable_date_field' => '2019-10-01', | ||
'immutable_datetime_field' => '2019-10-01 10:15', | ||
|
@@ -78,7 +78,6 @@ public function testDatesFormattedArrayAndJson() | |
|
||
public function testCustomDateCastsAreComparedAsDatesForCarbonInstances() | ||
{ | ||
/** @var TestModel1 */ | ||
$user = TestModel1::create([ | ||
'date_field' => '2019-10-01', | ||
'datetime_field' => '2019-10-01 10:15:20', | ||
|
@@ -99,7 +98,6 @@ public function testCustomDateCastsAreComparedAsDatesForCarbonInstances() | |
|
||
public function testCustomDateCastsAreComparedAsDatesForStringValues() | ||
{ | ||
/** @var TestModel1 */ | ||
$user = TestModel1::create([ | ||
'date_field' => '2019-10-01', | ||
'datetime_field' => '2019-10-01 10:15:20', | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we're not running an in-memory database anymore we'll need to wipe the database each time after every test. I want to refactor this to a RefreshDatabase trait later on but for now this is okay.