connectivity/source/drivers/firebird/Table.cxx |   19 +++----------------
 1 file changed, 3 insertions(+), 16 deletions(-)

New commits:
commit 6d782b57e0d8965dda279c2e73e2e91844f6f341
Author:     Julien Nabet <serval2...@yahoo.fr>
AuthorDate: Fri Dec 1 16:24:54 2023 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Sat Dec 2 12:34:30 2023 +0100

    tdf#158452: FB: impossible to change field to "entry required" in GUI
    
    ... after table has been saved.
    
    There was an hack due to the fact that before FB 3.0, it wasn't possible to 
use ALTER TABLE to change nullable.
    See https://bugs.documentfoundation.org/show_bug.cgi?id=158452#c1
    Since the hack doesn't work and since FB 3.0 since several years, let's 
remove the hack and use ALTER TABLE command.
    
    Change-Id: I145077bb4c4874f5fe31e375cfb64176a1293575
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160220
    Reviewed-by: Julien Nabet <serval2...@yahoo.fr>
    Tested-by: Jenkins
    (cherry picked from commit 735b6b3861ed898dafa5c9d08400c37d1996283e)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160173
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/connectivity/source/drivers/firebird/Table.cxx 
b/connectivity/source/drivers/firebird/Table.cxx
index c32160b99979..871febcf5122 100644
--- a/connectivity/source/drivers/firebird/Table.cxx
+++ b/connectivity/source/drivers/firebird/Table.cxx
@@ -155,27 +155,14 @@ void SAL_CALL Table::alterColumnByName(const OUString& 
rColName,
         if (nNullable != ColumnValue::NULLABLE_UNKNOWN)
         {
 
-            OUString sSql;
-            // Dirty hack: can't change null directly in sql, we have to fiddle
-            // the system tables manually.
+            OUString sSql(getAlterTableColumn(rColName));
             if (nNullable == ColumnValue::NULLABLE)
             {
-                sSql = "UPDATE RDB$RELATION_FIELDS SET RDB$NULL_FLAG = NULL "
-                       "WHERE RDB$FIELD_NAME = '" + rColName + "' "
-                       "AND RDB$RELATION_NAME = '" + getName() + "'";
+                sSql += "DROP NOT NULL";
             }
             else if (nNullable == ColumnValue::NO_NULLS)
             {
-                // And if we are making NOT NULL then we have to make sure we 
have
-                // no nulls left in the column.
-                OUString sFillNulls("UPDATE \"" + getName() + "\" SET \""
-                                    + rColName + "\" = 0 "
-                                    "WHERE \"" + rColName + "\" IS NULL");
-                getConnection()->createStatement()->execute(sFillNulls);
-
-                sSql = "UPDATE RDB$RELATION_FIELDS SET RDB$NULL_FLAG = 1 "
-                       "WHERE RDB$FIELD_NAME = '" + rColName + "' "
-                       "AND RDB$RELATION_NAME = '" + getName() + "'";
+                sSql += "SET NOT NULL";
             }
             getConnection()->createStatement()->execute(sSql);
         }

Reply via email to