Skip to content

Commit 93bbadb

Browse files
Fixed an issue where the query tool displayed 'default' instead of 'null' for null text data in the data output. #9098
1 parent 42ff67c commit 93bbadb

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

docs/en_US/release_notes_9_9.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Housekeeping
3030
Bug fixes
3131
*********
3232

33+
| `Issue #9098 <https://github.com/pgadmin-org/pgadmin4/issues/9098>`_ - Fixed an issue where the query tool displayed 'default' instead of 'null' for null text data in the data output.
3334
| `Issue #9158 <https://github.com/pgadmin-org/pgadmin4/issues/9158>`_ - Fixed an issue where saving the newly changed preferences was not reflecting on the preferences tab.
3435
| `Issue #9125 <https://github.com/pgadmin-org/pgadmin4/issues/9125>`_ - Fixed an issue where the pgAdmin configuration database wasn't being created on a fresh install when an external database was used for the configuration.
3536
| `Issue #9157 <https://github.com/pgadmin-org/pgadmin4/issues/9157>`_ - Fixed an issue where shortcuts are not working as expected on multiple keyboard layouts.

web/pgadmin/tools/sqleditor/static/js/components/sections/ResultSet.jsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ export class ResultSetUtils {
428428
async (formData) => {
429429
try {
430430
await connectServer(
431-
this.api,
431+
this.api,
432432
this.queryToolCtx.modal,
433433
this.queryToolCtx.params.sid,
434434
this.queryToolCtx.params.user,
@@ -669,8 +669,9 @@ export class ResultSetUtils {
669669
return columnVal;
670670
}
671671

672-
processRows(result, columns, fromClipboard=false, pasteSerials=false) {
672+
processRows(result, columns, options={}) {
673673
let retVal = [];
674+
let {fromClipboard=false, pasteSerials=false, isNewRow=false} = options;
674675
if(!_.isArray(result) || !_.size(result)) {
675676
return retVal;
676677
}
@@ -685,8 +686,9 @@ export class ResultSetUtils {
685686
// Convert 2darray to dict.
686687
let rowObj = {};
687688
for(const col of columns) {
688-
// if column data is undefined and there is not default value then set it to null.
689-
let columnVal = rec[col.pos] ?? (col.has_default_val ? undefined : null);
689+
// if column data is not present for existing rows then use null
690+
// for new rows, it should be undefined if there is default value.
691+
let columnVal = rec[col.pos] ?? ((col.has_default_val && isNewRow) ? undefined : null);
690692
/* If the source is clipboard, then it needs some extra handling */
691693
if(fromClipboard) {
692694
columnVal = this.processClipboardVal(columnVal, col, copiedRowsObjects[recIdx]?.[col.key], pasteSerials);
@@ -1379,7 +1381,7 @@ export function ResultSet() {
13791381
}, [selectedRows, queryData, dataChangeStore, rows, allRowsSelect]);
13801382

13811383
useEffect(()=>{
1382-
const triggerAddRows = (_rows, fromClipboard, pasteSerials)=>{
1384+
const triggerAddRows = (_rows, options)=>{
13831385
let insPosn = 0;
13841386
if(selectedRows.size > 0) {
13851387
let selectedRowsSorted = Array.from(selectedRows);
@@ -1396,7 +1398,7 @@ export function ResultSet() {
13961398
return x;
13971399
});
13981400
}
1399-
let newRows = rsu.current.processRows(_rows, columns, fromClipboard, pasteSerials);
1401+
let newRows = rsu.current.processRows(_rows, columns, options);
14001402
setRows((prev)=>[
14011403
...prev.slice(0, insPosn),
14021404
...newRows,

web/pgadmin/tools/sqleditor/static/js/components/sections/ResultSetToolbar.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,13 +281,13 @@ export function ResultSetToolbar({query, canEdit, totalRowCount, pagination, all
281281
field_separator: queryToolPref.results_grid_field_separator,
282282
});
283283
let copiedRows = copyUtils.getCopiedRows();
284-
eventBus.fireEvent(QUERY_TOOL_EVENTS.TRIGGER_ADD_ROWS, copiedRows, true, checkedMenuItems['paste_with_serials']);
284+
eventBus.fireEvent(QUERY_TOOL_EVENTS.TRIGGER_ADD_ROWS, copiedRows, {fromClipboard: true, pasteSerials: checkedMenuItems['paste_with_serials']});
285285
}, [queryToolPref, checkedMenuItems['paste_with_serials']]);
286286
const copyData = ()=>{
287287
eventBus.fireEvent(QUERY_TOOL_EVENTS.COPY_DATA, checkedMenuItems['copy_with_headers']);
288288
};
289289
const addRow = useCallback(()=>{
290-
eventBus.fireEvent(QUERY_TOOL_EVENTS.TRIGGER_ADD_ROWS, [[]]);
290+
eventBus.fireEvent(QUERY_TOOL_EVENTS.TRIGGER_ADD_ROWS, [[]], {isNewRow: true});
291291
}, []);
292292
const downloadResult = useCallback(()=>{
293293
eventBus.fireEvent(QUERY_TOOL_EVENTS.TRIGGER_SAVE_RESULTS);

0 commit comments

Comments
 (0)