Skip to content

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

Merged
kenjis merged 1 commit into
codeigniter4:developfrom
kenjis:fix-QB-join-BETWEEN
Apr 30, 2024
Merged

fix: [QueryBuilder] TypeError in join() with BETWEEN#8792
kenjis merged 1 commit into
codeigniter4:developfrom
kenjis:fix-QB-join-BETWEEN

Conversation

@kenjis

Copy link
Copy Markdown
Member

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

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

Copy link
Copy Markdown
MemberAuthor

Can someone review?

@michalsnmichalsn left a comment

Copy link
Copy Markdown
Member

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:developApr 30, 2024
@kenjis
kenjis deleted the fix-QB-join-BETWEEN branch April 30, 2024 00:31
@oyama-pai

Copy link
Copy Markdown

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
Copy Markdown
MemberAuthor

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
*/
publicfunctioninsert($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
Copy Markdown

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
Copy Markdown

???
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

oyama-pai commented Jun 22, 2024

Copy link
Copy Markdown

Bad

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

Good

privatefunctionhoge()
{
$data = [
'hoge' => 'fuga'
];
$this->insertHoge($data);
}
privatefunctioninsertHoge($data)
{
$model = newHogeModel();
$model->insert($data);
}

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugVerified issues on the current code behavior or pull requests that will fix themdatabaseIssues or pull requests that affect the database layer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: [QueryBuilder] join() with BETWEEN causes TypeError preg_quote(): Argument #1 ($str) must be of type string, false given

4 participants

@kenjis@oyama-pai@michalsn@datamweb