diff --git a/docs/en_US/release_notes_9_9.rst b/docs/en_US/release_notes_9_9.rst index 343e79fc1..249d3e859 100644 --- a/docs/en_US/release_notes_9_9.rst +++ b/docs/en_US/release_notes_9_9.rst @@ -30,6 +30,7 @@ Housekeeping Bug fixes ********* + | `Issue #9098 `_ - Fixed an issue where the query tool displayed 'default' instead of 'null' for null text data in the data output. | `Issue #9158 `_ - Fixed an issue where saving the newly changed preferences was not reflecting on the preferences tab. | `Issue #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. | `Issue #9157 `_ - Fixed an issue where shortcuts are not working as expected on multiple keyboard layouts. diff --git a/web/pgadmin/tools/sqleditor/static/js/components/sections/ResultSet.jsx b/web/pgadmin/tools/sqleditor/static/js/components/sections/ResultSet.jsx index 80a0f562a..4a9467259 100644 --- a/web/pgadmin/tools/sqleditor/static/js/components/sections/ResultSet.jsx +++ b/web/pgadmin/tools/sqleditor/static/js/components/sections/ResultSet.jsx @@ -428,7 +428,7 @@ export class ResultSetUtils { async (formData) => { try { await connectServer( - this.api, + this.api, this.queryToolCtx.modal, this.queryToolCtx.params.sid, this.queryToolCtx.params.user, @@ -669,8 +669,9 @@ export class ResultSetUtils { return columnVal; } - processRows(result, columns, fromClipboard=false, pasteSerials=false) { + processRows(result, columns, options={}) { let retVal = []; + let {fromClipboard=false, pasteSerials=false, isNewRow=false} = options; if(!_.isArray(result) || !_.size(result)) { return retVal; } @@ -685,8 +686,9 @@ export class ResultSetUtils { // Convert 2darray to dict. let rowObj = {}; for(const col of columns) { - // if column data is undefined and there is not default value then set it to null. - let columnVal = rec[col.pos] ?? (col.has_default_val ? undefined : null); + // if column data is not present for existing rows then use null + // for new rows, it should be undefined if there is default value. + let columnVal = rec[col.pos] ?? ((col.has_default_val && isNewRow) ? undefined : null); /* If the source is clipboard, then it needs some extra handling */ if(fromClipboard) { columnVal = this.processClipboardVal(columnVal, col, copiedRowsObjects[recIdx]?.[col.key], pasteSerials); @@ -1379,7 +1381,7 @@ export function ResultSet() { }, [selectedRows, queryData, dataChangeStore, rows, allRowsSelect]); useEffect(()=>{ - const triggerAddRows = (_rows, fromClipboard, pasteSerials)=>{ + const triggerAddRows = (_rows, options)=>{ let insPosn = 0; if(selectedRows.size > 0) { let selectedRowsSorted = Array.from(selectedRows); @@ -1396,7 +1398,7 @@ export function ResultSet() { return x; }); } - let newRows = rsu.current.processRows(_rows, columns, fromClipboard, pasteSerials); + let newRows = rsu.current.processRows(_rows, columns, options); setRows((prev)=>[ ...prev.slice(0, insPosn), ...newRows, diff --git a/web/pgadmin/tools/sqleditor/static/js/components/sections/ResultSetToolbar.jsx b/web/pgadmin/tools/sqleditor/static/js/components/sections/ResultSetToolbar.jsx index 65b8da7de..1f831374f 100644 --- a/web/pgadmin/tools/sqleditor/static/js/components/sections/ResultSetToolbar.jsx +++ b/web/pgadmin/tools/sqleditor/static/js/components/sections/ResultSetToolbar.jsx @@ -281,13 +281,13 @@ export function ResultSetToolbar({query, canEdit, totalRowCount, pagination, all field_separator: queryToolPref.results_grid_field_separator, }); let copiedRows = copyUtils.getCopiedRows(); - eventBus.fireEvent(QUERY_TOOL_EVENTS.TRIGGER_ADD_ROWS, copiedRows, true, checkedMenuItems['paste_with_serials']); + eventBus.fireEvent(QUERY_TOOL_EVENTS.TRIGGER_ADD_ROWS, copiedRows, {fromClipboard: true, pasteSerials: checkedMenuItems['paste_with_serials']}); }, [queryToolPref, checkedMenuItems['paste_with_serials']]); const copyData = ()=>{ eventBus.fireEvent(QUERY_TOOL_EVENTS.COPY_DATA, checkedMenuItems['copy_with_headers']); }; const addRow = useCallback(()=>{ - eventBus.fireEvent(QUERY_TOOL_EVENTS.TRIGGER_ADD_ROWS, [[]]); + eventBus.fireEvent(QUERY_TOOL_EVENTS.TRIGGER_ADD_ROWS, [[]], {isNewRow: true}); }, []); const downloadResult = useCallback(()=>{ eventBus.fireEvent(QUERY_TOOL_EVENTS.TRIGGER_SAVE_RESULTS);