Re: [HACKERS] mogrify and indent features for jsonb

2015-05-12 Thread Eva7
Yeaha didn't work either on http://jsonprettyprint.net http://jsonprettyprint.net for me. -- View this message in context: http://postgresql.nabble.com/mogrify-and-indent-features-for-jsonb-tp5838008p5848933.html Sent from the PostgreSQL - hackers mailing list archive at Nabble.com. --

Re: [HACKERS] mogrify and indent features for jsonb

2015-04-29 Thread Kevin Grittner
Andrew Dunstan and...@dunslane.net wrote: It's a matter of taste, but I find things a lot easier to understand when they are symmetrical. Thus I like all the branches of an if to be either in a block or not, and I like braces to line up either horizontally or vertically. Perhaps this

Re: [HACKERS] mogrify and indent features for jsonb

2015-04-29 Thread Jan de Visser
On April 29, 2015 03:09:51 PM Andrew Dunstan wrote: On 04/29/2015 01:19 PM, Robert Haas wrote: On Mon, Apr 27, 2015 at 6:41 PM, Andrew Dunstan and...@dunslane.net wrote: There's one exception I, at least, have to this rule, namely when there's a corresponding compound if or else. I

Re: [HACKERS] mogrify and indent features for jsonb

2015-04-29 Thread Robert Haas
On Mon, Apr 27, 2015 at 6:41 PM, Andrew Dunstan and...@dunslane.net wrote: There's one exception I, at least, have to this rule, namely when there's a corresponding compound if or else. I personally find this unaesthetic to put it mildly: if (condition) statement; else {

Re: [HACKERS] mogrify and indent features for jsonb

2015-04-29 Thread Stephen Frost
* Alvaro Herrera (alvhe...@2ndquadrant.com) wrote: Robert Haas wrote: On Mon, Apr 27, 2015 at 6:41 PM, Andrew Dunstan and...@dunslane.net wrote: There's one exception I, at least, have to this rule, namely when there's a corresponding compound if or else. I personally find this

Re: [HACKERS] mogrify and indent features for jsonb

2015-04-29 Thread Alvaro Herrera
Robert Haas wrote: On Mon, Apr 27, 2015 at 6:41 PM, Andrew Dunstan and...@dunslane.net wrote: There's one exception I, at least, have to this rule, namely when there's a corresponding compound if or else. I personally find this unaesthetic to put it mildly: if (condition)

Re: [HACKERS] mogrify and indent features for jsonb

2015-04-29 Thread Petr Jelinek
On 27/04/15 18:46, Petr Jelinek wrote: On 18/04/15 20:35, Dmitry Dolgov wrote: Sorry for late reply. Here is a slightly improved version of the patch with the new `h_atoi` function, I hope this implementation will be more appropriate. It's better, but a) I don't like the name of the function

Re: [HACKERS] mogrify and indent features for jsonb

2015-04-27 Thread Andrew Dunstan
On 04/27/2015 12:46 PM, Petr Jelinek wrote: Another thing I noticed now when reading the code again - you should not be using braces when you only have one command in the code-block. There's one exception I, at least, have to this rule, namely when there's a corresponding compound if or

Re: [HACKERS] mogrify and indent features for jsonb

2015-04-27 Thread Petr Jelinek
On 18/04/15 20:35, Dmitry Dolgov wrote: Sorry for late reply. Here is a slightly improved version of the patch with the new `h_atoi` function, I hope this implementation will be more appropriate. It's better, but a) I don't like the name of the function b) I don't see why we need the

Re: [HACKERS] mogrify and indent features for jsonb

2015-03-13 Thread Petr Jelinek
On 01/03/15 16:49, Andrew Dunstan wrote: On 03/01/2015 05:03 AM, Petr Jelinek wrote: On 23/02/15 18:15, Dmitry Dolgov wrote: Hi, Petr, thanks for the review. I think it would be better if the ident printing didn't put the start of array ([) and start of dictionary ({) on separate line Did

Re: [HACKERS] mogrify and indent features for jsonb

2015-03-11 Thread Ilya Ashchepkov
On Sat, 14 Feb 2015 22:06:07 -0500 Andrew Dunstan and...@dunslane.net wrote: Hello. I have function with recursive merging objects: # SELECT jsonb_deep_extend('{a: {b: 6}}'::jsonb, '{a: {c: 7}}'::jsonb) AS new_jsonb; new_jsonb - {a: {b: 6, c: 7}}

Re: [HACKERS] mogrify and indent features for jsonb

2015-03-01 Thread Petr Jelinek
On 23/02/15 18:15, Dmitry Dolgov wrote: Hi, Petr, thanks for the review. I think it would be better if the ident printing didn't put the start of array ([) and start of dictionary ({) on separate line Did you mean this? [ { a: 1, b: 2 } ]

Re: [HACKERS] mogrify and indent features for jsonb

2015-03-01 Thread Andrew Dunstan
On 03/01/2015 05:03 AM, Petr Jelinek wrote: On 23/02/15 18:15, Dmitry Dolgov wrote: Hi, Petr, thanks for the review. I think it would be better if the ident printing didn't put the start of array ([) and start of dictionary ({) on separate line Did you mean this? [ {

Re: [HACKERS] mogrify and indent features for jsonb

2015-02-26 Thread Thom Brown
On 26 February 2015 at 15:09, Dmitry Dolgov 9erthali...@gmail.com wrote: Hi, Thom. Would this support deleting type and the value 'dd' With this patch you can delete them one by one: select '{a: 1, b: 2, c: {type: json, stuff: test}, d: [aa,bb,cc,dd]}'::jsonb - '{c, type}'::text[] -

Re: [HACKERS] mogrify and indent features for jsonb

2015-02-26 Thread Dmitry Dolgov
Hi, Thom. Would this support deleting type and the value 'dd' With this patch you can delete them one by one: select '{a: 1, b: 2, c: {type: json, stuff: test}, d: [aa,bb,cc,dd]}'::jsonb - '{c, type}'::text[] - '{d, -1}'::text[]; ?column?

Re: [HACKERS] mogrify and indent features for jsonb

2015-02-26 Thread Josh Berkus
On 02/26/2015 07:25 AM, Thom Brown wrote: Yeah, I think that may be problematic. I agree with Josh that there's probably no sane mix of operators for this, as I would expect your example to replace d: [aa,bb,cc,dd] with d: [ee] rather than append to it. Hmm... unless we used a + operator,

Re: [HACKERS] mogrify and indent features for jsonb

2015-02-25 Thread Josh Berkus
On 02/25/2015 03:13 AM, Thom Brown wrote: Can you think of a reasonable syntax for doing that via operators? I can imagine that as a json_path function, i.e.: jsonb_add_to_path(jsonb, text[], jsonb) or where the end of the path is an array: jsonb_add_to_path(jsonb,

Re: [HACKERS] mogrify and indent features for jsonb

2015-02-25 Thread Thom Brown
On 24 February 2015 at 19:16, Josh Berkus j...@agliodbs.com wrote: Is there a way to take the json: '{a: 1, b: 2, c: {type: json, stuff: test}, d: [aa,bb,cc,dd]}' and add ee to d without replacing it? I can think of ways of currently doing it, but it's very convoluted just for

Re: [HACKERS] mogrify and indent features for jsonb

2015-02-24 Thread Josh Berkus
Is there a way to take the json: '{a: 1, b: 2, c: {type: json, stuff: test}, d: [aa,bb,cc,dd]}' and add ee to d without replacing it? I can think of ways of currently doing it, but it's very convoluted just for pushing a value to an array. Can you think of a reasonable syntax for

Re: [HACKERS] mogrify and indent features for jsonb

2015-02-23 Thread Dmitry Dolgov
Hi, Petr, thanks for the review. I think it would be better if the ident printing didn't put the start of array ([) and start of dictionary ({) on separate line Did you mean this? [ { a: 1, b: 2 } ] I tried to verify this in several ways

Re: [HACKERS] mogrify and indent features for jsonb

2015-02-23 Thread Thom Brown
On 15 February 2015 at 03:06, Andrew Dunstan and...@dunslane.net wrote: Attached is a patch to provide a number of very useful facilities to jsonb that people have asked for. These are based on work by Dmitry Dolgov in his jsonbx extension, but I take responsibility for any bugs. The

Re: [HACKERS] mogrify and indent features for jsonb

2015-02-17 Thread Petr Jelinek
Hi, I looked at the patch and have several comments. First let me say that modifying the individual paths of the json is the feature I miss the most in the current implementation so I am happy that this patch was submitted. I would prefer slightly the patch split into two parts, one for the

Re: [HACKERS] mogrify and indent features for jsonb

2015-02-15 Thread Andrew Dunstan
On 02/15/2015 11:47 AM, Sehrope Sarkuni wrote: For jsonb_indent, how about having it match up closer to the JavaScript JSON.stringify(value, replacer, space)[1]? That way a user can specify the indentation level and optionally filter the fields they'd like to output. In JS, the replacer

Re: [HACKERS] mogrify and indent features for jsonb

2015-02-15 Thread Sehrope Sarkuni
For jsonb_indent, how about having it match up closer to the JavaScript JSON.stringify(value, replacer, space)[1]? That way a user can specify the indentation level and optionally filter the fields they'd like to output. In JS, the replacer parameter can be either a JS function or an array of

Re: [HACKERS] mogrify and indent features for jsonb

2015-02-15 Thread Andrew Dunstan
On 02/14/2015 10:06 PM, Andrew Dunstan wrote: Attached is a patch to provide a number of very useful facilities to jsonb that people have asked for. These are based on work by Dmitry Dolgov in his jsonbx extension, but I take responsibility for any bugs. The facilities are: new