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

I sent a PR: https://github.com/codeigniter4/CodeIgniter4/pull/8426
Reply
#12
Thumbs Up 

(01-16-2024, 09:27 PM)kenjis Wrote: I sent a PR: https://github.com/codeigniter4/CodeIgniter4/pull/8426

Man I couldn't be any more happier. Thank you so-much. You made my day.
You are the best. Love you ma man. (y)
Reply
#13

Tests and reviews are welcome.
Reply
#14

I hope individuals with strong technical skills can offer assistance. I wish I possessed such skills to contribute. I attempted to rectify this after a few hours of struggling, but unfortunately, I failed. Every value is gets enclosed in quotes. I spent several days trying to comprehend how things interconnect, but I couldn't figure it out.

I want to convey that I genuinely desire to actively contribute to CI4, but I'm not at that level yet. I highly appreciate what you all are doing here. I eat, live, and take care of my family because of you guys. Thank you so much Smile
Reply
#15

(This post was last modified: 01-17-2024, 02:09 AM by byrallier.)

(01-01-2024, 01:19 PM)MrWhite Wrote: I have this issue. i dunno what to do. Sad

my whole project is now stuck at this point. cant go forward without having a solution to this. i nerver had this type of issue in ci3.

i suggest this kind of way casting types, $builder->updateBatch($data, ['title', 'author', 'data:jsonb']);

(01-16-2024, 09:48 PM)kenjis Wrote: Tests and reviews are welcome.

I reviewed its fine but it has to be documented. I will give it a try on its test
Reply
#16

Added the docs: https://github.com/codeigniter4/CodeIgniter4/pull/8426
Reply
#17

The quick and easy fix for this is to use RawSql as well as casting your php values:
Code:
$data = [
                [
                    'name'                  => 'Derek Jones',
                    'savings'               => (float) '28389.48',
                    'updated_at' => new RawSql("'2023-12-02 18:47:52'::TIMESTAMP"),
                ],
            ];

https://codeigniter.com/user_guide/datab...tml#rawsql

Another things to have a look at is:

https://www.postgresql.org/docs/current/...ecast.html
Reply
#18

(01-17-2024, 08:19 PM)kenjis Wrote: Added the docs: https://github.com/codeigniter4/CodeIgniter4/pull/8426
Big thanks   Heart
(01-19-2024, 03:25 PM)sclubricants Wrote: The quick and easy fix for this is to use RawSql as well as casting your php values:
Code:
            $data = [
                [
                    'name'                  => 'Derek Jones',
                    'savings'              => (float) '28389.48',
                    'updated_at' => new RawSql("'2023-12-02 18:47:52'::TIMESTAMP"),
                ],
            ];

https://codeigniter.com/user_guide/datab...tml#rawsql

Another things to have a look at is:

https://www.postgresql.org/docs/current/...ecast.html

Yeah! nice trick.
Reply
#19

There are four options now. Any opinion? or another solution?
See https://github.com/codeigniter4/CodeIgni...1901901019
Reply
#20

I sent another PR. This seems better.

fix: [Postgre] QueryBuilder::updateBatch() does not work (No API change) by kenjis · Pull Request #8439 · codeigniter4/CodeIgniter4
https://github.com/codeigniter4/CodeIgniter4/pull/8439
Reply




Theme © iAndrew 2016 - Forum software by © MyBB