Skip to content

Commit 9c4d2e2

Browse files
committed
new version 1.2.4
1 parent fd2a40b commit 9c4d2e2

File tree

7 files changed

+74
-57
lines changed

7 files changed

+74
-57
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ It also provides functionality that the JDBC driver implemented in LibreOffice d
444444
- Declare it as auto-increment (Identity) without it necessarily being the primary key.
445445
- Add or remove the Identity constraint (auto-increment).
446446
- Add comments.
447+
- Many improvements.
447448

448449
### What remains to be done for version 1.2.4:
449450

@@ -455,7 +456,7 @@ It also provides functionality that the JDBC driver implemented in LibreOffice d
455456
[2]: <https://prrvchr.github.io/jdbcDriverOOo/>
456457
[3]: <https://prrvchr.github.io/jdbcDriverOOo/README_fr>
457458
[4]: <https://prrvchr.github.io/jdbcDriverOOo/source/jdbcDriverOOo/registration/TermsOfUse_en>
458-
[5]: <https://prrvchr.github.io/jdbcDriverOOo/#what-has-been-done-for-version-121>
459+
[5]: <https://prrvchr.github.io/jdbcDriverOOo/#what-has-been-done-for-version-124>
459460
[6]: <https://prrvchr.github.io/>
460461
[7]: <https://www.libreoffice.org/download/download-libreoffice/>
461462
[8]: <https://www.openoffice.org/download/index.html>
@@ -539,6 +540,6 @@ It also provides functionality that the JDBC driver implemented in LibreOffice d
539540
[86]: <https://github.com/prrvchr/jdbcDriverOOo/blob/master/source/jdbcDriverOOo/source/io/github/prrvchr/uno/sdbcx/KeyContainer.java>
540541
[87]: <https://github.com/prrvchr/jdbcDriverOOo/blob/master/source/jdbcDriverOOo/source/io/github/prrvchr/uno/sdbcx/IndexContainer.java>
541542
[88]: <https://github.com/prrvchr/jdbcDriverOOo/blob/master/source/jdbcDriverOOo/source/io/github/prrvchr/uno/sdbcx/Container.java>
542-
[89]: <https://github.com/prrvchr/jdbcDriverOOo/blob/master/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/DBTableHelper.java#L179>
543+
[89]: <https://github.com/prrvchr/jdbcDriverOOo/blob/master/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/DBTableHelper.java#L178>
543544
[90]: <https://github.com/FirebirdSQL/jaybird/issues/791>
544-
[91]: <https://github.com/prrvchr/jdbcDriverOOo/blob/master/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/DBTableHelper.java#L281>
545+
[91]: <https://github.com/prrvchr/jdbcDriverOOo/blob/master/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/DBTableHelper.java#L276>

README_fr.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ Il permet également d'offrir des fonctionnalités que le pilote JDBC implément
444444
- La déclarer en auto-incrément (Identity) sans qu'elle soit nécessairement la clé primaire.
445445
- Ajouter ou retirer la contrainte Identity (auto-incrément).
446446
- Ajouter des commentaires.
447+
- De nombreuses améliorations.
447448

448449
### Que reste-t-il à faire pour la version 1.2.4:
449450

@@ -455,7 +456,7 @@ Il permet également d'offrir des fonctionnalités que le pilote JDBC implément
455456
[2]: <https://prrvchr.github.io/jdbcDriverOOo/>
456457
[3]: <https://prrvchr.github.io/jdbcDriverOOo/>
457458
[4]: <https://prrvchr.github.io/jdbcDriverOOo/source/jdbcDriverOOo/registration/TermsOfUse_fr>
458-
[5]: <https://prrvchr.github.io/jdbcDriverOOo/README_fr#ce-qui-a-%C3%A9t%C3%A9-fait-pour-la-version-121>
459+
[5]: <https://prrvchr.github.io/jdbcDriverOOo/README_fr#ce-qui-a-%C3%A9t%C3%A9-fait-pour-la-version-124>
459460
[6]: <https://prrvchr.github.io/README_fr>
460461
[7]: <https://fr.libreoffice.org/download/telecharger-libreoffice/>
461462
[8]: <https://www.openoffice.org/fr/Telecharger/>
@@ -539,6 +540,6 @@ Il permet également d'offrir des fonctionnalités que le pilote JDBC implément
539540
[86]: <https://github.com/prrvchr/jdbcDriverOOo/blob/master/source/jdbcDriverOOo/source/io/github/prrvchr/uno/sdbcx/KeyContainer.java>
540541
[87]: <https://github.com/prrvchr/jdbcDriverOOo/blob/master/source/jdbcDriverOOo/source/io/github/prrvchr/uno/sdbcx/IndexContainer.java>
541542
[88]: <https://github.com/prrvchr/jdbcDriverOOo/blob/master/source/jdbcDriverOOo/source/io/github/prrvchr/uno/sdbcx/Container.java>
542-
[89]: <https://github.com/prrvchr/jdbcDriverOOo/blob/master/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/DBTableHelper.java#L179>
543+
[89]: <https://github.com/prrvchr/jdbcDriverOOo/blob/master/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/DBTableHelper.java#L178>
543544
[90]: <https://github.com/FirebirdSQL/jaybird/issues/791>
544-
[91]: <https://github.com/prrvchr/jdbcDriverOOo/blob/master/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/DBTableHelper.java#L281>
545+
[91]: <https://github.com/prrvchr/jdbcDriverOOo/blob/master/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/DBTableHelper.java#L276>

source/jdbcDriverOOo/Drivers.xcu

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@
737737
</node>
738738

739739
<node oor:name="MetaData">
740-
<node oor:name="IsPrimaryKeyAlterable" oor:op="replace">
740+
<node oor:name="SupportsAlterPrimaryKey" oor:op="replace">
741741
<prop oor:name="Value" oor:type="xs:boolean">
742742
<value>false</value>
743743
</prop>
@@ -747,7 +747,12 @@
747747
<value>false</value>
748748
</prop>
749749
</node>
750-
<node oor:name="IsColumnPropertyAlterable" oor:op="replace">
750+
<node oor:name="SupportsAlterColumnType" oor:op="replace">
751+
<prop oor:name="Value" oor:type="xs:boolean">
752+
<value>false</value>
753+
</prop>
754+
</node>
755+
<node oor:name="SupportsAlterColumnProperty" oor:op="replace">
751756
<prop oor:name="Value" oor:type="xs:boolean">
752757
<value>false</value>
753758
</prop>

source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/DBTableHelper.java

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ public Object[] getQueryArguments(String table)
171171
* The CREATE TABLE statement.
172172
* @throws java.sql.SQLException
173173
* @throws SQLException
174-
* @throws IllegalArgumentException
175174
* @throws WrappedTargetException
176175
* @throws IndexOutOfBoundsException
177176
* @throws UnknownPropertyException
@@ -181,7 +180,7 @@ public static List<String> getCreateTableQueries(DriverProvider provider,
181180
String table,
182181
ComposeRule rule,
183182
boolean sensitive)
184-
throws java.sql.SQLException, SQLException, IllegalArgumentException, WrappedTargetException, IndexOutOfBoundsException, UnknownPropertyException
183+
throws java.sql.SQLException, SQLException, WrappedTargetException, IndexOutOfBoundsException, UnknownPropertyException
185184
{
186185
String separator = ", ";
187186
boolean hasAutoIncrement = false;
@@ -217,7 +216,7 @@ public static List<String> getCreateTableQueries(DriverProvider provider,
217216
// XXX: If the underlying driver allows it, we create the primary key in a DDL command
218217
// XXX: separate from the one that creates the table. But there are specific cases!!!
219218
boolean autopk = provider.isAutoIncrementIsPrimaryKey();
220-
boolean alterpk = provider.isPrimaryKeyAlterable();
219+
boolean alterpk = provider.supportsAlterPrimaryKey();
221220
// XXX: MariaDB only permit to create auto increment if the PK is created while the table creation (second test)
222221
if ((alterpk && !autopk) || (alterpk && autopk && !hasAutoIncrement)) {
223222
queries.addAll(0, getCreateConstraintQueries(provider, property, property, "", rule, sensitive));
@@ -270,10 +269,6 @@ private static String getColumnDescriptionQuery(DriverProvider provider,
270269
* The binary result (ie: 1 -> renamed, 2 -> type changed ...)
271270
* @throws java.sql.SQLException
272271
* @throws SQLException
273-
* @throws IllegalArgumentException
274-
* @throws WrappedTargetException
275-
* @throws IndexOutOfBoundsException
276-
* @throws UnknownPropertyException
277272
*/
278273
// XXX: This method is called from 2 places:
279274
// XXX: - ColumnContainerBase.createColumn() for any new column.
@@ -321,9 +316,13 @@ public static byte getAlterColumnQueries(List<String> queries,
321316
boolean autochanged = auto1 != auto2 && provider.supportsAlterIdentity();
322317

323318
// XXX: Type have been changed
324-
String type1 = DBTools.getDescriptorStringValue(descriptor1, PropertyIds.TYPENAME);
325-
String type2 = DBTools.getDescriptorStringValue(descriptor2, PropertyIds.TYPENAME);
326-
boolean typechanged = !type2.equals(type1);
319+
boolean typechanged = false;
320+
// XXX: Changing column type is only allowed if the underlying driver supports it.
321+
if (provider.supportsAlterColumnType()) {
322+
String type1 = DBTools.getDescriptorStringValue(descriptor1, PropertyIds.TYPENAME);
323+
String type2 = DBTools.getDescriptorStringValue(descriptor2, PropertyIds.TYPENAME);
324+
typechanged = !type2.equals(type1);
325+
}
327326

328327
boolean alldone = false;
329328
List<String> parts = new ArrayList<String>();
@@ -372,35 +371,36 @@ public static byte getAlterColumnQueries(List<String> queries,
372371
}
373372
queries.addAll(parts);
374373

375-
boolean altercolumn = provider.isColumnPropertyAlterable();
376-
String default1 = DBTools.getDescriptorStringValue(descriptor1, PropertyIds.DEFAULTVALUE);
377-
String default2 = DBTools.getDescriptorStringValue(descriptor2, PropertyIds.DEFAULTVALUE);
378-
boolean defaultchanged = !default2.equals(default1);
379-
//FIXME: Primary key & auto-increment column don't have to handle Default property
380-
if (altercolumn && !alterpk && !alldone && defaultchanged) {
381-
if (default2.isBlank()) {
382-
query = provider.getColumnResetDefaultQuery();
383-
}
384-
else {
385-
query = DBDefaultQuery.STR_QUERY_ALTER_COLUMN_SET_DEFAULT;
374+
// XXX: Primary key & auto-increment column don't have to handle Default and Not Null property,
375+
// XXX: and some underlying driver doesn't support alteration of column.
376+
if (!alldone && !alterpk && !auto2 && provider.supportsAlterColumnProperty()) {
377+
String default1 = DBTools.getDescriptorStringValue(descriptor1, PropertyIds.DEFAULTVALUE);
378+
String default2 = DBTools.getDescriptorStringValue(descriptor2, PropertyIds.DEFAULTVALUE);
379+
boolean defaultchanged = !default2.equals(default1);
380+
if (defaultchanged) {
381+
if (default2.isBlank()) {
382+
query = provider.getColumnResetDefaultQuery();
383+
}
384+
else {
385+
query = DBDefaultQuery.STR_QUERY_ALTER_COLUMN_SET_DEFAULT;
386+
}
387+
queries.add(MessageFormat.format(query, arguments));
388+
result |= 8;
386389
}
387-
queries.add(MessageFormat.format(query, arguments));
388-
result |= 8;
389-
}
390390

391-
int nullable1 = DBTools.getDescriptorIntegerValue(descriptor1, PropertyIds.ISNULLABLE);
392-
int nullable2 = DBTools.getDescriptorIntegerValue(descriptor2, PropertyIds.ISNULLABLE);
393-
boolean nullablechanged = nullable2 != nullable1;
394-
//FIXME: Primary key & auto-increment column don't have to handle Not Null property
395-
if (altercolumn && !alterpk && !alldone && nullablechanged) {
396-
if (nullable2 == ColumnValue.NO_NULLS) {
397-
query = DBDefaultQuery.STR_QUERY_ALTER_COLUMN_SET_NOT_NULL;
398-
}
399-
else {
400-
query = DBDefaultQuery.STR_QUERY_ALTER_COLUMN_DROP_NOT_NULL;
391+
int nullable1 = DBTools.getDescriptorIntegerValue(descriptor1, PropertyIds.ISNULLABLE);
392+
int nullable2 = DBTools.getDescriptorIntegerValue(descriptor2, PropertyIds.ISNULLABLE);
393+
boolean nullablechanged = nullable2 != nullable1;
394+
if (nullablechanged) {
395+
if (nullable2 == ColumnValue.NO_NULLS) {
396+
query = DBDefaultQuery.STR_QUERY_ALTER_COLUMN_SET_NOT_NULL;
397+
}
398+
else {
399+
query = DBDefaultQuery.STR_QUERY_ALTER_COLUMN_DROP_NOT_NULL;
400+
}
401+
queries.add(MessageFormat.format(query, arguments));
402+
result |= 16;
401403
}
402-
queries.add(MessageFormat.format(query, arguments));
403-
result |= 16;
404404
}
405405
}
406406

source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/DriverProvider.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,17 @@ public void setConnection(ResourceBasedEventLogger logger,
118118
// - In the primary key definition (true)
119119
public boolean isAutoIncrementIsPrimaryKey();
120120

121-
// Does the underlying database driver support altering default value and null constraint on column
121+
// Does the underlying database driver support altering column type
122122
// Default value is true.
123-
public Boolean isColumnPropertyAlterable();
123+
public Boolean supportsAlterColumnType();
124+
125+
// Does the underlying database driver support altering column default value and not null constraint
126+
// Default value is true.
127+
public Boolean supportsAlterColumnProperty();
124128

125129
// Does the underlying database driver support adding, removing or altering primary key
126130
// Default value is true.
127-
public Boolean isPrimaryKeyAlterable();
131+
public Boolean supportsAlterPrimaryKey();
128132

129133
// Does the underlying database driver support java.sql.Statement.getGeneratedValues()
130134
// Default value is false.

source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/DriverProviderMain.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ public abstract class DriverProviderMain
8181
private String m_AutoIncrementCreation = "";
8282
private boolean m_AddIndexAppendix = false;
8383
private boolean m_IsAutoIncrementIsPrimaryKey = false;
84-
private boolean m_IsColumnPropertyAlterable = true;
85-
private boolean m_IsPrimaryKeyAlterable = true;
84+
private boolean m_SupportsAlterColumnType = true;
85+
private boolean m_SupportsAlterColumnProperty = true;
86+
private boolean m_SupportsAlterPrimaryKey = true;
8687
private boolean m_IsAutoRetrievingEnabled = false;
8788
private boolean m_IsResultSetUpdatable = false;
8889
private String m_AutoRetrievingStatement = "";
@@ -537,8 +538,10 @@ public void setConnection(ResourceBasedEventLogger logger,
537538
m_SupportsAlterIdentity = getDriverBooleanProperty(config1, "SupportsAlterIdentity", m_SupportsAlterIdentity);
538539
m_SupportsRenameView = getDriverBooleanProperty(config1, "SupportsRenameView", m_SupportsRenameView);
539540
m_SupportsColumnDescription = getDriverBooleanProperty(config1, "SupportsColumnDescription", m_SupportsColumnDescription);
540-
m_IsPrimaryKeyAlterable = getDriverBooleanProperty(config1, "IsPrimaryKeyAlterable", m_IsPrimaryKeyAlterable);
541-
m_IsColumnPropertyAlterable = getDriverBooleanProperty(config1, "IsColumnPropertyAlterable", m_IsColumnPropertyAlterable);
541+
m_SupportsAlterPrimaryKey = getDriverBooleanProperty(config1, "SupportsAlterPrimaryKey", m_SupportsAlterPrimaryKey);
542+
543+
m_SupportsAlterColumnType = getDriverBooleanProperty(config1, "SupportsAlterColumnType", m_SupportsAlterColumnType);
544+
m_SupportsAlterColumnProperty = getDriverBooleanProperty(config1, "SupportsAlterColumnProperty", m_SupportsAlterColumnProperty);
542545
m_CreateTableCommand = getDriverStringProperty(config1, "CreateTableCommand", m_CreateTableCommand);
543546
m_DropTableCommand = getDriverStringProperty(config1, "DropTableCommand", m_DropTableCommand);
544547
m_AlterColumnCommand = getDriverStringProperty(config1, "AlterColumnCommand", m_AlterColumnCommand);
@@ -625,11 +628,14 @@ public boolean isAutoRetrievingEnabled() {
625628
public boolean isAutoIncrementIsPrimaryKey() {
626629
return m_IsAutoIncrementIsPrimaryKey;
627630
}
628-
public Boolean isColumnPropertyAlterable() {
629-
return m_IsColumnPropertyAlterable;
631+
public Boolean supportsAlterColumnType() {
632+
return m_SupportsAlterColumnType;
630633
}
631-
public Boolean isPrimaryKeyAlterable() {
632-
return m_IsPrimaryKeyAlterable;
634+
public Boolean supportsAlterColumnProperty() {
635+
return m_SupportsAlterColumnProperty;
636+
}
637+
public Boolean supportsAlterPrimaryKey() {
638+
return m_SupportsAlterPrimaryKey;
633639
}
634640
public String getAutoRetrievingStatement() {
635641
return m_AutoRetrievingStatement;

source/jdbcDriverOOo/source/io/github/prrvchr/uno/sdbcx/KeyContainer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ private boolean createKey(XPropertySet descriptor, String key)
144144
{
145145
try {
146146
DriverProvider provider = getConnection().getProvider();
147-
if (!provider.isPrimaryKeyAlterable()) {
147+
if (!provider.supportsAlterPrimaryKey()) {
148148
int resource = Resources.STR_LOG_KEY_ADD_UNSUPPORTED_FEATURE_ERROR;
149149
String msg = SharedResources.getInstance().getResourceWithSubstitution(resource, m_table.getName());
150150
throw new SQLException(msg, this, StandardSQLState.SQL_FEATURE_NOT_IMPLEMENTED.text(), 0, Any.VOID);
@@ -234,7 +234,7 @@ protected void removeDataBaseElement(int index,
234234
{
235235
try {
236236
DriverProvider provider = getConnection().getProvider();
237-
if (!provider.isPrimaryKeyAlterable()) {
237+
if (!provider.supportsAlterPrimaryKey()) {
238238
int resource = Resources.STR_LOG_KEY_REMOVE_UNSUPPORTED_FEATURE_ERROR;
239239
String msg = SharedResources.getInstance().getResourceWithSubstitution(resource, m_table.getName());
240240
throw new SQLException(msg, this, StandardSQLState.SQL_FEATURE_NOT_IMPLEMENTED.text(), 0, Any.VOID);

0 commit comments

Comments
 (0)