Skip to content

Commit

Permalink
Merge 6c3d4c2 into 53c1ca8
Browse files Browse the repository at this point in the history
  • Loading branch information
othercorey committed Jan 23, 2020
2 parents 53c1ca8 + 6c3d4c2 commit eff7d0e
Show file tree
Hide file tree
Showing 13 changed files with 97 additions and 90 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ jobs:
- 5432/tcp

steps:
- name: Setup mysql 8
if: matrix.db-type == 'mysql'
run: |
sudo service mysql stop
docker run --rm --name=mysqld -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -e MYSQL_DATABASE=cakephp --tmpfs /var/lib/mysql:rw --network=host -d mysql --default-authentication-plugin=mysql_native_password --disable-log-bin --innodb-flush-method=O_DIRECT_NO_FSYNC
- uses: actions/checkout@v1
with:
fetch-depth: 1
Expand Down Expand Up @@ -58,10 +64,8 @@ jobs:
env:
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
run: |
if [ ${{ matrix.db-type }} == 'mysql' ]; then mysql -u root -proot -e 'CREATE DATABASE cakephp_test;'; fi
if [[ ${{ matrix.db-type }} == 'sqlite' ]]; then export DB_DSN='sqlite:///:memory:'; fi
if [[ ${{ matrix.db-type }} == 'mysql' ]]; then export DB_DSN='mysql://root:root@127.0.0.1/cakephp_test?init[]=SET sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"'; fi
if [[ ${{ matrix.db-type }} == 'mysql' ]]; then export DB_DSN='mysql://root@127.0.0.1/cakephp?init[]=SET sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"'; fi
if [[ ${{ matrix.db-type }} == 'pgsql' ]]; then export DB_DSN='postgres://postgres@127.0.0.1:${{ job.services.postgres.ports['5432'] }}/postgres'; fi
if [[ ${{ matrix.php-version }} == '7.2' ]]; then
Expand Down
11 changes: 6 additions & 5 deletions src/Database/Schema/MysqlSchemaDialect.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,16 @@ protected function _convertColumn(string $column): array

$unsigned = (isset($matches[3]) && strtolower($matches[3]) === 'unsigned');
if (strpos($col, 'bigint') !== false || $col === 'bigint') {
return ['type' => TableSchema::TYPE_BIGINTEGER, 'length' => $length, 'unsigned' => $unsigned];
return ['type' => TableSchema::TYPE_BIGINTEGER, 'length' => null, 'unsigned' => $unsigned];
}
if ($col === 'tinyint') {
return ['type' => TableSchema::TYPE_TINYINTEGER, 'length' => $length, 'unsigned' => $unsigned];
return ['type' => TableSchema::TYPE_TINYINTEGER, 'length' => null, 'unsigned' => $unsigned];
}
if ($col === 'smallint') {
return ['type' => TableSchema::TYPE_SMALLINTEGER, 'length' => $length, 'unsigned' => $unsigned];
return ['type' => TableSchema::TYPE_SMALLINTEGER, 'length' => null, 'unsigned' => $unsigned];
}
if (in_array($col, ['int', 'integer', 'mediumint'])) {
return ['type' => TableSchema::TYPE_INTEGER, 'length' => $length, 'unsigned' => $unsigned];
return ['type' => TableSchema::TYPE_INTEGER, 'length' => null, 'unsigned' => $unsigned];
}
if ($col === 'char' && $length === 36) {
return ['type' => TableSchema::TYPE_UUID, 'length' => null];
Expand Down Expand Up @@ -263,7 +263,8 @@ public function describeForeignKeySql(string $tableName, array $config): array
kcu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME
AND kcu.CONSTRAINT_SCHEMA = rc.CONSTRAINT_SCHEMA
)
WHERE kcu.TABLE_SCHEMA = ? AND kcu.TABLE_NAME = ? AND rc.TABLE_NAME = ?';
WHERE kcu.TABLE_SCHEMA = ? AND kcu.TABLE_NAME = ? AND rc.TABLE_NAME = ?
ORDER BY kcu.ORDINAL_POSITION ASC';

return [$sql, [$config['database'], $tableName, $tableName]];
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Fixture/MembersFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class MembersFixture extends TestFixture
*/
public $fields = [
'id' => ['type' => 'integer'],
'group_count' => ['type' => 'integer'],
'section_count' => ['type' => 'integer'],
'_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
];

Expand All @@ -38,6 +38,6 @@ class MembersFixture extends TestFixture
* @var array
*/
public $records = [
['group_count' => 2],
['section_count' => 2],
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
use Cake\TestSuite\Fixture\TestFixture;

/**
* GroupsFixture
* SectionsFixture
*/
class GroupsFixture extends TestFixture
class SectionsFixture extends TestFixture
{
/**
* fields property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
use Cake\TestSuite\Fixture\TestFixture;

/**
* GroupsMembersFixture
* SectionsMembersFixture
*/
class GroupsMembersFixture extends TestFixture
class SectionsMembersFixture extends TestFixture
{
/**
* fields property
Expand All @@ -28,7 +28,7 @@ class GroupsMembersFixture extends TestFixture
*/
public $fields = [
'id' => ['type' => 'integer'],
'group_id' => ['type' => 'integer'],
'section_id' => ['type' => 'integer'],
'member_id' => ['type' => 'integer'],
'_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
];
Expand All @@ -39,7 +39,7 @@ class GroupsMembersFixture extends TestFixture
* @var array
*/
public $records = [
['group_id' => 1, 'member_id' => 1],
['group_id' => 2, 'member_id' => 1],
['section_id' => 1, 'member_id' => 1],
['section_id' => 2, 'member_id' => 1],
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
use Cake\TestSuite\Fixture\TestFixture;

/**
* Class GroupsTranslationsFixture
* Class SectionsTranslationsFixture
*
*/
class GroupsTranslationsFixture extends TestFixture
class SectionsTranslationsFixture extends TestFixture
{
/**
* fields property
Expand Down
6 changes: 3 additions & 3 deletions tests/TestCase/Database/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,12 @@ public function testSelectWithJoinsConditions()
$result->closeCursor();

$query = new Query($this->connection);
$time = new \DateTime('2007-03-18 10:50:00');
$time = new \DateTime('2007-03-18 10:45:23');
$types = ['created' => 'datetime'];
$result = $query
->select(['title', 'comment' => 'c.comment'])
->from('articles')
->join(['table' => 'comments', 'alias' => 'c', 'conditions' => ['created <=' => $time]], $types)
->join(['table' => 'comments', 'alias' => 'c', 'conditions' => ['created' => $time]], $types)
->execute();
$this->assertEquals(['title' => 'First Article', 'comment' => 'First Comment for First Article'], $result->fetch('assoc'));
$result->closeCursor();
Expand Down Expand Up @@ -468,7 +468,7 @@ public function testSelectJoinWithCallback2()
->from('authors')
->innerJoin('comments', function ($exp, $q) use ($query, $types) {
$this->assertSame($q, $query);
$exp->add(['created >' => new \DateTime('2007-03-18 10:45:23')], $types);
$exp->add(['created' => new \DateTime('2007-03-18 10:47:23')], $types);

return $exp;
})
Expand Down
70 changes: 35 additions & 35 deletions tests/TestCase/Database/Schema/MysqlSchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,36 +85,36 @@ public static function convertColumnProvider()
['type' => 'boolean', 'length' => null],
],
[
'TINYINT(2)',
['type' => 'tinyinteger', 'length' => 2, 'unsigned' => false],
'TINYINT(1) UNSIGNED',
['type' => 'boolean', 'length' => null],
],
[
'TINYINT(3)',
['type' => 'tinyinteger', 'length' => 3, 'unsigned' => false],
['type' => 'tinyinteger', 'length' => null, 'unsigned' => false],
],
[
'TINYINT(3) UNSIGNED',
['type' => 'tinyinteger', 'length' => 3, 'unsigned' => true],
['type' => 'tinyinteger', 'length' => null, 'unsigned' => true],
],
[
'SMALLINT(4)',
['type' => 'smallinteger', 'length' => 4, 'unsigned' => false],
['type' => 'smallinteger', 'length' => null, 'unsigned' => false],
],
[
'SMALLINT(4) UNSIGNED',
['type' => 'smallinteger', 'length' => 4, 'unsigned' => true],
['type' => 'smallinteger', 'length' => null, 'unsigned' => true],
],
[
'INTEGER(11)',
['type' => 'integer', 'length' => 11, 'unsigned' => false],
['type' => 'integer', 'length' => null, 'unsigned' => false],
],
[
'MEDIUMINT(11)',
['type' => 'integer', 'length' => 11, 'unsigned' => false],
['type' => 'integer', 'length' => null, 'unsigned' => false],
],
[
'INTEGER(11) UNSIGNED',
['type' => 'integer', 'length' => 11, 'unsigned' => true],
['type' => 'integer', 'length' => null, 'unsigned' => true],
],
[
'BIGINT',
Expand Down Expand Up @@ -267,7 +267,7 @@ protected function _createTables($connection)

$table = <<<SQL
CREATE TABLE schema_authors (
id INT(11) PRIMARY KEY AUTO_INCREMENT,
id INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(50),
bio TEXT,
created DATETIME
Expand All @@ -280,7 +280,7 @@ protected function _createTables($connection)
id BIGINT PRIMARY KEY AUTO_INCREMENT,
title VARCHAR(20) COMMENT 'A title',
body TEXT,
author_id INT(11) NOT NULL,
author_id INT NOT NULL,
published BOOLEAN DEFAULT 0,
allow_comments TINYINT(1) DEFAULT 0,
created DATETIME,
Expand All @@ -295,7 +295,7 @@ protected function _createTables($connection)
if ($connection->getDriver()->supportsNativeJson()) {
$table = <<<SQL
CREATE TABLE schema_json (
id INT(11) PRIMARY KEY AUTO_INCREMENT,
id INT PRIMARY KEY AUTO_INCREMENT,
data JSON NOT NULL
)
SQL;
Expand Down Expand Up @@ -340,7 +340,7 @@ public function testDescribeTable()
'null' => false,
'unsigned' => false,
'default' => null,
'length' => 20,
'length' => null,
'precision' => null,
'comment' => null,
'autoIncrement' => true,
Expand Down Expand Up @@ -368,7 +368,7 @@ public function testDescribeTable()
'null' => false,
'unsigned' => false,
'default' => null,
'length' => 11,
'length' => null,
'precision' => null,
'comment' => null,
'autoIncrement' => null,
Expand Down Expand Up @@ -490,7 +490,7 @@ public function testDescribeNonPrimaryAutoIncrement()
$sql = <<<SQL
CREATE TABLE `odd_primary_key` (
`id` BIGINT UNSIGNED NOT NULL,
`other_field` INTEGER(11) NOT NULL AUTO_INCREMENT,
`other_field` INTEGER NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
UNIQUE KEY `other_field` (`other_field`)
)
Expand All @@ -510,7 +510,7 @@ public function testDescribeNonPrimaryAutoIncrement()

$output = $table->createSql($connection);
$this->assertStringContainsString('`id` BIGINT UNSIGNED NOT NULL,', $output[0]);
$this->assertStringContainsString('`other_field` INTEGER(11) NOT NULL AUTO_INCREMENT,', $output[0]);
$this->assertStringContainsString('`other_field` INTEGER NOT NULL AUTO_INCREMENT,', $output[0]);
}

/**
Expand Down Expand Up @@ -637,57 +637,57 @@ public static function columnSqlProvider()
// Integers
[
'post_id',
['type' => 'tinyinteger', 'length' => 2],
'`post_id` TINYINT(2)',
['type' => 'tinyinteger'],
'`post_id` TINYINT',
],
[
'post_id',
['type' => 'tinyinteger', 'length' => 2, 'unsigned' => true],
'`post_id` TINYINT(2) UNSIGNED',
['type' => 'tinyinteger', 'unsigned' => true],
'`post_id` TINYINT UNSIGNED',
],
[
'post_id',
['type' => 'smallinteger', 'length' => 4],
'`post_id` SMALLINT(4)',
['type' => 'smallinteger'],
'`post_id` SMALLINT',
],
[
'post_id',
['type' => 'smallinteger', 'length' => 4, 'unsigned' => true],
'`post_id` SMALLINT(4) UNSIGNED',
['type' => 'smallinteger', 'unsigned' => true],
'`post_id` SMALLINT UNSIGNED',
],
[
'post_id',
['type' => 'integer', 'length' => 11],
'`post_id` INTEGER(11)',
['type' => 'integer'],
'`post_id` INTEGER',
],
[
'post_id',
['type' => 'integer', 'length' => 11, 'unsigned' => true],
'`post_id` INTEGER(11) UNSIGNED',
['type' => 'integer', 'unsigned' => true],
'`post_id` INTEGER UNSIGNED',
],
[
'post_id',
['type' => 'biginteger', 'length' => 20],
['type' => 'biginteger'],
'`post_id` BIGINT',
],
[
'post_id',
['type' => 'biginteger', 'length' => 20, 'unsigned' => true],
['type' => 'biginteger', 'unsigned' => true],
'`post_id` BIGINT UNSIGNED',
],
[
'post_id',
['type' => 'integer', 'length' => 20, 'autoIncrement' => true],
'`post_id` INTEGER(20) AUTO_INCREMENT',
['type' => 'integer', 'autoIncrement' => true],
'`post_id` INTEGER AUTO_INCREMENT',
],
[
'post_id',
['type' => 'integer', 'length' => 20, 'null' => false, 'autoIncrement' => false],
'`post_id` INTEGER(20) NOT NULL',
['type' => 'integer', 'null' => false, 'autoIncrement' => false],
'`post_id` INTEGER NOT NULL',
],
[
'post_id',
['type' => 'biginteger', 'length' => 20, 'autoIncrement' => true],
['type' => 'biginteger', 'autoIncrement' => true],
'`post_id` BIGINT AUTO_INCREMENT',
],
// Decimal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ class TranslateBehaviorShadowTableTest extends TranslateBehaviorTest
'core.TagsTranslations',
'core.ArticlesTags',
'core.SpecialTags',
'core.Groups',
'core.Sections',
'core.ArticlesTranslations',
'core.ArticlesMoreTranslations',
'core.AuthorsTranslations',
'core.CommentsTranslations',
'core.TagsShadowTranslations',
'core.SpecialTagsTranslations',
'core.GroupsTranslations',
'core.SectionsTranslations',
];

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/ORM/Behavior/TranslateBehaviorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class TranslateBehaviorTest extends TestCase
'core.Articles',
'core.ArticlesTags',
'core.Authors',
'core.Groups',
'core.Sections',
'core.SpecialTags',
'core.Tags',
'core.Comments',
Expand Down Expand Up @@ -1450,7 +1450,7 @@ public function testSaveNewRecordWithTranslatesField()
*/
public function testSaveNewRecordWithOnlyTranslationsNotDefaultLocale()
{
$table = $this->getTableLocator()->get('Groups');
$table = $this->getTableLocator()->get('Sections');
$table->addBehavior('Translate', [
'fields' => ['title'],
'validator' => (new \Cake\Validation\Validator())->add('title', 'notBlank', ['rule' => 'notBlank']),
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/ORM/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2377,7 +2377,7 @@ public function testFormatDeepAssociationRecords()
};
$query = $table->find()
->contain(['Articles' => $builder, 'Articles.Authors' => $builder])
->order(['Articles.id' => 'ASC']);
->order(['ArticlesTags.article_id' => 'ASC']);

$query->formatResults(function ($results) {
return $results->map(function ($row) {
Expand Down

0 comments on commit eff7d0e

Please sign in to comment.