Subject: | patch: format Pg arrays |
14:12 < ether> at what point are arrays serialized to their '{1,2,3}' form? is that way down in DBD::Pg?
14:12 < ether> I wish there was a way of making this trace output more readable:
14:12 < ether> UPDATE device SET links = array_cat_distinct(links,?), updated = now() WHERE ( ( not(links @> ?) AND id = ? ) ): 'ARRAY(0x7f940c5043f8)', 'ARRAY(0x7f940c5043f8)',
'c818345c-9e5f-41b4-a57f-f4758c72f5dd'
14:12 < ether> seeing a serialized reference is not great for debugging what I actually passed in my binds :)
14:16 < mst> ether: oh that's interesting
14:16 < mst> I bet that'll be your debug logger serialising it because it's derived from code I wrote long before I even knew pg arrays existed
14:17 < mst> gimme a minute
14:19 < mst> see if query_start in Storage::Statistics gets the un-stringified version
14:19 < mst> or check what your trace profile is
14:22 < mst> ref($schema->storage->debugobj) or something might tell you too
14:23 < ether> checking...
14:25 < ether> no, query_start gets [ '\'ARRAY(0x7faf9bf0c458)\'', ... ] in @binds
14:25 < ether> so it's ::Storage::DBI doing it, so it's fixable
14:26 < ether> yeah, _format_for_trace
14:26 < ether> ..just needs tweaking
Here is a patch that DTRT, prepared against 0.082841.
diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm
index 9600389b..6f69314b 100644
--- a/lib/DBIx/Class/Storage/DBI.pm
+++ b/lib/DBIx/Class/Storage/DBI.pm
@@ -1757,7 +1757,7 @@ sub _format_for_trace {
map {
defined( $_ && $_->[1] )
- ? qq{'$_->[1]'}
+ ? (ref($_->[1]) eq 'ARRAY' ? qq('{).join(',',map qq{"$_"},@{$_->[1]}).qq(}') : qq{'$_->[1]'})
: q{NULL}
} @{$_[1] || []};
}