Skip to content

Commit

Permalink
Merge branch '4.0.x' of github.com:rotexsoft/leanorm into 4.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
rotimi committed Jul 19, 2024
2 parents 444a6cd + e9f150d commit 52a23fd
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Run PHP Tests and Code Quality Tools

on:
push:
branches: [ master ]
branches: [ 4.0.x ]
pull_request:
branches: [ master ]
branches: [ 4.0.x ]
schedule:
# Also run every Sunday at midnight
- cron: '0 0 * * 0'
Expand Down
1 change: 1 addition & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
\Rector\DeadCode\Rector\PropertyProperty\RemoveNullPropertyInitializationRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector::class,
\Rector\CodeQuality\Rector\If_\CompleteMissingIfElseBracketRector::class,
\Rector\Php80\Rector\FunctionLike\MixedTypeRector::class,
];

$rectorConfigurator->skip($skipables);
Expand Down
8 changes: 8 additions & 0 deletions run-tests-against-multiple-db-versions.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,14 @@ function readableElapsedTime($microtime, $format = null, $round = 3) {
'username' => $mysql_user,
'password' => $mysql_root_psw,
],
],
[
'mysql:8.4.0' => [
'run_container' => "podman run -dt -p 3306:3306 -e MYSQL_ROOT_PASSWORD={$mysql_root_psw} docker.io/library/mysql:8.4.0",
'dsn' => $mysql_maria_db_sql_dsn,
'username' => $mysql_user,
'password' => $mysql_root_psw,
],
],
[
'postgres:15.6' => [
Expand Down
20 changes: 10 additions & 10 deletions src/LeanOrm/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,10 @@ public function deleteMatchingDbTableRows(array $cols_n_vals): int {

//delete statement
$del_qry_obj = (new QueryFactory($this->getPdoDriverName()))->newDelete();
$sel_qry_obj = (new QueryFactory($this->getPdoDriverName()))->newSelect();
$del_qry_obj->from($this->getTableName());
$sel_qry_obj->from($this->getTableName());
$sel_qry_obj->cols([' count(*) ']);
$table_cols = $this->getTableColNames();

/** @psalm-suppress MixedAssignment */
Expand Down Expand Up @@ -1674,6 +1677,7 @@ public function deleteMatchingDbTableRows(array $cols_n_vals): int {
}

$this->addWhereInAndOrIsNullToQuery(''.$colname, $colval, $del_qry_obj);
$this->addWhereInAndOrIsNullToQuery(''.$colname, $colval, $sel_qry_obj);

} else {

Expand All @@ -1683,6 +1687,7 @@ public function deleteMatchingDbTableRows(array $cols_n_vals): int {
}

$del_qry_obj->where(" {$colname} = :{$colname} ", [$colname => $this->stringifyIfStringable($colval)]);
$sel_qry_obj->where(" {$colname} = :{$colname} ", [$colname => $this->stringifyIfStringable($colval)]);
}
}

Expand All @@ -1694,19 +1699,14 @@ public function deleteMatchingDbTableRows(array $cols_n_vals): int {
$dlt_qry_params = $del_qry_obj->getBindValues();
$this->logQuery($dlt_qry, $dlt_qry_params, __METHOD__, '' . __LINE__);

$result = $this->db_connector->executeQuery($dlt_qry, $dlt_qry_params, true);
$matching_rows_before_delete = (int) $this->fetchValue($sel_qry_obj);

if( is_array($result) && $result['query_result'] === true ) {
$this->db_connector->executeQuery($dlt_qry, $dlt_qry_params, true);

//return number of affected rows
$pdo_statement_used_for_query = $result['pdo_statement'];
$result = $pdo_statement_used_for_query->rowCount();
} else {
$matching_rows_after_delete = (int) $this->fetchValue($sel_qry_obj);

// something went wrong
// TODO: Maybe throw an exception
$result = 0;
} // if( $result['query_result'] === true )
//number of deleted rows
$result = $matching_rows_before_delete - $matching_rows_after_delete;
} // if($cols_n_vals !== [])
} // if ( $cols_n_vals !== [] )

Expand Down
5 changes: 1 addition & 4 deletions src/LeanOrm/Model/Record.php
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,7 @@ public function __set($key, mixed $val): void {
//model's record.
$this->data[$key] = $val;

} elseif(
$this->getModel() instanceof \GDAO\Model
&& in_array($key, $this->getModel()->getRelationNames())
) {
} elseif (in_array($key, $this->getModel()->getRelationNames())) {
//$key is a valid relation name in the model for this record.
$this->related_data[$key] = $val;

Expand Down

0 comments on commit 52a23fd

Please sign in to comment.