Hi Hackers,

PFA updated the patch.

On Wed, Sep 21, 2022 at 12:14 PM Aditya Toshniwal <
aditya.toshni...@enterprisedb.com> wrote:

> Hi Nikhil,
>
> I think this fix is incomplete. This is not particularly for PK. Non-PK
> columns can also have default values.
> To cover all, the solution should be if a column which has default value
> is made empty then use default and not null.
>
> On Wed, Sep 21, 2022 at 11:10 AM Nikhil Mohite <
> nikhil.moh...@enterprisedb.com> wrote:
>
>> Hi Hackers,
>>
>> Please find attached the patch for GI-5308
>> <https://github.com/pgadmin-org/pgadmin4/issues/5308>:  Cannot set a
>> data field "default", makes it impossible to copy tuples with PK or SERIAL
>>
>>
>> --
>> *Thanks & Regards,*
>> *Nikhil Mohite*
>> *Senior Software Engineer.*
>> *EDB Postgres* <https://www.enterprisedb.com/>
>> *Mob.No: +91-7798364578.*
>>
>
>
> --
> Thanks,
> Aditya Toshniwal
> pgAdmin Hacker | Software Architect | *edbpostgres.com*
> <http://edbpostgres.com>
> "Don't Complain about Heat, Plant a TREE"
>

Regards,
Nikhil Mohite
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 92fc3fa4f..4413fe337 100644
--- a/web/pgadmin/tools/sqleditor/static/js/components/sections/ResultSet.jsx
+++ b/web/pgadmin/tools/sqleditor/static/js/components/sections/ResultSet.jsx
@@ -1248,6 +1248,11 @@ export function ResultSet() {
     let row = newRows[otherInfo.indexes[0]];
     let clientPK = rowKeyGetter(row);
 
+    // Check if column is pk and value is null set it to default value.
+    if(otherInfo.column.has_default_val && _.isNull(row[otherInfo.column.key])) {
+      row[otherInfo.column.key] = undefined;
+    }
+
     if(clientPK in (dataChangeStore.added || {})) {
       /* No need to track this */
     } else if(clientPK in (dataChangeStore.updated || {})) {

Reply via email to