Problems handling JSON
tarkhil opened this issue · 5 comments
tarkhil commented
- Mojo::Pg version: 4.22
- Perl version: v5.32.0
- Operating system: FreeBSD 12.2-RELEASE-p1
Steps to reproduce the behavior
#!/usr/bin/env perl
use Mojo::Base -base;
use SQL::Abstract::Pg;
use YAML;
my $abstract = SQL::Abstract::Pg->new;
say Dump $abstract->insert( 'some_table', {foo => {-json => [1, 2, 3]}}, {bar => 23} );
Actual behavior
% ./tmp/insert
[SQL::Abstract::__ANON__] Warning: HASH ref as bind value in insert is not supported at ./tmp/insert line 7.
--- 'INSERT INTO some_table ( foo) VALUES ( ? )'
---
-json:
- 1
- 2
- 3
Attempt to use that insert with Mojo::Pg yields "Cannot bind a reference" error
kraih commented
We can only use the hooks SQL::Abstract
provides us. How they are handled we have no control over. You probably want to report the issue upstream.
tarkhil commented
So it was handled by SQL::Abstract, while being a Pg extension?... Ok...
…On 17.01.2021 0:26, Sebastian Riedel wrote:
We can only use the hooks |SQL::Abstract| provides us. How they are
handled we have no control over. You probably want to report the issue
upstream.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#74 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAD4K55RYKDT6PPL7JZLRPLS2IABDANCNFSM4WFRVKJA>.
tarkhil commented
As of 1.87. SQL::Abstract does not support JSON.
And as far as I understand SQL::Abstract::Pg manual, SQL::Abstract::Pg - should, as it's a Pg extension...
kraih commented
That doesn't mean we can magically change SQL::Abstract
internals.
karenetheridge commented
@tarkhil I'm not sure exactly what SQL you are expecting to be generated, but if json()
is to be a function call in postgres, and its argument is a hashref, then this should do the trick:
$abstract->insert( 'some_table', {foo => \[ 'json(?)', [{}, [1,2,3] ] ]}, {bar => 23} );