Welcome Guest, Not a member yet? Register   Sign In
Type casting in PostgreSQL with updateBatch()
#7

(This post was last modified: 01-01-2024, 03:25 PM by byrallier.)

on CI4, There are new form of creating SQL queries and this is happen when you dont use type definitions on models. (i think) I dont know why anyone else is not experincing this, its critical I believe.

method: _updateBatch
change this line:
static fn ($key, $index) => $index . ' ' . $key,
to:
static fn ($key, $index) => (is_array($index)?$index[0].'::'.str_replace("'","",$index[1]):$index) . ' ' . $key,
** simple explanation is, If a value of a row is array then apply its type from getting second index by interpolating sting like '2024-01-01'::date

Also I applied this one to _insertBatch. Now I send type information on an array for batch queries like;

array( [0]=>(123,'simon',array('2024-01-01',''date')), [1]=>(124,'byrallier',array('2024-01-02',''date'))...

free look to diff: https://files.slack.com/files-pri/T46QYU.../image.png
Reply


Messages In This Thread
RE: Type casting in PostgreSQL with updateBatch() - by byrallier - 01-01-2024, 03:22 PM



Theme © iAndrew 2016 - Forum software by © MyBB