Welcome Guest, Not a member yet? Register   Sign In
Error when updateBatch() updates a single record containing a timestamp and timezone
#1

Hello, Thank you for fixing the following bug.
CodeIgniter4.4.5 Type char casting bug PostgreSQL with updateBatch()

We have identified a bug that we believe is related and will report it.
I encountered Error when updateBatch() updates a single record containing a timestamp and timezone column (PostgreSQL 9.2)

Environment in which the phenomenon was observed.
  • PHP 7.4.33
  • CodeIgniter 4.4.5
  • PostgreSQL 9.2.24
The following is a list of procedures that can be used to confirm the occurrence of the phenomenon.
Zenn Scraps - CodeIgniter4.4.5 Error when updateBatch() a single record containing TS TZ columns (PostgreSQL 9.2)

PostgreSQL 13.11 had no problems.
Reply
#2

(This post was last modified: 02-22-2024, 04:13 PM by kenjis.)

What if you use `now`, not `now()`?

PHP Code:
        $set = [
            [
                'id1'      => 1,
                'id2'      => 4,
                'char'      => 'Modify Qux',
                'varchar'  => 'Modify Qux',
                'timestamp' => 'now',
            ],
        ]; 

Or

PHP Code:
'timestamp' => new RawSql('now()'), 
Reply
#3

@kenjis
Thanks for the reply.

The result is the same for `now`, which also failed.

PHP Code:
'timestamp' => new RawSql('now()'), 

If I use `now()` in RawSql, I have succeeded.
Incidentally, using `now` in RawSql was a failure.

Use `now()` in RawSql. Thanks!
Reply
#4

I think the following is a misuse because now() will be a string 'now()' in the SQL statement.
But now() is a function. I don't know why it worked and works on v13.

PHP Code:
'timestamp' => 'now()'
Reply
#5

updateBatch in PostgreSQL v9 caused an internal error (XX000) for both `now()` and `now`.
Both `now()` and `now` succeeded in PostgreSQL v13 updateBatch.

https://zenn.dev/naente/scraps/0983a5252...0f49a10fdd

I don't know if the difference is due to the PostgreSQL version or my environment.
In any case, I understand that it is safe to use RawSql.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB