public inbox for [email protected]
help / color / mirror / Atom feedFrom: Aditya Toshniwal <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: [pgAdmin][RM4969] JSONB and JSON field editing
Date: Fri, 10 Apr 2020 11:48:52 +0530
Message-ID: <CAM9w-_ndFNQshhg5QT9wUWL9TjB_k9QPC_XeiQ7UjXuj0NXYVQ@mail.gmail.com> (raw)
Hi Hackers,
Attached is the patch fix issue for jsonb and json field editing. Making
the field blank throws a validation error. The patch will set json, jsonb
to null when set to blank.
Please review.
--
Thanks and Regards,
Aditya Toshniwal
pgAdmin Hacker | Sr. Software Engineer | EnterpriseDB India | Pune
"Don't Complain about Heat, Plant a TREE"
Attachments:
[application/octet-stream] RM4969.patch (1.5K, 3-RM4969.patch)
download | inline diff:
diff --git a/web/pgadmin/static/js/slickgrid/editors.js b/web/pgadmin/static/js/slickgrid/editors.js
index 1dcc29d9b..1647d4b82 100644
--- a/web/pgadmin/static/js/slickgrid/editors.js
+++ b/web/pgadmin/static/js/slickgrid/editors.js
@@ -110,7 +110,7 @@ import gettext from 'sources/gettext';
grid.copied_rows[row][cell] = 1;
}
} else {
- if(column_type === 'jsonb') {
+ if(column_type === 'jsonb' && state != null) {
item[args.column.field] = JSONBigNumber.stringify(JSONBigNumber.parse(state));
} else {
item[args.column.field] = state;
@@ -361,7 +361,7 @@ import gettext from 'sources/gettext';
this.loadValue = function(item) {
var data = defaultValue = item[args.column.field];
/* If jsonb or array */
- if(args.column.column_type_internal === 'jsonb' && !Array.isArray(data)) {
+ if(args.column.column_type_internal === 'jsonb' && !Array.isArray(data) && data != null) {
data = JSONBigNumber.stringify(JSONBigNumber.parse(data), null, 4);
} else if (Array.isArray(data)) {
var temp = [];
@@ -406,7 +406,9 @@ import gettext from 'sources/gettext';
if(args.column.column_type_internal === 'jsonb' ||
args.column.column_type_internal === 'json') {
try {
- JSON.parse($input.val());
+ if($input.val() != ''){
+ JSON.parse($input.val());
+ }
} catch(e) {
$input.addClass('pg-text-invalid');
return {
view thread (2+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: [pgAdmin][RM4969] JSONB and JSON field editing
In-Reply-To: <CAM9w-_ndFNQshhg5QT9wUWL9TjB_k9QPC_XeiQ7UjXuj0NXYVQ@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox