Bod has asked for the wisdom of the Perl Monks concerning the following question:
I'm creating user-defined custom fields in Maria DB using the JSON Data Type. I've never had cause to use this data type before so I've been playing learning by running queries directly against a test database to get the syntax right. I thought I'd got this to the point where I can use it and imagined that there could be some issues with getting the DBI placeholders right.
But I seem to have hit a more tricky issue...
I started with this DBI query:
But this didn't work. I assumed it was a placeholder issue.$row->{'inuse'} = $dbh->selectrow_array("SELECT COUNT(*) FROM Person W +HERE Account_idAccount = ? AND JSON_EXISTS(custom, ?)", undef, $accou +nt, "$." . $row->{'name'});
However, I slowly removed the placeholders to test where things were going wrong. To the point where I arrived at this with no placeholders...
The code doesn't die.$row->{'inuse'} = $dbh->selectrow_array("SELECT COUNT(*) FROM Person W +HERE Account_idAccount = 35 AND JSON_EXISTS(custom, '$.test3')"); die $dbh->errstr if $dbh->err; die $row->{'inuse'} if $row->{'inuse'};
But, if I run the same query directly against the same database:
I get the result 1SELECT COUNT(*) FROM Person WHERE Account_idAccount = 35 AND JSON_EXIS +TS(custom, '$.test3')
Is there a problem using the MariaDB JSON Data Type with DBI or have I missed something else obvious?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: DBI and JSON fields
by choroba (Cardinal) on Mar 12, 2024 at 12:40 UTC | |
by Bod (Parson) on Mar 12, 2024 at 13:00 UTC | |
by stevieb (Canon) on Mar 13, 2024 at 07:37 UTC | |
by etj (Priest) on Mar 14, 2024 at 10:37 UTC | |
Re: DBI and JSON fields
by Corion (Patriarch) on Mar 12, 2024 at 12:33 UTC | |
by Bod (Parson) on Mar 12, 2024 at 14:01 UTC | |
by Corion (Patriarch) on Mar 12, 2024 at 14:11 UTC | |
by Bod (Parson) on Mar 12, 2024 at 23:28 UTC | |
by stevieb (Canon) on Mar 13, 2024 at 08:09 UTC | |
by soonix (Chancellor) on Mar 13, 2024 at 07:49 UTC | |
|