Skip to content

Commit

Permalink
Fixed the error caused by the Validation::is_unique() method.
Browse files Browse the repository at this point in the history
  • Loading branch information
muhammetsafak committed Aug 20, 2022
1 parent 396d94e commit 73ebe59
Show file tree
Hide file tree
Showing 32 changed files with 40 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/Connection/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr>
* @copyright Copyright © 2022 Muhammet ŞAFAK
* @license ./LICENSE MIT
* @version 1.1.12
* @version 1.1.13
* @link https://www.muhammetsafak.com.tr
*/

Expand Down
2 changes: 1 addition & 1 deletion src/Connection/ConnectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr>
* @copyright Copyright © 2022 Muhammet ŞAFAK
* @license ./LICENSE MIT
* @version 1.1.12
* @version 1.1.13
* @link https://www.muhammetsafak.com.tr
*/

Expand Down
13 changes: 7 additions & 6 deletions src/DB.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr>
* @copyright Copyright © 2022 Muhammet ŞAFAK
* @license ./LICENSE MIT
* @version 1.1.12
* @version 1.1.13
* @link https://www.muhammetsafak.com.tr
*/

Expand Down Expand Up @@ -136,10 +136,9 @@ public function __call($name, $arguments)
throw new DatabaseException('The "' . $name . '" method does not exist.');
}

public function with(): self
public function newInstance(): self
{
$with = clone $this;
return $with;
return new self($this->configurations);
}

/**
Expand All @@ -162,7 +161,8 @@ public function setSchema(string $schema): self

public function withSchema(string $schema): self
{
return $this->with()->setSchema($schema);
$with = clone $this;
return $with->setSchema($schema);
}

/**
Expand All @@ -185,7 +185,8 @@ public function setSchemaID(string $schemaID): self

public function withSchemaID(string $schemaID): self
{
return $this->with()->setSchemaID($schemaID);
$with = clone $this;
return $with->setSchemaID($schemaID);
}

public function isError(): bool
Expand Down
2 changes: 1 addition & 1 deletion src/DataMapper/DataMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr>
* @copyright Copyright © 2022 Muhammet ŞAFAK
* @license ./LICENSE MIT
* @version 1.1.12
* @version 1.1.13
* @link https://www.muhammetsafak.com.tr
*/

Expand Down
2 changes: 1 addition & 1 deletion src/DataMapper/DataMapperInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr>
* @copyright Copyright © 2022 Muhammet ŞAFAK
* @license ./LICENSE MIT
* @version 1.1.12
* @version 1.1.13
* @link https://www.muhammetsafak.com.tr
*/

Expand Down
2 changes: 1 addition & 1 deletion src/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr>
* @copyright Copyright © 2022 Muhammet ŞAFAK
* @license ./LICENSE MIT
* @version 1.1.12
* @version 1.1.13
* @link https://www.muhammetsafak.com.tr
*/

Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/DataMapperException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr>
* @copyright Copyright © 2022 Muhammet ŞAFAK
* @license ./LICENSE MIT
* @version 1.1.12
* @version 1.1.13
* @link https://www.muhammetsafak.com.tr
*/

Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/DataMapperInvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr>
* @copyright Copyright © 2022 Muhammet ŞAFAK
* @license ./LICENSE MIT
* @version 1.1.12
* @version 1.1.13
* @link https://www.muhammetsafak.com.tr
*/

Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/DatabaseConnectionException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr>
* @copyright Copyright © 2022 Muhammet ŞAFAK
* @license ./LICENSE MIT
* @version 1.1.12
* @version 1.1.13
* @link https://www.muhammetsafak.com.tr
*/

Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/DatabaseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr>
* @copyright Copyright © 2022 Muhammet ŞAFAK
* @license ./LICENSE MIT
* @version 1.1.12
* @version 1.1.13
* @link https://www.muhammetsafak.com.tr
*/

Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/DatabaseInvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr>
* @copyright Copyright © 2022 Muhammet ŞAFAK
* @license ./LICENSE MIT
* @version 1.1.12
* @version 1.1.13
* @link https://www.muhammetsafak.com.tr
*/

Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/ModelCallbacksException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr>
* @copyright Copyright © 2022 Muhammet ŞAFAK
* @license ./LICENSE MIT
* @version 1.1.12
* @version 1.1.13
* @link https://www.muhammetsafak.com.tr
*/

Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/ModelException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr>
* @copyright Copyright © 2022 Muhammet ŞAFAK
* @license ./LICENSE MIT
* @version 1.1.12
* @version 1.1.13
* @link https://www.muhammetsafak.com.tr
*/

Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/ModelPermissionException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr>
* @copyright Copyright © 2022 Muhammet ŞAFAK
* @license ./LICENSE MIT
* @version 1.1.12
* @version 1.1.13
* @link https://www.muhammetsafak.com.tr
*/

Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/ModelRelationsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr>
* @copyright Copyright © 2022 Muhammet ŞAFAK
* @license ./LICENSE MIT
* @version 1.1.12
* @version 1.1.13
* @link https://www.muhammetsafak.com.tr
*/

Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/QueryBuilderException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr>
* @copyright Copyright © 2022 Muhammet ŞAFAK
* @license ./LICENSE MIT
* @version 1.1.12
* @version 1.1.13
* @link https://www.muhammetsafak.com.tr
*/

Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/QueryBuilderInvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr>
* @copyright Copyright © 2022 Muhammet ŞAFAK
* @license ./LICENSE MIT
* @version 1.1.12
* @version 1.1.13
* @link https://www.muhammetsafak.com.tr
*/

Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/ValidationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr>
* @copyright Copyright © 2022 Muhammet ŞAFAK
* @license ./LICENSE MIT
* @version 1.1.12
* @version 1.1.13
* @link https://www.muhammetsafak.com.tr
*/

Expand Down
2 changes: 1 addition & 1 deletion src/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr>
* @copyright Copyright © 2022 Muhammet ŞAFAK
* @license ./LICENSE MIT
* @version 1.1.12
* @version 1.1.13
* @link https://www.muhammetsafak.com.tr
*/

Expand Down
2 changes: 1 addition & 1 deletion src/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr>
* @copyright Copyright © 2022 Muhammet ŞAFAK
* @license ./LICENSE MIT
* @version 1.1.12
* @version 1.1.13
* @link https://www.muhammetsafak.com.tr
*/

Expand Down
2 changes: 1 addition & 1 deletion src/QueryBuilder/Expressions/From.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr>
* @copyright Copyright © 2022 Muhammet ŞAFAK
* @license ./LICENSE MIT
* @version 1.1.12
* @version 1.1.13
* @link https://www.muhammetsafak.com.tr
*/

Expand Down
2 changes: 1 addition & 1 deletion src/QueryBuilder/Expressions/GroupBy.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr>
* @copyright Copyright © 2022 Muhammet ŞAFAK
* @license ./LICENSE MIT
* @version 1.1.12
* @version 1.1.13
* @link https://www.muhammetsafak.com.tr
*/

Expand Down
2 changes: 1 addition & 1 deletion src/QueryBuilder/Expressions/Join.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr>
* @copyright Copyright © 2022 Muhammet ŞAFAK
* @license ./LICENSE MIT
* @version 1.1.12
* @version 1.1.13
* @link https://www.muhammetsafak.com.tr
*/

Expand Down
2 changes: 1 addition & 1 deletion src/QueryBuilder/Expressions/Limit.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr>
* @copyright Copyright © 2022 Muhammet ŞAFAK
* @license ./LICENSE MIT
* @version 1.1.12
* @version 1.1.13
* @link https://www.muhammetsafak.com.tr
*/

Expand Down
2 changes: 1 addition & 1 deletion src/QueryBuilder/Expressions/OrderBy.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr>
* @copyright Copyright © 2022 Muhammet ŞAFAK
* @license ./LICENSE MIT
* @version 1.1.12
* @version 1.1.13
* @link https://www.muhammetsafak.com.tr
*/

Expand Down
2 changes: 1 addition & 1 deletion src/QueryBuilder/Expressions/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr>
* @copyright Copyright © 2022 Muhammet ŞAFAK
* @license ./LICENSE MIT
* @version 1.1.12
* @version 1.1.13
* @link https://www.muhammetsafak.com.tr
*/

Expand Down
2 changes: 1 addition & 1 deletion src/QueryBuilder/Expressions/WhereAndHaving.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr>
* @copyright Copyright © 2022 Muhammet ŞAFAK
* @license ./LICENSE MIT
* @version 1.1.12
* @version 1.1.13
* @link https://www.muhammetsafak.com.tr
*/

Expand Down
2 changes: 1 addition & 1 deletion src/QueryBuilder/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr>
* @copyright Copyright © 2022 Muhammet ŞAFAK
* @license ./LICENSE MIT
* @version 1.1.12
* @version 1.1.13
* @link https://www.muhammetsafak.com.tr
*/

Expand Down
2 changes: 1 addition & 1 deletion src/QueryBuilder/QueryBuilderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr>
* @copyright Copyright © 2022 Muhammet ŞAFAK
* @license ./LICENSE MIT
* @version 1.1.12
* @version 1.1.13
* @link https://www.muhammetsafak.com.tr
*/

Expand Down
2 changes: 1 addition & 1 deletion src/Validation/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr>
* @copyright Copyright © 2022 Muhammet ŞAFAK
* @license ./LICENSE MIT
* @version 1.1.12
* @version 1.1.13
* @link https://www.muhammetsafak.com.tr
*/

Expand Down
5 changes: 3 additions & 2 deletions src/Validation/ValidationRulesTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr>
* @copyright Copyright © 2022 Muhammet ŞAFAK
* @license ./LICENSE MIT
* @version 1.1.12
* @version 1.1.13
* @link https://www.muhammetsafak.com.tr
*/

Expand All @@ -26,7 +26,7 @@ protected function is_unique($data, $column, $schemaID = null): bool
if($this->db->getSchemaID() === null){
throw new ValidationException('You need a model with a PRIMARY KEY to use the is_unique validation.');
}
$db = $this->db->with();
$db = $this->db->newInstance();
$db->getQueryBuilder()->reset();
$db->getDataMapper()->getParameters(); // Prev parameters reset.

Expand All @@ -46,6 +46,7 @@ protected function required($data): bool
{
if(!\is_iterable($data) && !\is_object($data)){
$data = \trim((string)$data);
return $data !== '';
}
return !empty($data);
}
Expand Down
2 changes: 1 addition & 1 deletion src/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr>
* @copyright Copyright © 2022 Muhammet ŞAFAK
* @license ./LICENSE MIT
* @version 1.1.12
* @version 1.1.13
* @link https://www.muhammetsafak.com.tr
*/

Expand Down

0 comments on commit 73ebe59

Please sign in to comment.