Skip to content
This repository has been archived by the owner on Apr 3, 2021. It is now read-only.

Commit

Permalink
Feature improvement and psr-12 support
Browse files Browse the repository at this point in the history
Added
- ColumnDefinition object for simplifying the configuration of columns.
- Cascade support for column foreign keys.
- Support for using other types of default values.

Refactor
- Updated package to be in compliance with PSR-12.

Changed
- Default value for nullable in abstract table query set to false.
  • Loading branch information
mfrankruijter committed Oct 25, 2020
1 parent b28ec0c commit 4b44bd2
Show file tree
Hide file tree
Showing 81 changed files with 819 additions and 177 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: php
php:
- '7.2'
- '7.3'
- '7.4'

before_script:
- composer install
Expand Down
31 changes: 20 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 4.0.0 - 2020-10-25
### Added
- ColumnDefinition object for simplifying the configuration of columns.
- Cascade support for column foreign keys.
- Support for using other types of default values.

### Refactor
- Updated package to be in compliance with PSR-12.

### Changed
- Default value for nullable in abstract table query set to false.

## 3.0.2 - 2020-04-09
### Changed
- Changed enum package to GrizzIT variation.
Expand Down Expand Up @@ -76,14 +88,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `Ulrack\Dbal\Sql\Query\View\CreateViewQuery`
- `Ulrack\Dbal\Sql\Query\View\DropViewQuery`

[Unreleased](https://github.com/ulrack/dbal-sql/compare/3.0.2...HEAD)

[3.0.2](https://github.com/ulrack/dbal-sql/compare/3.0.1...3.0.2)

[3.0.1](https://github.com/ulrack/dbal-sql/compare/3.0.0...3.0.1)

[3.0.0](https://github.com/ulrack/dbal-sql/compare/2.0.1...3.0.0)

[2.0.1](https://github.com/ulrack/dbal-sql/compare/2.0.0...2.0.1)

[2.0.0](https://github.com/ulrack/dbal-sql/compare/1.0.0...2.0.0)
## Releases
- [4.0.0 > Unreleased](https://github.com/ulrack/dbal-sql/compare/4.0.0...HEAD)
- [3.0.2 > 4.0.0](https://github.com/ulrack/dbal-sql/compare/3.0.2...4.0.0)
- [3.0.1 > 3.0.2](https://github.com/ulrack/dbal-sql/compare/3.0.1...3.0.2)
- [3.0.0 > 3.0.1](https://github.com/ulrack/dbal-sql/compare/3.0.0...3.0.1)
- [2.0.1 > 3.0.0](https://github.com/ulrack/dbal-sql/compare/2.0.1...3.0.0)
- [2.0.0 > 2.0.1](https://github.com/ulrack/dbal-sql/compare/2.0.0...2.0.1)
- [1.0.0 > 2.0.0](https://github.com/ulrack/dbal-sql/compare/1.0.0...2.0.0)
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ for the other table queries.
- [CreateTableQuery](src/Component/Query/Table/CreateTableQuery.php)
- [DropTableQuery](src/Component/Query/Table/DropTableQuery.php)

Column operations are defined through:
- [ColumnDefinition](src/Component/Query/Table/ColumnDefinition.php)

##### View

- [CreateOrReplaceViewQuery](src/Component/Query/View/CreateOrReplaceViewQuery.php)
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"minimum-stability": "stable",
"require":
{
"php": "^7.2",
"php": "^7.3",
"ulrack/dbal": "^1.0",
"grizz-it/enum": "^1.0"
},
Expand Down Expand Up @@ -51,7 +51,7 @@
},
"require-dev":
{
"phpunit/phpunit": "^8.0",
"squizlabs/php_codesniffer": "^3.4"
"phpunit/phpunit": "^9.4",
"squizlabs/php_codesniffer": "^3.5"
}
}
3 changes: 1 addition & 2 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@
<arg name="colors" />
<arg value="s" />

<!-- Use the PSR2 Standard-->
<rule ref="PSR2" />
<rule ref="PSR12" />
</ruleset>
23 changes: 12 additions & 11 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheResult="false">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
24 changes: 24 additions & 0 deletions src/Common/CascadeEnum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

/**
* Copyright (C) GrizzIT, Inc. All rights reserved.
* See LICENSE for license details.
*/

namespace Ulrack\Dbal\Sql\Common;

use GrizzIt\Enum\Enum;

/**
* @method static CascadeEnum NO_ACTION()
* @method static CascadeEnum CASCADE()
* @method static CascadeEnum SET_NULL()
* @method static CascadeEnum SET_DEFAULT()
*/
class CascadeEnum extends Enum
{
public const NO_ACTION = 'NO ACTION';
public const CASCADE = 'CASCADE';
public const SET_NULL = 'SET NULL';
public const SET_DEFAULT = 'SET DEFAULT';
}
9 changes: 5 additions & 4 deletions src/Common/ColumnAttributeEnum.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Copyright (C) GrizzIT, Inc. All rights reserved.
* See LICENSE for license details.
Expand All @@ -16,8 +17,8 @@
*/
class ColumnAttributeEnum extends Enum
{
const BINARY = 'BINARY';
const UNSIGNED = 'UNSIGNED';
const ZEROFILL = 'UNSIGNED ZEROFILL';
const ON_UPDATE_NOW = 'on update CURRENT_TIMESTAMP';
public const BINARY = 'BINARY';
public const UNSIGNED = 'UNSIGNED';
public const ZEROFILL = 'UNSIGNED ZEROFILL';
public const ON_UPDATE_NOW = 'on update CURRENT_TIMESTAMP';
}
7 changes: 4 additions & 3 deletions src/Common/ColumnDefaultEnum.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Copyright (C) GrizzIT, Inc. All rights reserved.
* See LICENSE for license details.
Expand All @@ -15,7 +16,7 @@
*/
class ColumnDefaultEnum extends Enum
{
const NONE = '';
const DEFAULT_NULL = 'NULL';
const CURRENT_TIMESTAMP = 'CURRENT_TIMESTAMP';
public const NONE = '';
public const DEFAULT_NULL = 'NULL';
public const CURRENT_TIMESTAMP = 'CURRENT_TIMESTAMP';
}
158 changes: 158 additions & 0 deletions src/Common/ColumnDefinitionInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
<?php

/**
* Copyright (C) GrizzIT, Inc. All rights reserved.
* See LICENSE for license details.
*/

namespace Ulrack\Dbal\Sql\Common;

use Ulrack\Dbal\Sql\Common\ColumnTypeEnum;
use Ulrack\Dbal\Sql\Common\ColumnAttributeEnum;

interface ColumnDefinitionInterface
{
/**
* Get the column name.
*
* @return string
*/
public function getName(): string;

/**
* Set the column name.
*
* @param string $name
*
* @return void
*/
public function setName(string $name): void;

/**
* Get the column type.
*
* @return ColumnTypeEnum
*/
public function getType(): ColumnTypeEnum;

/**
* Set the column type.
*
* @param ColumnTypeEnum $type
*
* @return void
*/
public function setType(ColumnTypeEnum $type): void;

/**
* Get the type option value.
*
* @return string|null
*/
public function getTypeOption(): ?string;

/**
* Set the column type option.
*
* @param string|null $typeOption
*
* @return string|null
*/
public function setTypeOption(?string $typeOption): void;

/**
* Get the default value.
*
* @return ColumnDefaultEnum|mixed
*/
public function getDefault();

/**
* Set the default value.
*
* @param ColumnDefaultEnum|mixed $default
*
* @return void
*/
public function setDefault($default): void;

/**
* Get the attribute.
*
* @return ColumnAttributeEnum|null
*/
public function getAttribute(): ?ColumnAttributeEnum;

/**
* Set the attribute.
*
* @param ColumnAttributeEnum|null $attribute
*
* @return void
*/
public function setAttribute(?ColumnAttributeEnum $attribute): void;

/**
* Whether the column is nullable.
*
* @return bool
*/
public function isNullable(): bool;

/**
* Set whether the column is nullable.
*
* @param bool $nullable
*
* @return void
*/
public function setIsNullable(bool $nullable): void;

/**
* Whether the column is automatically incrementing.
*
* @return bool
*/
public function isAutoIncrement(): bool;

/**
* Set whether the column is automatically incrementing.
*
* @param bool $autoIncrement
*
* @return void
*/
public function setIsAutoIncrement(bool $autoIncrement): void;

/**
* Whether the value of the column must be unique.
*
* @return bool
*/
public function isUnique(): bool;

/**
* Set whether the column should be unique.
*
* @param bool $unique
*
* @return void
*/
public function setIsUnique(bool $unique): void;

/**
* Get the column comment.
*
* @return string
*/
public function getComment(): string;

/**
* Set the column comment.
*
* @param string $comment
*
* @return void
*/
public function setComment(string $comment): void;
}
Loading

0 comments on commit 4b44bd2

Please sign in to comment.