diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2023-12-01 16:24:54 +0100 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2023-12-01 17:23:23 +0100 |
commit | 735b6b3861ed898dafa5c9d08400c37d1996283e (patch) | |
tree | 742c6caf58da83de713d7664df26de527721cbad /connectivity | |
parent | 67444341273377f25f688b3e67acd8b2a1346431 (diff) |
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 <serval2412@yahoo.fr>
Tested-by: Jenkins
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/drivers/firebird/Table.cxx | 19 |
1 files changed, 3 insertions, 16 deletions
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); } |