Discussion:
Mojo::Pg and bytea don't seem to work
(too old to reply)
Alejandro Imass
2017-06-16 20:00:56 UTC
Permalink
Hi,

Bytea values are coming back as empty strings. Am I missing something or is
this a limitation and if so, is there a workaround?

TIA,
Alejandro Imass
--
You received this message because you are subscribed to the Google Groups "Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
Alejandro Imass
2017-06-16 20:24:07 UTC
Permalink
Post by Alejandro Imass
Hi,
Bytea values are coming back as empty strings. Am I missing something or is
this a limitation and if so, is there a workaround?
TIA,
Alejandro Imass
Seems like a DBI issue and requires some explicit spec on the Pg
datatype and bind the params manually...
Anyone have an example by any chance (for selects and/or insert/update) ??

TIA,
Alejandro Imass
--
You received this message because you are subscribed to the Google Groups "Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
Dan Book
2017-06-16 20:33:39 UTC
Permalink
The recently added bind type support should help, see the last example
here: https://metacpan.org/pod/Mojo::Pg::Database#query
Post by Alejandro Imass
Post by Alejandro Imass
Hi,
Bytea values are coming back as empty strings. Am I missing something or
is
Post by Alejandro Imass
this a limitation and if so, is there a workaround?
TIA,
Alejandro Imass
Seems like a DBI issue and requires some explicit spec on the Pg
datatype and bind the params manually...
Anyone have an example by any chance (for selects and/or insert/update) ??
TIA,
Alejandro Imass
--
You received this message because you are subscribed to the Google Groups
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
Alejandro Imass
2017-06-17 12:57:53 UTC
Permalink
Post by Dan Book
https://metacpan.org/pod/Mojo::Pg::Database#query
Thanks Dan!

You are right. That seems to work for insert, supported by query()

But for retrieval queries (using query() or select()) I think the
limitation is in $results->hash only expands json or jsonb in the
_expand subroutine in Mojo::Pg::Results

Looking at the code in _expand (some of it is a bit mind bending)
maybe there is a way to do it by querying a single field in the select
statement (single field select with type=PG_BYTEA) but I tried several
ways and none worked.

I believe adding a new case to the json/jsonb case in _results for the
bytea type and support "raw" bytes could solve the issue but I am time
constrained and it's cheaper for me to change the database model for
now than trying to hack away at this.

It would be nice though if this is supported in the future or if
someone volunteers to submit a patch in this regard.

Best,
Alejandro Imass
--
You received this message because you are subscribed to the Google Groups "Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
sri
2017-06-17 13:15:36 UTC
Permalink
Post by Alejandro Imass
It would be nice though if this is supported in the future or if
someone volunteers to submit a patch in this regard.
Patches welcome, allowing custom expanders (besides JSON) for Mojo::Pg is a
planned
feature. It gets requested a lot but nobody ever volunteers for
implementing it.

--
sebastian
--
You received this message because you are subscribed to the Google Groups "Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
Alejandro Imass
2017-06-17 13:59:47 UTC
Permalink
Post by sri
Post by Alejandro Imass
It would be nice though if this is supported in the future or if
someone volunteers to submit a patch in this regard.
Patches welcome, allowing custom expanders (besides JSON) for Mojo::Pg is a
planned
feature. It gets requested a lot but nobody ever volunteers for implementing
it.
Thanks Sebastian!

If I finish this on time I will try to get it working and fully
understand the idx, name logic ;-)

I could figure out that $idx is for array and $name is for hash but
wasn't sure about many things such as in which cases @$self{qw(idx
name)} would be pre-set when entering _expand (i.e. when would this
happen: my ($idx, $name) = @$self{qw(idx name)} when entering
_expand??);

I guess fully custom expanders seems like a bit of work but supporting
a few non-standard automatic cases like bytea and maybe couple of
others does not seem that much work (just MHO since it's the first
time doing anything serious with Mojo::Pg)

Best,
Alejandro Imass
--
You received this message because you are subscribed to the Google Groups "Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
Loading...