public inbox for [email protected]
help / color / mirror / Atom feedPATCH: To fix JSON array handling (pgAdmin4)
2+ messages / 2 participants
[nested] [flat]
* PATCH: To fix JSON array handling (pgAdmin4)
@ 2016-09-21 10:43 Murtuza Zabuawala <[email protected]>
0 siblings, 1 reply; 2+ messages in thread
From: Murtuza Zabuawala @ 2016-09-21 10:43 UTC (permalink / raw)
To: pgadmin-hackers
Hi,
PFA patch to fix the issue where SlickGrid was not displaying nested JSON
data properly.
This patch fixes: RM#1713 & RM#1404
*Issue:*
Nested JSON data was not handled properly.
--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers
Attachments:
[application/octet-stream] RM_1713.patch (2.8K, 3-RM_1713.patch)
download | inline diff:
diff --git a/web/pgadmin/static/js/slickgrid/slick.pgadmin.editors.js b/web/pgadmin/static/js/slickgrid/slick.pgadmin.editors.js
index 6f2984a..05fbb91 100644
--- a/web/pgadmin/static/js/slickgrid/slick.pgadmin.editors.js
+++ b/web/pgadmin/static/js/slickgrid/slick.pgadmin.editors.js
@@ -230,6 +230,16 @@
var data = defaultValue = item[args.column.field];
if (typeof data === "object" && !Array.isArray(data)) {
data = JSON.stringify(data);
+ } else if (Array.isArray(data)) {
+ var temp = [];
+ $.each(data, function(i, val) {
+ if (typeof val === "object") {
+ temp.push(JSON.stringify(val));
+ } else {
+ temp.push(val)
+ }
+ });
+ data = "[" + temp.join() + "]";
}
$input.val(data);
$input.select();
@@ -466,6 +476,16 @@
var data = defaultValue = item[args.column.field];
if (typeof data === "object" && !Array.isArray(data)) {
data = JSON.stringify(data);
+ } else if (Array.isArray(data)) {
+ var temp = [];
+ $.each(data, function(i, val) {
+ if (typeof val === "object") {
+ temp.push(JSON.stringify(val));
+ } else {
+ temp.push(val)
+ }
+ });
+ data = "[" + temp.join() + "]";
}
$input.val(data);
$input.select();
diff --git a/web/pgadmin/static/js/slickgrid/slick.pgadmin.formatters.js b/web/pgadmin/static/js/slickgrid/slick.pgadmin.formatters.js
index b131657..3b4aa3c 100644
--- a/web/pgadmin/static/js/slickgrid/slick.pgadmin.formatters.js
+++ b/web/pgadmin/static/js/slickgrid/slick.pgadmin.formatters.js
@@ -24,6 +24,16 @@
// Stringify only if it's json object
if (typeof value === "object" && !Array.isArray(value)) {
return JSON.stringify(value);
+ } else if (Array.isArray(value)) {
+ var temp = [];
+ $.each(value, function(i, val) {
+ if (typeof val === "object") {
+ temp.push(JSON.stringify(val));
+ } else {
+ temp.push(val)
+ }
+ });
+ return "[" + temp.join() + "]"
} else {
return value;
}
diff --git a/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js b/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
index 74502c7..f7cf0ab 100644
--- a/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
+++ b/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
@@ -1790,7 +1790,7 @@ define(
*/
var explain_data_array = [];
if(
- data.result && data.result.length > 1 &&
+ data.result && data.result.length >= 1 &&
data.result[0] && data.result[0].hasOwnProperty(
'QUERY PLAN'
) && _.isObject(data.result[0]['QUERY PLAN'])
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: PATCH: To fix JSON array handling (pgAdmin4)
@ 2016-09-21 12:43 Dave Page <[email protected]>
parent: Murtuza Zabuawala <[email protected]>
0 siblings, 0 replies; 2+ messages in thread
From: Dave Page @ 2016-09-21 12:43 UTC (permalink / raw)
To: Murtuza Zabuawala <[email protected]>; +Cc: pgadmin-hackers
Thanks, applied.
On Wed, Sep 21, 2016 at 11:43 AM, Murtuza Zabuawala
<[email protected]> wrote:
> Hi,
>
> PFA patch to fix the issue where SlickGrid was not displaying nested JSON
> data properly.
> This patch fixes: RM#1713 & RM#1404
>
> Issue:
> Nested JSON data was not handled properly.
>
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
>
> --
> Sent via pgadmin-hackers mailing list ([email protected])
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgadmin-hackers
>
--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2016-09-21 12:43 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-09-21 10:43 PATCH: To fix JSON array handling (pgAdmin4) Murtuza Zabuawala <[email protected]>
2016-09-21 12:43 ` Dave Page <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox