-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Bug: [Postgres] QueryBuilder::updateBatch()
pg_affected_rows(): Argument #1 ($result) must be of type PgSql\Result, bool given
#7387
Comments
It seems there is no |
This test passes:
Can you write a failed test case? |
i mean $this->packagePlanModel->updateBatch($updatedData, 'package_plan_id'); id is using package_plan_id
|
Same issue when im running
it's throw error:
|
We cannot reproduce. |
As I can see from the code, such an error can be caused by a broken SQL query. I'm not sure, but try wrapping your code in a try...catch try {
$moduleModel->insertBatch($modules);
} catch (Exception $e) {
dd($moduleModel->error());
} |
@Onerosolutions Can you provide minimum code that reproduces the error? |
Hello, sorry for the late reply. @kenjis @iRedds The possible cause of the error may be that I added updated_at to the $allowedFields attribute as shown below: class PackagePlanModel extends BaseModel
{
protected $table = 'package_plan_ms';
protected $primaryKey = 'package_plan_id';
protected $returnType = 'App\Entities\PackageBuilder\PackagePlan';
protected $useSoftDeletes = true;
protected $allowedFields = [
'package_plan_id',
'package_id',
'package_plan_name',
'package_plan_description',
'created_at',
'updated_at',
];
.... I tried to run updateBatch with the returnSQL parameter set to true to get the raw SQL, and running it manually in PostgreSQL using DBbeaver: $packagePlanModel = new PackagePlanModel();
try {
$sql = $packagePlanModel->updateBatch($packagePlanUpdateBatchData, 'package_plan_id', 100, true);
print_r($sql); die;
....
but it resulted in an error like this:
So the issue could be due to the failure when updating the data, where the updated_at column and the value to be updated have different types.
|
PHP Version CodeIgniter4 Version CodeIgniter4 Installation Method Which operating systems have you tested for this bug? Which server did you use? Database What happened? Data
Code
Error message when in database trasaction:
Error message when not in trasaction:
|
updateBatch()
pg_affected_rows(): Argument #1 ($result) must be of type PgSql\Result, bool given
The same issue as this? |
There is no way to do that now. See also #8282 (comment) |
updateBatch()
pg_affected_rows(): Argument #1 ($result) must be of type PgSql\Result, bool givenQueryBuilder::updateBatch()
pg_affected_rows(): Argument #1 ($result) must be of type PgSql\Result, bool given
I sent a PR: #8426 |
Please try #8439 |
PHP Version
8.1
CodeIgniter4 Version
4.3.3
CodeIgniter4 Installation Method
Composer (using
codeigniter4/appstarter
)Which operating systems have you tested for this bug?
Windows
Which server did you use?
apache
Database
PostgeSQL 15
What happened?
Error after run $this->modelName->updateBatch($updatedData, 'id');
Steps to Reproduce
Run updateBatch method
$this->modelName->updateBatch($updatedData, 'id');
Expected Output
No error.
Anything else?
No response
The text was updated successfully, but these errors were encountered: