Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [QueryBuilder] TypeError in join() with BETWEEN #8792

Merged
merged 1 commit into from
Apr 30, 2024

Conversation

kenjis
Copy link
Member

@kenjis kenjis commented Apr 15, 2024

Description
Fixes #8791

This PR makes the same behavior as v4.4.x or before.

  • ad hoc fix

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@kenjis kenjis added the bug Verified issues on the current code behavior or pull requests that will fix them label Apr 15, 2024
@kenjis kenjis changed the title fix: [QueryBuilder] join() with BETWEEN fix: [QueryBuilder] TypeError in join() with BETWEEN Apr 16, 2024
@kenjis kenjis added the database Issues or pull requests that affect the database layer label Apr 20, 2024
@kenjis
Copy link
Member Author

kenjis commented Apr 29, 2024

Can someone review?

Copy link
Member

@michalsn michalsn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather see the use of RawSql for complicated conditions, but since the issue with BETWEEN is described as a regression, I think this is fine.

@kenjis kenjis merged commit 3134350 into codeigniter4:develop Apr 30, 2024
40 checks passed
@kenjis kenjis deleted the fix-QB-join-BETWEEN branch April 30, 2024 00:31
@oyama-pai
Copy link

The version has been upgraded to 4.5.2.
Query builder class "->insert()" now displays errors on my VS Code.

$model = new HogeModel();
$data = [
'hoge' => 'fuga'
];
$model->insert($data);

"Argument '1' passed to insert() is expected to be of type object|row_array|null, array given"

Please fix it.
(*ᴗˬᴗ)⁾⁾⁾

@kenjis
Copy link
Member Author

kenjis commented Jun 21, 2024

Why your VS Code reads @phpstan-param instead of @param?

* @param array|object|null $row
* @phpstan-param row_array|object|null $row
* @param bool $returnID Whether insert ID should be returned or not.
*
* @return bool|int|string
* @phpstan-return ($returnID is true ? int|string|false : bool)
*
* @throws ReflectionException
*/
public function insert($row = null, bool $returnID = true)

If it reads @phpstan-param, it should know row_array.

* @phpstan-type row_array array<int|string, float|int|null|object|string>

@oyama-pai
Copy link

Thank you.
It's seems to be due to my dev environment or VSCode settings.
but why????

Windows 11 Pro 23H2 WSL2
Ubuntu 22.04.4

It was very helpful.
Thank you.

@oyama-pai
Copy link

???
When open CodeIgniter4/system/Model.php is error disappears.
But when I close /Mdel.php file display error line.

Model.php on line 268 & BaseModel.php on line 656 is displays "undefined property" error form intelephense.

Here and now (´;д;`)

@oyama-pai
Copy link

oyama-pai commented Jun 22, 2024

Bad

$model = new HogeModel();
$data = [
'hoge' => 'fuga'
];
$model->insert($data);

Good

private function hoge()
{
$data = [
'hoge' => 'fuga'
];
$this->insertHoge($data);
}
private function insertHoge($data)
{
$model = new HogeModel();
$model->insert($data);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them database Issues or pull requests that affect the database layer
Projects
None yet
4 participants