Skip to content

Commit

Permalink
3.1.2
Browse files Browse the repository at this point in the history
Boolean columns and nullable for json|jsonb
  • Loading branch information
Nurlan Mukhanov committed Aug 26, 2024
1 parent 99ec8e4 commit 2c6f2bd
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 5 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "falseclock/dbd-php-entity",
"type": "library",
"version": "3.1.1",
"version": "3.1.2",
"description": "DTO like library to fetch any data in an Object-Oriented manner (ORM)",
"keywords": [
"dbd",
Expand Down
51 changes: 51 additions & 0 deletions src/DBD/Entity/Columns/BooleanColumn.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
/********************************************************************************
* Apache License, Version 2.0 *
* *
* Copyright [2024] [Nurlan Mukhanov <[email protected]>] *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
* You may obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
* See the License for the specific language governing permissions and *
* limitations under the License. *
* *
********************************************************************************/

declare(strict_types=1);

namespace DBD\Entity\Columns;

use Attribute;
use DBD\Entity\Column;
use DBD\Entity\Primitive;

/**
* Class BooleanColumn
*
* @package DBD\Entity\Columns
*/
#[Attribute(Attribute::TARGET_PROPERTY)]
class BooleanColumn extends Column
{
public function __construct(
string $name,
bool $nullable = true,
?string $annotation = null
)
{
parent::__construct([
Column::NAME => $name,
Column::PRIMITIVE_TYPE => Primitive::Boolean,
Column::ORIGIN_TYPE => 'boolean',
Column::NULLABLE => $nullable,
Column::ANNOTATION => $annotation
]);
}
}
6 changes: 4 additions & 2 deletions src/DBD/Entity/Columns/JsonColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,16 @@ class JsonColumn extends Column
{
public function __construct(
string $name,
?string $annotation = null
?string $annotation = null,
bool $nullable = true,
)
{
parent::__construct([
Column::NAME => $name,
Column::PRIMITIVE_TYPE => StringPrimitives::String,
Column::ORIGIN_TYPE => 'json',
Column::ANNOTATION => $annotation
Column::ANNOTATION => $annotation,
Column::NULLABLE => $nullable
]);
}
}
6 changes: 4 additions & 2 deletions src/DBD/Entity/Columns/JsonbColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,16 @@ class JsonbColumn extends Column
{
public function __construct(
string $name,
?string $annotation = null
?string $annotation = null,
bool $nullable = true,
)
{
parent::__construct([
Column::NAME => $name,
Column::PRIMITIVE_TYPE => StringPrimitives::String,
Column::ORIGIN_TYPE => 'jsonb',
Column::ANNOTATION => $annotation
Column::ANNOTATION => $annotation,
Column::NULLABLE => $nullable
]);
}
}

0 comments on commit 2c6f2bd

Please sign in to comment.