diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6e951414dd7..82e704b75f4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -185,7 +185,6 @@ jobs: DIRIGIBLE_DATASOURCE_DEFAULT_URL: jdbc:postgresql://localhost:5432/${{ env.POSTGRES_DB }} DIRIGIBLE_DATASOURCE_DEFAULT_USERNAME: ${{ env.POSTGRES_USER }} DIRIGIBLE_DATASOURCE_DEFAULT_PASSWORD: ${{ env.POSTGRES_PASS }} - DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE: true - name: Generate a random artifact name if: always() diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 1f3b81b3259..b349fcd037f 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -152,7 +152,6 @@ jobs: DIRIGIBLE_DATASOURCE_DEFAULT_URL: jdbc:postgresql://localhost:5432/${{ env.POSTGRES_DB }} DIRIGIBLE_DATASOURCE_DEFAULT_USERNAME: ${{ env.POSTGRES_USER }} DIRIGIBLE_DATASOURCE_DEFAULT_PASSWORD: ${{ env.POSTGRES_PASS }} - DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE: true - name: Generate a random artifact name if: always() diff --git a/build/application/src/main/resources/dirigible.properties b/build/application/src/main/resources/dirigible.properties index f8782870771..6c676688047 100644 --- a/build/application/src/main/resources/dirigible.properties +++ b/build/application/src/main/resources/dirigible.properties @@ -19,7 +19,6 @@ DIRIGIBLE_DATABASE_PROVIDER=local DIRIGIBLE_JAVASCRIPT_HANDLER_CLASS_NAME=org.eclipse.dirigible.graalium.handler.GraaliumJavascriptHandler DIRIGIBLE_GRAALIUM_ENABLE_DEBUG=true DIRIGIBLE_HOME_URL=services/web/ide/ -DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE=true DIRIGIBLE_MULTI_TENANT_MODE=true DIRIGIBLE_BRANDING_HELP_ITEMS=HELP,SUPPORT,FEATURE,NEWS,DOWNLOAD DIRIGIBLE_BRANDING_HELP_ITEM_HELP_NAME=Help Portal @@ -41,4 +40,4 @@ DIRIGIBLE_BRANDING_HELP_ITEM_NEWS_DIVIDER=false DIRIGIBLE_BRANDING_HELP_ITEM_DOWNLOAD_NAME=Check for Updates DIRIGIBLE_BRANDING_HELP_ITEM_DOWNLOAD_ORDER=5 DIRIGIBLE_BRANDING_HELP_ITEM_DOWNLOAD_URL=http://download.dirigible.io/ -DIRIGIBLE_BRANDING_HELP_ITEM_DOWNLOAD_DIVIDER=true \ No newline at end of file +DIRIGIBLE_BRANDING_HELP_ITEM_DOWNLOAD_DIVIDER=true diff --git a/build/helm-charts/dirigible/templates/dirigible.yaml b/build/helm-charts/dirigible/templates/dirigible.yaml index 1cedd935d1e..bcd439d6df6 100644 --- a/build/helm-charts/dirigible/templates/dirigible.yaml +++ b/build/helm-charts/dirigible/templates/dirigible.yaml @@ -118,8 +118,6 @@ spec: value: {{ required "Missing database password" .Values.database.password }} - name: DIRIGIBLE_MESSAGING_USE_DEFAULT_DATABASE value: "false" - - name: DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE - value: "true" - name: DIRIGIBLE_SCHEDULER_MEMORY_STORE value: "true" {{- end }} @@ -149,8 +147,6 @@ spec: key: password - name: DIRIGIBLE_MESSAGING_USE_DEFAULT_DATABASE value: "false" - - name: DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE - value: "true" - name: DIRIGIBLE_SCHEDULER_MEMORY_STORE value: "true" {{- end }} diff --git a/components/api/api-modules-javascript/src/main/resources/META-INF/dirigible/modules/src/db/dao.ts b/components/api/api-modules-javascript/src/main/resources/META-INF/dirigible/modules/src/db/dao.ts index 5ba70cb95d0..4f86c48f8cf 100644 --- a/components/api/api-modules-javascript/src/main/resources/META-INF/dirigible/modules/src/db/dao.ts +++ b/components/api/api-modules-javascript/src/main/resources/META-INF/dirigible/modules/src/db/dao.ts @@ -936,16 +936,10 @@ export function create(oDefinition, logCtxName, dataSourceName) { globals.set(dataSourceName, productName); } - let isCaseSensitive = configurations.get("DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE"); - if (!isCaseSensitive && productName === "PostgreSQL") { - orm["properties"].map(function (property) { - property.column = property.column.toLowerCase(); - }); - } // } return new DAO(orm, logCtxName, dataSourceName); }; export function dao(oDefinition, logCtxName, dataSourceName) { return create(oDefinition, logCtxName, dataSourceName) -} \ No newline at end of file +} diff --git a/components/api/api-modules-javascript/src/main/resources/META-INF/dirigible/modules/src/db/orm.ts b/components/api/api-modules-javascript/src/main/resources/META-INF/dirigible/modules/src/db/orm.ts index d66052303c6..5c62568bd27 100644 --- a/components/api/api-modules-javascript/src/main/resources/META-INF/dirigible/modules/src/db/orm.ts +++ b/components/api/api-modules-javascript/src/main/resources/META-INF/dirigible/modules/src/db/orm.ts @@ -40,7 +40,6 @@ * */ import { configurations } from "sdk/core"; -const isCaseSensitive = configurations.get("DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE"); export function ORM(orm) { this.orm = orm; @@ -223,7 +222,7 @@ ORM.prototype.toColumn = function (ormProperty) { let column; if (ormProperty) { column = { - name: isCaseSensitive ? "\"" + ormProperty.column + "\"" : ormProperty.column, + name: "\"" + ormProperty.column + "\"", type: ormProperty.type, length: String(ormProperty.length), primaryKey: String(ormProperty.id === undefined ? false : ormProperty.id), diff --git a/components/core/core-database/src/main/java/org/eclipse/dirigible/components/database/DatabaseParameters.java b/components/core/core-database/src/main/java/org/eclipse/dirigible/components/database/DatabaseParameters.java index c2b967bfe06..dba3e72cefc 100644 --- a/components/core/core-database/src/main/java/org/eclipse/dirigible/components/database/DatabaseParameters.java +++ b/components/core/core-database/src/main/java/org/eclipse/dirigible/components/database/DatabaseParameters.java @@ -14,9 +14,6 @@ */ public interface DatabaseParameters { - /** Whether or not to use case sensitive syntax for table or view names and column names. */ - String DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE = "DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE"; - /** The Constant DIRIGIBLE_DATABASE_DEFAULT_QUERY_LIMIT. */ String DIRIGIBLE_DATABASE_DEFAULT_QUERY_LIMIT = "DIRIGIBLE_DATABASE_DEFAULT_QUERY_LIMIT"; diff --git a/components/core/core-database/src/main/java/org/eclipse/dirigible/components/database/DatabaseSystem.java b/components/core/core-database/src/main/java/org/eclipse/dirigible/components/database/DatabaseSystem.java index ab166d69695..561427c14c4 100644 --- a/components/core/core-database/src/main/java/org/eclipse/dirigible/components/database/DatabaseSystem.java +++ b/components/core/core-database/src/main/java/org/eclipse/dirigible/components/database/DatabaseSystem.java @@ -4,7 +4,7 @@ public enum DatabaseSystem { // when adding or changing enum values do NOT forget to // update the JavaScript API in the connection class located at: // dirigible/modules/src/db/database.ts - UNKNOWN, DERBY, POSTGRESQL, H2, MARIADB, HANA, SNOWFLAKE, MYSQL, MONGODB, SYBASE; + UNKNOWN, DERBY, POSTGRESQL, H2, MARIADB, HANA, SNOWFLAKE, MYSQL, MONGODB; public boolean isH2() { return isOfType(H2); diff --git a/components/core/core-database/src/main/java/org/eclipse/dirigible/components/database/DatabaseSystemDeterminer.java b/components/core/core-database/src/main/java/org/eclipse/dirigible/components/database/DatabaseSystemDeterminer.java index 7d224006297..896c899aa04 100644 --- a/components/core/core-database/src/main/java/org/eclipse/dirigible/components/database/DatabaseSystemDeterminer.java +++ b/components/core/core-database/src/main/java/org/eclipse/dirigible/components/database/DatabaseSystemDeterminer.java @@ -24,7 +24,6 @@ public class DatabaseSystemDeterminer { DatabaseSystem.MARIADB, "jdbc:mariadb", // DatabaseSystem.MYSQL, "jdbc:mysql", // DatabaseSystem.MONGODB, "jdbc:mongodb", // - DatabaseSystem.SYBASE, "jdbc:sybase", // DatabaseSystem.DERBY, "jdbc:derby"// ); @@ -36,7 +35,6 @@ public class DatabaseSystemDeterminer { DatabaseSystem.MARIADB, List.of("org.mariadb.jdbc.Driver"), // DatabaseSystem.MYSQL, List.of("com.mysql.cj.jdbc.Driver"), // DatabaseSystem.MONGODB, List.of("com.mongodb.jdbc.MongoDriver"), // - DatabaseSystem.SYBASE, List.of("com.sybase.jdbc4.jdbc.SybDriver"), // DatabaseSystem.DERBY, List.of("org.apache.derby.jdbc.ClientDriver", "org.apache.derby.jdbc.EmbeddedDriver")// ); diff --git a/components/core/core-database/src/test/java/org/eclipse/dirigible/components/database/DatabaseSystemDeterminerTest.java b/components/core/core-database/src/test/java/org/eclipse/dirigible/components/database/DatabaseSystemDeterminerTest.java index 2beafc76502..9e5e1f47c42 100644 --- a/components/core/core-database/src/test/java/org/eclipse/dirigible/components/database/DatabaseSystemDeterminerTest.java +++ b/components/core/core-database/src/test/java/org/eclipse/dirigible/components/database/DatabaseSystemDeterminerTest.java @@ -98,16 +98,6 @@ void testDetermineMongoDB_withDriver() { testDetermine_withDriver("com.mongodb.jdbc.MongoDriver", DatabaseSystem.MONGODB); } - @Test - void testDetermineSybase_withUrl() { - testDetermine_withUrl("jdbc:sybase:Tds:localhost:3306/database", DatabaseSystem.SYBASE); - } - - @Test - void testDetermineSybase_withDriver() { - testDetermine_withDriver("com.sybase.jdbc4.jdbc.SybDriver", DatabaseSystem.SYBASE); - } - @Test void testDetermineUnknown_withUrl() { testDetermine_withUrl("jdbc:unknown://localhost:1234/testdb", DatabaseSystem.UNKNOWN); diff --git a/components/data/data-management/src/main/java/org/eclipse/dirigible/components/data/management/load/DataSourceMetadataLoader.java b/components/data/data-management/src/main/java/org/eclipse/dirigible/components/data/management/load/DataSourceMetadataLoader.java index 297df220552..ede78106369 100644 --- a/components/data/data-management/src/main/java/org/eclipse/dirigible/components/data/management/load/DataSourceMetadataLoader.java +++ b/components/data/data-management/src/main/java/org/eclipse/dirigible/components/data/management/load/DataSourceMetadataLoader.java @@ -10,7 +10,6 @@ package org.eclipse.dirigible.components.data.management.load; import com.google.common.base.CaseFormat; -import org.eclipse.dirigible.commons.config.Configuration; import org.eclipse.dirigible.components.data.sources.manager.DataSourcesManager; import org.eclipse.dirigible.components.data.structures.domain.*; import org.eclipse.dirigible.components.database.DatabaseParameters; @@ -38,10 +37,6 @@ public class DataSourceMetadataLoader implements DatabaseParameters { /** The Constant logger. */ private static final Logger logger = LoggerFactory.getLogger(DataSourceMetadataLoader.class); - /** The Constant IS_CASE_SENSETIVE. */ - private static final boolean IS_CASE_SENSETIVE = - Boolean.parseBoolean(Configuration.get(DatabaseParameters.DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE)); - /** The data source service. */ private final DataSourcesManager datasourceManager; @@ -129,16 +124,6 @@ public static void addColumns(DatabaseMetaData databaseMetadata, Connection conn databaseMetadata.getColumns(connection.getCatalog(), schemaPattern, normalizeTableName(tableMetadata.getName()), null); if (columns.next()) { iterateColumns(tableMetadata, columns); - } else if (!IS_CASE_SENSETIVE) { - // Fallback for PostgreSQL - columns = databaseMetadata.getColumns(connection.getCatalog(), schemaPattern, normalizeTableName(tableMetadata.getName() - .toLowerCase()), - null); - if (!columns.next()) { - throw new SQLException("Error in getting the information about the columns."); - } else { - iterateColumns(tableMetadata, columns); - } } } @@ -172,14 +157,6 @@ public static void addPrimaryKeys(DatabaseMetaData databaseMetadata, Connection databaseMetadata.getPrimaryKeys(connection.getCatalog(), schema, normalizeTableName(tableMetadata.getName())); if (primaryKeys.next()) { iteratePrimaryKeys(tableMetadata, primaryKeys); - } else if (!IS_CASE_SENSETIVE) { - // Fallback for PostgreSQL - primaryKeys = databaseMetadata.getPrimaryKeys(connection.getCatalog(), schema, normalizeTableName(tableMetadata.getName() - .toLowerCase())); - if (!primaryKeys.next()) { - } else { - iteratePrimaryKeys(tableMetadata, primaryKeys); - } } } @@ -227,14 +204,6 @@ public static void addForeignKeys(DatabaseMetaData databaseMetadata, Connection databaseMetadata.getImportedKeys(connection.getCatalog(), schema, normalizeTableName(tableMetadata.getName())); if (foreignKeys.next()) { iterateForeignKeys(tableMetadata, foreignKeys); - } else if (!IS_CASE_SENSETIVE) { - // Fallback for PostgreSQL - foreignKeys = databaseMetadata.getImportedKeys(connection.getCatalog(), schema, normalizeTableName(tableMetadata.getName() - .toLowerCase())); - if (!foreignKeys.next()) { - } else { - iterateForeignKeys(tableMetadata, foreignKeys); - } } } @@ -339,16 +308,6 @@ public static void addTableType(DatabaseMetaData databaseMetadata, Connection co databaseMetadata.getTables(connection.getCatalog(), schemaPattern, normalizeTableName(tableMetadata.getName()), null); if (tables.next()) { iterateTables(tableMetadata, tables); - } else if (!IS_CASE_SENSETIVE) { - // Fallback for PostgreSQL - tables = databaseMetadata.getTables(connection.getCatalog(), schemaPattern, normalizeTableName(tableMetadata.getName() - .toLowerCase()), - null); - if (!tables.next()) { - throw new SQLException("Error in getting the information about the tables."); - } else { - iterateTables(tableMetadata, tables); - } } } diff --git a/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/synchronizer/table/TableAlterProcessor.java b/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/synchronizer/table/TableAlterProcessor.java index 43d38dfc59d..b0653f7a8ae 100644 --- a/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/synchronizer/table/TableAlterProcessor.java +++ b/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/synchronizer/table/TableAlterProcessor.java @@ -9,29 +9,20 @@ */ package org.eclipse.dirigible.components.data.structures.synchronizer.table; -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.eclipse.dirigible.commons.config.Configuration; import org.eclipse.dirigible.components.data.structures.domain.Table; import org.eclipse.dirigible.components.data.structures.domain.TableColumn; import org.eclipse.dirigible.components.database.DatabaseNameNormalizer; -import org.eclipse.dirigible.components.database.DatabaseParameters; -import org.eclipse.dirigible.database.sql.DataType; -import org.eclipse.dirigible.database.sql.DataTypeUtils; -import org.eclipse.dirigible.database.sql.ISqlKeywords; -import org.eclipse.dirigible.database.sql.SqlException; -import org.eclipse.dirigible.database.sql.SqlFactory; +import org.eclipse.dirigible.database.sql.*; import org.eclipse.dirigible.database.sql.builders.table.AlterTableBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.sql.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + /** * The Table Alter Processor. */ @@ -41,7 +32,8 @@ public class TableAlterProcessor { private static final Logger logger = LoggerFactory.getLogger(TableAlterProcessor.class); /** The Constant INCOMPATIBLE_CHANGE_OF_TABLE. */ - private static final String INCOMPATIBLE_CHANGE_OF_TABLE = "Incompatible change of table [%s] by adding a column [%s] which is [%s]"; //$NON-NLS-1$ + private static final String INCOMPATIBLE_CHANGE_OF_TABLE = "Incompatible change of table [%s] by adding a column [%s] which is [%s]"; + // $NON-NLS-1$ /** * Execute the corresponding statement. @@ -51,12 +43,8 @@ public class TableAlterProcessor { * @throws SQLException the SQL exception */ public static void execute(Connection connection, Table tableModel) throws SQLException { - boolean caseSensitive = - Boolean.parseBoolean(Configuration.get(DatabaseParameters.DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE, "false")); - String tableName = tableModel.getName(); - if (caseSensitive) { - tableName = "\"" + tableName + "\""; - } + String tableName = "\"" + tableModel.getName() + "\""; + logger.info("Processing Alter Table: " + tableName); Map columnDefinitions = new HashMap<>(); @@ -80,11 +68,9 @@ public static void execute(Connection connection, Table tableModel) throws SQLEx // ADD iteration for (TableColumn columnModel : tableModel.getColumns()) { - String name = columnModel.getName(); + String name = "\"" + columnModel.getName() + "\""; String nameOriginal = name; - if (caseSensitive) { - name = "\"" + name + "\""; - } + DataType type = DataType.valueOfByName(columnModel.getType()); String length = columnModel.getLength(); boolean isNullable = columnModel.isNullable(); @@ -150,9 +136,7 @@ public static void execute(Connection connection, Table tableModel) throws SQLEx // DROP iteration for (String columnName : columnDefinitions.keySet()) { - if (caseSensitive) { - columnName = "\"" + columnName + "\""; - } + columnName = "\"" + columnName + "\""; if (!modelColumnNames.contains(columnName.toUpperCase())) { AlterTableBuilder alterTableBuilder = SqlFactory.getNative(connection) .alter() diff --git a/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/synchronizer/table/TableCreateProcessor.java b/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/synchronizer/table/TableCreateProcessor.java index 30f20d979b9..bf683e9d1f1 100644 --- a/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/synchronizer/table/TableCreateProcessor.java +++ b/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/synchronizer/table/TableCreateProcessor.java @@ -9,20 +9,7 @@ */ package org.eclipse.dirigible.components.data.structures.synchronizer.table; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.SQLException; -import java.util.List; -import java.util.Set; - -import org.eclipse.dirigible.commons.config.Configuration; -import org.eclipse.dirigible.components.data.structures.domain.Table; -import org.eclipse.dirigible.components.data.structures.domain.TableColumn; -import org.eclipse.dirigible.components.data.structures.domain.TableConstraintCheck; -import org.eclipse.dirigible.components.data.structures.domain.TableConstraintForeignKey; -import org.eclipse.dirigible.components.data.structures.domain.TableConstraintUnique; -import org.eclipse.dirigible.components.data.structures.domain.TableIndex; -import org.eclipse.dirigible.components.database.DatabaseParameters; +import org.eclipse.dirigible.components.data.structures.domain.*; import org.eclipse.dirigible.database.sql.DataType; import org.eclipse.dirigible.database.sql.ISqlKeywords; import org.eclipse.dirigible.database.sql.SqlFactory; @@ -30,6 +17,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.util.List; +import java.util.Set; + /** * The Table Create Processor. */ @@ -58,12 +51,8 @@ public static void execute(Connection connection, Table tableModel) throws SQLEx * @throws SQLException the SQL exception */ public static void execute(Connection connection, Table tableModel, boolean skipForeignKeys) throws SQLException { - boolean caseSensitive = - Boolean.parseBoolean(Configuration.get(DatabaseParameters.DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE, "false")); - String tableName = tableModel.getName(); - if (caseSensitive) { - tableName = "\"" + tableName + "\""; - } + String tableName = "\"" + tableModel.getName() + "\""; + if (logger.isInfoEnabled()) { logger.info("Processing Create Table: " + tableName); } @@ -73,10 +62,8 @@ public static void execute(Connection connection, Table tableModel, boolean skip List columns = tableModel.getColumns(); List indexes = tableModel.getIndexes(); for (TableColumn columnModel : columns) { - String name = columnModel.getName(); - if (caseSensitive) { - name = "\"" + name + "\""; - } + String name = "\"" + columnModel.getName() + "\""; + DataType type = DataType.valueOfByName(columnModel.getType()); String length = columnModel.getLength(); boolean isNullable = columnModel.isNullable(); @@ -118,11 +105,7 @@ public static void execute(Connection connection, Table tableModel, boolean skip for (String column : tableModel.getConstraints() .getPrimaryKey() .getColumns()) { - if (caseSensitive) { - primaryKeyColumns[i++] = "\"" + column + "\""; - } else { - primaryKeyColumns[i++] = column; - } + primaryKeyColumns[i++] = "\"" + column + "\""; } createTableBuilder.primaryKey(primaryKeyColumns); @@ -135,31 +118,19 @@ public static void execute(Connection connection, Table tableModel, boolean skip .isEmpty()) { for (TableConstraintForeignKey foreignKey : tableModel.getConstraints() .getForeignKeys()) { - String foreignKeyName = foreignKey.getName(); - if (caseSensitive) { - foreignKeyName = "\"" + foreignKeyName + "\""; - } + String foreignKeyName = "\"" + foreignKey.getName() + "\""; + String[] foreignKeyColumns = new String[foreignKey.getColumns().length]; int i = 0; for (String column : foreignKey.getColumns()) { - if (caseSensitive) { - foreignKeyColumns[i++] = "\"" + column + "\""; - } else { - foreignKeyColumns[i++] = column; - } - } - String foreignKeyReferencedTable = foreignKey.getReferencedTable(); - if (caseSensitive) { - foreignKeyReferencedTable = "\"" + foreignKeyReferencedTable + "\""; + foreignKeyColumns[i++] = "\"" + column + "\""; } + String foreignKeyReferencedTable = "\"" + foreignKey.getReferencedTable() + "\""; + String[] foreignKeyReferencedColumns = new String[foreignKey.getReferencedColumns().length]; i = 0; for (String column : foreignKey.getReferencedColumns()) { - if (caseSensitive) { - foreignKeyReferencedColumns[i++] = "\"" + column + "\""; - } else { - foreignKeyReferencedColumns[i++] = column; - } + foreignKeyReferencedColumns[i++] = "\"" + column + "\""; } createTableBuilder.foreignKey(foreignKeyName, foreignKeyColumns, foreignKeyReferencedTable, @@ -171,18 +142,12 @@ public static void execute(Connection connection, Table tableModel, boolean skip .getUniqueIndexes() != null) { for (TableConstraintUnique uniqueIndex : tableModel.getConstraints() .getUniqueIndexes()) { - String uniqueIndexName = uniqueIndex.getName(); - if (caseSensitive) { - uniqueIndexName = "\"" + uniqueIndexName + "\""; - } + String uniqueIndexName = "\"" + uniqueIndex.getName() + "\""; + String[] uniqueIndexColumns = new String[uniqueIndex.getColumns().length]; int i = 0; for (String column : uniqueIndex.getColumns()) { - if (caseSensitive) { - uniqueIndexColumns[i++] = "\"" + column + "\""; - } else { - uniqueIndexColumns[i++] = column; - } + uniqueIndexColumns[i++] = "\"" + column + "\""; } createTableBuilder.unique(uniqueIndexName, uniqueIndexColumns); } @@ -191,10 +156,8 @@ public static void execute(Connection connection, Table tableModel, boolean skip .getChecks() != null) { for (TableConstraintCheck check : tableModel.getConstraints() .getChecks()) { - String checkName = check.getName(); - if (caseSensitive) { - checkName = "\"" + checkName + "\""; - } + String checkName = "\"" + check.getName() + "\""; + createTableBuilder.check(checkName, check.getExpression()); } } diff --git a/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/synchronizer/table/TableDropProcessor.java b/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/synchronizer/table/TableDropProcessor.java index 35ec1e9958a..27308053cfe 100644 --- a/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/synchronizer/table/TableDropProcessor.java +++ b/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/synchronizer/table/TableDropProcessor.java @@ -9,20 +9,18 @@ */ package org.eclipse.dirigible.components.data.structures.synchronizer.table; -import static java.text.MessageFormat.format; +import org.eclipse.dirigible.components.data.structures.domain.Table; +import org.eclipse.dirigible.components.data.structures.domain.TableConstraintForeignKey; +import org.eclipse.dirigible.database.sql.SqlFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -import org.eclipse.dirigible.commons.config.Configuration; -import org.eclipse.dirigible.components.data.structures.domain.Table; -import org.eclipse.dirigible.components.data.structures.domain.TableConstraintForeignKey; -import org.eclipse.dirigible.components.database.DatabaseParameters; -import org.eclipse.dirigible.database.sql.SqlFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import static java.text.MessageFormat.format; /** * The Table Drop Processor. @@ -40,12 +38,8 @@ public class TableDropProcessor { * @throws SQLException the SQL exception */ public static void execute(Connection connection, Table tableModel) throws SQLException { - boolean caseSensitive = - Boolean.parseBoolean(Configuration.get(DatabaseParameters.DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE, "false")); - String tableName = tableModel.getName(); - if (caseSensitive) { - tableName = "\"" + tableName + "\""; - } + String tableName = "\"" + tableModel.getName() + "\""; + if (logger.isInfoEnabled()) { logger.info("Processing Drop Table: " + tableName); } diff --git a/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/synchronizer/table/TableForeignKeysCreateProcessor.java b/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/synchronizer/table/TableForeignKeysCreateProcessor.java index 5a052d025d9..efeb3d6d965 100644 --- a/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/synchronizer/table/TableForeignKeysCreateProcessor.java +++ b/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/synchronizer/table/TableForeignKeysCreateProcessor.java @@ -9,6 +9,13 @@ */ package org.eclipse.dirigible.components.data.structures.synchronizer.table; +import org.eclipse.dirigible.components.data.structures.domain.Table; +import org.eclipse.dirigible.components.data.structures.domain.TableConstraintForeignKey; +import org.eclipse.dirigible.database.sql.SqlFactory; +import org.eclipse.dirigible.database.sql.builders.table.AlterTableBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; @@ -17,15 +24,6 @@ import java.util.List; import java.util.Objects; -import org.eclipse.dirigible.commons.config.Configuration; -import org.eclipse.dirigible.components.data.structures.domain.Table; -import org.eclipse.dirigible.components.data.structures.domain.TableConstraintForeignKey; -import org.eclipse.dirigible.components.database.DatabaseParameters; -import org.eclipse.dirigible.database.sql.SqlFactory; -import org.eclipse.dirigible.database.sql.builders.table.AlterTableBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * The Class TableForeignKeysCreateProcessor. */ @@ -42,12 +40,7 @@ public class TableForeignKeysCreateProcessor { * @throws SQLException the SQL exception */ public static void execute(Connection connection, Table tableModel) throws SQLException { - boolean caseSensitive = - Boolean.parseBoolean(Configuration.get(DatabaseParameters.DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE, "false")); - String tableName = tableModel.getName(); - if (caseSensitive) { - tableName = "\"" + tableName + "\""; - } + String tableName = "\"" + tableModel.getName() + "\""; if (tableModel.getConstraints() != null) { if (tableModel.getConstraints() @@ -67,12 +60,8 @@ public static void execute(Connection connection, Table tableModel) throws SQLEx List valsToHashFKName = new ArrayList<>(Arrays.asList(foreignKey.getColumns())); valsToHashFKName.add(foreignKey.getReferencedTable()); String hashedFKName = "fk" + generateHashedName(valsToHashFKName); - String foreignKeyName = Objects.isNull(foreignKey.getName()) ? hashedFKName : foreignKey.getName(); - String referencedTable = foreignKey.getReferencedTable(); - if (caseSensitive) { - foreignKeyName = "\"" + foreignKeyName + "\""; - referencedTable = "\"" + referencedTable + "\""; - } + String foreignKeyName = "\"" + (Objects.isNull(foreignKey.getName()) ? hashedFKName : foreignKey.getName()) + "\""; + String referencedTable = "\"" + foreignKey.getReferencedTable() + "\""; alterTableBuilder.add() .foreignKey(foreignKeyName, foreignKey.getColumns(), referencedTable, foreignKey.getReferencedColumns()); @@ -81,8 +70,7 @@ public static void execute(Connection connection, Table tableModel) throws SQLEx if (logger.isInfoEnabled()) { logger.info(sql); } - PreparedStatement statement = connection.prepareStatement(sql); - try { + try (PreparedStatement statement = connection.prepareStatement(sql)) { statement.executeUpdate(); } catch (SQLException e) { if (logger.isErrorEnabled()) { @@ -90,10 +78,6 @@ public static void execute(Connection connection, Table tableModel) throws SQLEx } // if (logger.isErrorEnabled()) {logger.error(e.getMessage(), e);} throw new SQLException(e.getMessage(), e); - } finally { - if (statement != null) { - statement.close(); - } } } } @@ -106,7 +90,7 @@ public static void execute(Connection connection, Table tableModel) throws SQLEx * @return the string */ public static String generateHashedName(List values) { - StringBuilder hashedName = new StringBuilder(""); + StringBuilder hashedName = new StringBuilder(); for (String val : values) { hashedName.append(val); } diff --git a/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/synchronizer/table/TableForeignKeysDropProcessor.java b/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/synchronizer/table/TableForeignKeysDropProcessor.java index 007bcd1ec3f..30084778f8d 100644 --- a/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/synchronizer/table/TableForeignKeysDropProcessor.java +++ b/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/synchronizer/table/TableForeignKeysDropProcessor.java @@ -9,19 +9,17 @@ */ package org.eclipse.dirigible.components.data.structures.synchronizer.table; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.SQLException; - -import org.eclipse.dirigible.commons.config.Configuration; import org.eclipse.dirigible.components.data.structures.domain.Table; import org.eclipse.dirigible.components.data.structures.domain.TableConstraintForeignKey; -import org.eclipse.dirigible.components.database.DatabaseParameters; import org.eclipse.dirigible.database.sql.SqlFactory; import org.eclipse.dirigible.database.sql.builders.table.AlterTableBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; + /** * The Class TableForeignKeysDropProcessor. */ @@ -38,12 +36,7 @@ public class TableForeignKeysDropProcessor { * @throws SQLException the SQL exception */ public static void execute(Connection connection, Table tableModel) throws SQLException { - boolean caseSensitive = - Boolean.parseBoolean(Configuration.get(DatabaseParameters.DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE, "false")); - String tableName = tableModel.getName(); - if (caseSensitive) { - tableName = "\"" + tableName + "\""; - } + String tableName = "\"" + tableModel.getName() + "\""; if (tableModel.getConstraints() != null) { if (tableModel.getConstraints() @@ -59,10 +52,8 @@ public static void execute(Connection connection, Table tableModel) throws SQLEx .table(tableName); for (TableConstraintForeignKey foreignKey : tableModel.getConstraints() .getForeignKeys()) { - String foreignKeyName = foreignKey.getName(); - if (caseSensitive) { - foreignKeyName = "\"" + foreignKeyName + "\""; - } + String foreignKeyName = "\"" + foreignKey.getName() + "\""; + alterTableBuilder.drop() .foreignKey(foreignKeyName, foreignKey.getColumns(), foreignKey.getReferencedTable(), foreignKey.getReferencedColumns()); diff --git a/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/synchronizer/view/ViewCreateProcessor.java b/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/synchronizer/view/ViewCreateProcessor.java index 37f1ad0a5d5..a79aff2a4ee 100644 --- a/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/synchronizer/view/ViewCreateProcessor.java +++ b/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/synchronizer/view/ViewCreateProcessor.java @@ -9,9 +9,7 @@ */ package org.eclipse.dirigible.components.data.structures.synchronizer.view; -import org.eclipse.dirigible.commons.config.Configuration; import org.eclipse.dirigible.components.data.structures.domain.View; -import org.eclipse.dirigible.components.database.DatabaseParameters; import org.eclipse.dirigible.database.sql.SqlFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,12 +34,8 @@ public class ViewCreateProcessor { * @throws SQLException the SQL exception */ public static void execute(Connection connection, View viewModel) throws SQLException { - boolean caseSensitive = - Boolean.parseBoolean(Configuration.get(DatabaseParameters.DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE, "false")); - String viewName = viewModel.getName(); - if (caseSensitive) { - viewName = "\"" + viewName + "\""; - } + String viewName = "\"" + viewModel.getName() + "\""; + logger.info("Processing Create View: " + viewName); if (!SqlFactory.getNative(connection) diff --git a/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/synchronizer/view/ViewDropProcessor.java b/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/synchronizer/view/ViewDropProcessor.java index 0a95b4e2649..2cc2a8ff74c 100644 --- a/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/synchronizer/view/ViewDropProcessor.java +++ b/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/synchronizer/view/ViewDropProcessor.java @@ -9,17 +9,15 @@ */ package org.eclipse.dirigible.components.data.structures.synchronizer.view; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.SQLException; - -import org.eclipse.dirigible.commons.config.Configuration; import org.eclipse.dirigible.components.data.structures.domain.View; -import org.eclipse.dirigible.components.database.DatabaseParameters; import org.eclipse.dirigible.database.sql.SqlFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; + /** * The View Drop Processor. */ @@ -36,12 +34,8 @@ public class ViewDropProcessor { * @throws SQLException the SQL exception */ public static void execute(Connection connection, View viewModel) throws SQLException { - boolean caseSensitive = - Boolean.parseBoolean(Configuration.get(DatabaseParameters.DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE, "false")); - String viewName = viewModel.getName(); - if (caseSensitive) { - viewName = "\"" + viewName + "\""; - } + String viewName = "\"" + viewModel.getName() + "\""; + if (logger.isInfoEnabled()) { logger.info("Processing Drop View: " + viewName); } diff --git a/components/engine/engine-odata/src/main/java/org/eclipse/dirigible/components/odata/transformers/ODataDatabaseMetadataUtil.java b/components/engine/engine-odata/src/main/java/org/eclipse/dirigible/components/odata/transformers/ODataDatabaseMetadataUtil.java index 618bdffe28b..bd88068b946 100644 --- a/components/engine/engine-odata/src/main/java/org/eclipse/dirigible/components/odata/transformers/ODataDatabaseMetadataUtil.java +++ b/components/engine/engine-odata/src/main/java/org/eclipse/dirigible/components/odata/transformers/ODataDatabaseMetadataUtil.java @@ -9,18 +9,7 @@ */ package org.eclipse.dirigible.components.odata.transformers; -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import javax.sql.DataSource; -import org.eclipse.dirigible.commons.config.Configuration; +import com.google.common.base.CaseFormat; import org.eclipse.dirigible.components.base.spring.BeanProvider; import org.eclipse.dirigible.components.data.sources.manager.DataSourcesManager; import org.eclipse.dirigible.components.data.structures.domain.Table; @@ -28,7 +17,13 @@ import org.eclipse.dirigible.components.data.structures.domain.TableConstraintForeignKey; import org.eclipse.dirigible.components.odata.api.ODataProperty; import org.eclipse.dirigible.database.sql.ISqlKeywords; -import com.google.common.base.CaseFormat; + +import javax.sql.DataSource; +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.*; /** * The Class DBMetadataUtil. @@ -38,9 +33,6 @@ public class ODataDatabaseMetadataUtil { /** The Constant DIRIGIBLE_GENERATE_PRETTY_NAMES. */ public static final String DIRIGIBLE_GENERATE_PRETTY_NAMES = "DIRIGIBLE_GENERATE_PRETTY_NAMES"; - /** The Constant IS_CASE_SENSETIVE. */ - private static final boolean IS_CASE_SENSETIVE = Boolean.parseBoolean(Configuration.get("DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE")); - /** The Constant JDBC_COLUMN_NAME_PROPERTY. */ public static final String JDBC_COLUMN_NAME_PROPERTY = "COLUMN_NAME"; @@ -192,11 +184,6 @@ private void getForeignKeys(DatabaseMetaData databaseMetadata, Connection connec throws SQLException { ResultSet foreignKeys = databaseMetadata.getImportedKeys(connection.getCatalog(), schemaName, normalizeTableName(tableMetadata.getName())); - if (!foreignKeys.isBeforeFirst() && !IS_CASE_SENSETIVE) { - // Fallback for PostgreSQL - foreignKeys = databaseMetadata.getImportedKeys(connection.getCatalog(), schemaName, normalizeTableName(tableMetadata.getName() - .toLowerCase())); - } while (foreignKeys.next()) { new TableConstraintForeignKey(foreignKeys.getString(JDBC_FK_NAME_PROPERTY), new String[] {}, @@ -239,11 +226,6 @@ private List getPrimaryKeys(DatabaseMetaData databaseMetadata, Connectio throws SQLException { ResultSet primaryKeys = databaseMetadata.getPrimaryKeys(connection.getCatalog(), schemaName, normalizeTableName(tableMetadata.getName())); - if (!primaryKeys.isBeforeFirst() && !IS_CASE_SENSETIVE) { - // Fallback for PostgreSQL - primaryKeys = databaseMetadata.getPrimaryKeys(connection.getCatalog(), schemaName, normalizeTableName(tableMetadata.getName() - .toLowerCase())); - } List primaryKeyColumns = new ArrayList<>(); while (primaryKeys.next()) { @@ -267,12 +249,6 @@ private void getColumns(DatabaseMetaData databaseMetadata, Connection connection throws SQLException { ResultSet columns = databaseMetadata.getColumns(connection.getCatalog(), schemaPattern, normalizeTableName(tableMetadata.getName()), null); - if (!columns.isBeforeFirst() && !IS_CASE_SENSETIVE) { - // Fallback for PostgreSQL - columns = databaseMetadata.getColumns(connection.getCatalog(), schemaPattern, normalizeTableName(tableMetadata.getName() - .toLowerCase()), - null); - } List primaryKeys = getPrimaryKeys(databaseMetadata, connection, tableMetadata, schemaPattern); @@ -351,7 +327,7 @@ public static String getType(TableColumn column, List properties) String columnName = column.getName(); for (ODataProperty next : properties) { if (next.getType() != null) { - if (columnName.equals(next.getColumn()) || !IS_CASE_SENSETIVE && columnName.equalsIgnoreCase(next.getColumn())) { + if (columnName.equals(next.getColumn())) { return next.getType(); } } @@ -395,11 +371,6 @@ public static String normalizeTableName(String table) { public String getArtifactType(DatabaseMetaData databaseMetadata, Connection connection, String artifactName, String schemaPattern) throws SQLException { ResultSet tables = databaseMetadata.getTables(connection.getCatalog(), schemaPattern, normalizeTableName(artifactName), null); - if (!tables.isBeforeFirst() && !IS_CASE_SENSETIVE) { - // Fallback for PostgreSQL - tables = databaseMetadata.getTables(connection.getCatalog(), schemaPattern, normalizeTableName(artifactName.toLowerCase()), - null); - } return tables.next() ? tables.getString("TABLE_TYPE") : null; } diff --git a/components/group/group-database/pom.xml b/components/group/group-database/pom.xml index 3abba754449..f879f292bab 100644 --- a/components/group/group-database/pom.xml +++ b/components/group/group-database/pom.xml @@ -74,10 +74,6 @@ org.eclipse.dirigible dirigible-database-sql-hana - - org.eclipse.dirigible - dirigible-database-sql-sybase - org.eclipse.dirigible dirigible-database-sql-snowflake @@ -90,4 +86,4 @@ ../../../ - \ No newline at end of file + diff --git a/modules/commons/commons-config/src/main/java/org/eclipse/dirigible/commons/config/Configuration.java b/modules/commons/commons-config/src/main/java/org/eclipse/dirigible/commons/config/Configuration.java index d8af5111a57..02793866fb3 100644 --- a/modules/commons/commons-config/src/main/java/org/eclipse/dirigible/commons/config/Configuration.java +++ b/modules/commons/commons-config/src/main/java/org/eclipse/dirigible/commons/config/Configuration.java @@ -88,13 +88,13 @@ private static String[] getConfigParams() { "DIRIGIBLE_REPOSITORY_SEARCH_INDEX_LOCATION", "DIRIGIBLE_REPOSITORY_VERSIONING_ENABLED", "DIRIGIBLE_DATABASE_PROVIDER", "DIRIGIBLE_DATABASE_DEFAULT_SET_AUTO_COMMIT", "DIRIGIBLE_DATABASE_DEFAULT_MAX_CONNECTIONS_COUNT", "DIRIGIBLE_DATABASE_DEFAULT_WAIT_TIMEOUT", "DIRIGIBLE_DATABASE_DEFAULT_WAIT_COUNT", "DIRIGIBLE_DATABASE_CUSTOM_DATASOURCES", - "DIRIGIBLE_DATABASE_DATASOURCE_NAME_DEFAULT", "DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE", - "DIRIGIBLE_DATABASE_DERBY_ROOT_FOLDER_DEFAULT", "DIRIGIBLE_DATABASE_H2_ROOT_FOLDER_DEFAULT", "DIRIGIBLE_DATABASE_H2_DRIVER", - "DIRIGIBLE_DATABASE_H2_URL", "DIRIGIBLE_DATABASE_H2_USERNAME", "DIRIGIBLE_DATABASE_H2_PASSWORD", - "DIRIGIBLE_DATABASE_TRANSFER_BATCH_SIZE", "DIRIGIBLE_PERSISTENCE_CREATE_TABLE_ON_USE", "DIRIGIBLE_MONGODB_CLIENT_URI", - "DIRIGIBLE_MONGODB_DATABASE_DEFAULT", "DIRIGIBLE_SCHEDULER_MEMORY_STORE", "DIRIGIBLE_SCHEDULER_DATASOURCE_TYPE", - "DIRIGIBLE_SCHEDULER_DATASOURCE_NAME", "DIRIGIBLE_SCHEDULER_DATABASE_DELEGATE", "DIRIGIBLE_SCHEDULER_LOGS_RETANTION_PERIOD", - "DIRIGIBLE_SCHEDULER_EMAIL_SENDER", "DIRIGIBLE_SCHEDULER_EMAIL_RECIPIENTS", "DIRIGIBLE_SCHEDULER_EMAIL_SUBJECT_ERROR", + "DIRIGIBLE_DATABASE_DATASOURCE_NAME_DEFAULT", "DIRIGIBLE_DATABASE_DERBY_ROOT_FOLDER_DEFAULT", + "DIRIGIBLE_DATABASE_H2_ROOT_FOLDER_DEFAULT", "DIRIGIBLE_DATABASE_H2_DRIVER", "DIRIGIBLE_DATABASE_H2_URL", + "DIRIGIBLE_DATABASE_H2_USERNAME", "DIRIGIBLE_DATABASE_H2_PASSWORD", "DIRIGIBLE_DATABASE_TRANSFER_BATCH_SIZE", + "DIRIGIBLE_PERSISTENCE_CREATE_TABLE_ON_USE", "DIRIGIBLE_MONGODB_CLIENT_URI", "DIRIGIBLE_MONGODB_DATABASE_DEFAULT", + "DIRIGIBLE_SCHEDULER_MEMORY_STORE", "DIRIGIBLE_SCHEDULER_DATASOURCE_TYPE", "DIRIGIBLE_SCHEDULER_DATASOURCE_NAME", + "DIRIGIBLE_SCHEDULER_DATABASE_DELEGATE", "DIRIGIBLE_SCHEDULER_LOGS_RETANTION_PERIOD", "DIRIGIBLE_SCHEDULER_EMAIL_SENDER", + "DIRIGIBLE_SCHEDULER_EMAIL_RECIPIENTS", "DIRIGIBLE_SCHEDULER_EMAIL_SUBJECT_ERROR", "DIRIGIBLE_SCHEDULER_EMAIL_SUBJECT_NORMAL", "DIRIGIBLE_SCHEDULER_EMAIL_TEMPLATE_ERROR", "DIRIGIBLE_SCHEDULER_EMAIL_TEMPLATE_NORMAL", "DIRIGIBLE_SCHEDULER_EMAIL_URL_SCHEME", "DIRIGIBLE_SCHEDULER_EMAIL_URL_HOST", "DIRIGIBLE_SCHEDULER_EMAIL_URL_PORT", "DIRIGIBLE_SYNCHRONIZER_IGNORE_DEPENDENCIES", "DIRIGIBLE_SYNCHRONIZER_EXCLUDE_PATHS", diff --git a/modules/commons/commons-config/src/main/java/org/eclipse/dirigible/commons/config/DirigibleConfig.java b/modules/commons/commons-config/src/main/java/org/eclipse/dirigible/commons/config/DirigibleConfig.java index 6f75942d631..14ad922d883 100644 --- a/modules/commons/commons-config/src/main/java/org/eclipse/dirigible/commons/config/DirigibleConfig.java +++ b/modules/commons/commons-config/src/main/java/org/eclipse/dirigible/commons/config/DirigibleConfig.java @@ -49,8 +49,6 @@ public enum DirigibleConfig { /** The multi tenant mode enabled. */ MULTI_TENANT_MODE_ENABLED("DIRIGIBLE_MULTI_TENANT_MODE", Boolean.FALSE.toString()), - DATABASE_NAMES_CASE_SENSITIVE("DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE", Boolean.FALSE.toString()), - /** The tenant subdomain regex. */ TENANT_SUBDOMAIN_REGEX("DIRIGIBLE_TENANT_SUBDOMAIN_REGEX", "^([^\\.]+)\\..+$"), diff --git a/modules/commons/commons-helpers/src/main/java/org/eclipse/dirigible/commons/api/helpers/DataStructuresUtils.java b/modules/commons/commons-helpers/src/main/java/org/eclipse/dirigible/commons/api/helpers/DataStructuresUtils.java deleted file mode 100644 index 94a3c8e1ff0..00000000000 --- a/modules/commons/commons-helpers/src/main/java/org/eclipse/dirigible/commons/api/helpers/DataStructuresUtils.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2024 Eclipse Dirigible contributors - * - * All rights reserved. This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v2.0 which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v20.html - * - * SPDX-FileCopyrightText: Eclipse Dirigible contributors SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.dirigible.commons.api.helpers; - -import org.eclipse.dirigible.commons.config.Configuration; - -/** - * The Class DataStructuresUtils. - */ -public class DataStructuresUtils { - - /** The Constant DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE. */ - private static final String DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE = "DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE"; - - /** The Constant IS_CASE_SENSETIVE. */ - private static final boolean IS_CASE_SENSETIVE = Boolean.parseBoolean(Configuration.get(DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE)); - - /** - * Gets the case sensitive table name. - * - * @param tableName the table name - * @return the case sensitive table name - */ - public static String getCaseSensitiveTableName(String tableName) { - if (IS_CASE_SENSETIVE && tableName != null && !tableName.startsWith("\"") && !tableName.endsWith("\"")) { - return "\"" + tableName + "\""; - } - return tableName; - } -} diff --git a/modules/database/database-persistence/src/main/java/org/eclipse/dirigible/database/persistence/utils/DatabaseMetadataUtil.java b/modules/database/database-persistence/src/main/java/org/eclipse/dirigible/database/persistence/utils/DatabaseMetadataUtil.java index 7d2449eaa5d..8b4c9ec46d6 100644 --- a/modules/database/database-persistence/src/main/java/org/eclipse/dirigible/database/persistence/utils/DatabaseMetadataUtil.java +++ b/modules/database/database-persistence/src/main/java/org/eclipse/dirigible/database/persistence/utils/DatabaseMetadataUtil.java @@ -9,36 +9,26 @@ */ package org.eclipse.dirigible.database.persistence.utils; -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - -import javax.sql.DataSource; - -import org.eclipse.dirigible.commons.config.Configuration; +import com.google.common.base.CaseFormat; import org.eclipse.dirigible.database.persistence.model.PersistenceTableColumnModel; import org.eclipse.dirigible.database.persistence.model.PersistenceTableIndexModel; import org.eclipse.dirigible.database.persistence.model.PersistenceTableModel; import org.eclipse.dirigible.database.persistence.model.PersistenceTableRelationModel; import org.eclipse.dirigible.database.sql.ISqlKeywords; -import com.google.common.base.CaseFormat; - +import javax.sql.DataSource; +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; /** * The Class DatabaseMetadataUtil. */ public class DatabaseMetadataUtil { - /** The Constant DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE. */ - public static final String DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE = "DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE"; - - /** The Constant IS_CASE_SENSETIVE. */ - private static final boolean IS_CASE_SENSETIVE = Boolean.parseBoolean(Configuration.get(DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE)); - /** The Constant JDBC_COLUMN_NAME_PROPERTY. */ public static final String JDBC_COLUMN_NAME_PROPERTY = "COLUMN_NAME"; @@ -142,15 +132,6 @@ public static void addForeignKeys(DatabaseMetaData databaseMetadata, Connection databaseMetadata.getImportedKeys(connection.getCatalog(), schema, normalizeTableName(tableMetadata.getTableName())); if (foreignKeys.next()) { iterateForeignKeys(tableMetadata, foreignKeys); - } else if (!IS_CASE_SENSETIVE) { - // Fallback for PostgreSQL - foreignKeys = databaseMetadata.getImportedKeys(connection.getCatalog(), schema, normalizeTableName(tableMetadata.getTableName() - .toLowerCase())); - if (!foreignKeys.next()) { - return; - } else { - iterateForeignKeys(tableMetadata, foreignKeys); - } } } @@ -187,15 +168,6 @@ public static void addPrimaryKeys(DatabaseMetaData databaseMetadata, Connection databaseMetadata.getPrimaryKeys(connection.getCatalog(), schema, normalizeTableName(tableMetadata.getTableName())); if (primaryKeys.next()) { iteratePrimaryKeys(tableMetadata, primaryKeys); - } else if (!IS_CASE_SENSETIVE) { - // Fallback for PostgreSQL - primaryKeys = databaseMetadata.getPrimaryKeys(connection.getCatalog(), schema, normalizeTableName(tableMetadata.getTableName() - .toLowerCase())); - if (!primaryKeys.next()) { - return; - } else { - iteratePrimaryKeys(tableMetadata, primaryKeys); - } } } @@ -286,16 +258,6 @@ public static void addFields(DatabaseMetaData databaseMetadata, Connection conne databaseMetadata.getColumns(connection.getCatalog(), schemaPattern, normalizeTableName(tableMetadata.getTableName()), null); if (columns.next()) { iterateFields(tableMetadata, columns); - } else if (!IS_CASE_SENSETIVE) { - // Fallback for PostgreSQL - columns = databaseMetadata.getColumns(connection.getCatalog(), schemaPattern, normalizeTableName(tableMetadata.getTableName() - .toLowerCase()), - null); - if (!columns.next()) { - throw new SQLException("Error in getting the information about the columns."); - } else { - iterateFields(tableMetadata, columns); - } } } @@ -354,16 +316,6 @@ public static void addTableType(DatabaseMetaData databaseMetadata, Connection co databaseMetadata.getTables(connection.getCatalog(), schemaPattern, normalizeTableName(tableMetadata.getTableName()), null); if (tables.next()) { iterateTables(tableMetadata, tables); - } else if (!IS_CASE_SENSETIVE) { - // Fallback for PostgreSQL - tables = databaseMetadata.getTables(connection.getCatalog(), schemaPattern, normalizeTableName(tableMetadata.getTableName() - .toLowerCase()), - null); - if (!tables.next()) { - throw new SQLException("Error in getting the information about the tables."); - } else { - iterateTables(tableMetadata, tables); - } } } diff --git a/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/CreateTableTest.java b/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/CreateTableTest.java index 73f8d61246e..390e029af73 100644 --- a/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/CreateTableTest.java +++ b/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/CreateTableTest.java @@ -9,13 +9,13 @@ */ package org.eclipse.dirigible.database.sql.dialects.h2; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.DataType; import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class CreateTableTest. */ @@ -36,7 +36,7 @@ public void createTableGeneric() { assertNotNull(sql); assertEquals( - "CREATE TABLE CUSTOMERS ( ID INTEGER NOT NULL PRIMARY KEY , FIRST_NAME VARCHAR (20) NOT NULL UNIQUE , LAST_NAME VARCHAR (30) )", + "CREATE TABLE \"CUSTOMERS\" ( \"ID\" INTEGER NOT NULL PRIMARY KEY , \"FIRST_NAME\" VARCHAR (20) NOT NULL UNIQUE , \"LAST_NAME\" VARCHAR (30) )", sql); } @@ -54,7 +54,8 @@ public void createTableTypeSafe() { .build(); assertNotNull(sql); - assertEquals("CREATE TABLE CUSTOMERS ( ID INTEGER NOT NULL PRIMARY KEY , FIRST_NAME VARCHAR (20) UNIQUE , LAST_NAME VARCHAR (30) )", + assertEquals( + "CREATE TABLE \"CUSTOMERS\" ( \"ID\" INTEGER NOT NULL PRIMARY KEY , \"FIRST_NAME\" VARCHAR (20) UNIQUE , \"LAST_NAME\" VARCHAR (30) )", sql); } diff --git a/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/CreateViewTest.java b/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/CreateViewTest.java index 73ac723dbce..6e9acfb4831 100644 --- a/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/CreateViewTest.java +++ b/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/CreateViewTest.java @@ -9,12 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.h2; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class CreateViewTest. */ @@ -40,7 +40,7 @@ public void createViewAsSelect() { .build(); assertNotNull(sql); - assertEquals("CREATE VIEW CUSTOMERS_VIEW ( ID , FIRST_NAME , LAST_NAME ) AS SELECT * FROM CUSTOMERS", sql); + assertEquals("CREATE VIEW \"CUSTOMERS_VIEW\" ( \"ID\" , \"FIRST_NAME\" , \"LAST_NAME\" ) AS SELECT * FROM \"CUSTOMERS\"", sql); } } diff --git a/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/DeleteTest.java b/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/DeleteTest.java index e37197e0a7e..2622185f847 100644 --- a/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/DeleteTest.java +++ b/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/DeleteTest.java @@ -9,12 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.h2; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class DeleteTest. */ @@ -31,7 +31,7 @@ public void deleteSimple() { .build(); assertNotNull(sql); - assertEquals("DELETE FROM CUSTOMERS", sql); + assertEquals("DELETE FROM \"CUSTOMERS\"", sql); } /** @@ -47,7 +47,7 @@ public void deleteWhere() { .build(); assertNotNull(sql); - assertEquals("DELETE FROM CUSTOMERS WHERE (AGE > ?) AND (COMPANY = 'SAP')", sql); + assertEquals("DELETE FROM \"CUSTOMERS\" WHERE (\"AGE\" > ?) AND (\"COMPANY\" = 'SAP')", sql); } } diff --git a/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/DropTableTest.java b/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/DropTableTest.java index 55800776b18..6c168b0bc43 100644 --- a/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/DropTableTest.java +++ b/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/DropTableTest.java @@ -9,12 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.h2; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class DropTableTest. */ @@ -31,8 +31,7 @@ public void dropTable() { .build(); assertNotNull(sql); - assertEquals("DROP TABLE CUSTOMERS", sql); + assertEquals("DROP TABLE \"CUSTOMERS\"", sql); } - } diff --git a/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/DropViewTest.java b/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/DropViewTest.java index ac9098ffbf5..c7738a30c90 100644 --- a/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/DropViewTest.java +++ b/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/DropViewTest.java @@ -9,12 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.h2; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class DropViewTest. */ @@ -31,7 +31,7 @@ public void dropView() { .build(); assertNotNull(sql); - assertEquals("DROP VIEW CUSTOMERS_VIEW", sql); + assertEquals("DROP VIEW \"CUSTOMERS_VIEW\"", sql); } } diff --git a/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/InsertTest.java b/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/InsertTest.java index 2b071eb629d..f9986163a11 100644 --- a/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/InsertTest.java +++ b/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/InsertTest.java @@ -9,12 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.h2; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class InsertTest. */ @@ -33,7 +33,7 @@ public void insertSimple() { .build(); assertNotNull(sql); - assertEquals("INSERT INTO CUSTOMERS (FIRST_NAME, LAST_NAME) VALUES (?, ?)", sql); + assertEquals("INSERT INTO \"CUSTOMERS\" (\"FIRST_NAME\", \"LAST_NAME\") VALUES (?, ?)", sql); } /** @@ -51,7 +51,7 @@ public void insertValues() { .build(); assertNotNull(sql); - assertEquals("INSERT INTO CUSTOMERS (FIRST_NAME, LAST_NAME) VALUES (?, 'Smith')", sql); + assertEquals("INSERT INTO \"CUSTOMERS\" (\"FIRST_NAME\", \"LAST_NAME\") VALUES (?, 'Smith')", sql); } /** @@ -72,7 +72,7 @@ public void insertSelect() { .toString(); assertNotNull(sql); - assertEquals("INSERT INTO CUSTOMERS (FIRST_NAME, LAST_NAME) SELECT * FROM SUPPLIERS", sql); + assertEquals("INSERT INTO \"CUSTOMERS\" (\"FIRST_NAME\", \"LAST_NAME\") SELECT * FROM \"SUPPLIERS\"", sql); } } diff --git a/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/SelectTest.java b/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/SelectTest.java index ed8397d045d..7f35fbd08df 100644 --- a/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/SelectTest.java +++ b/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/SelectTest.java @@ -9,12 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.h2; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class SelectTest. */ @@ -32,7 +32,7 @@ public void selectStar() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS", sql); + assertEquals("SELECT * FROM \"CUSTOMERS\"", sql); } /** @@ -48,7 +48,7 @@ public void selectColumnsFromTable() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS", sql); + assertEquals("SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\"", sql); } /** @@ -64,7 +64,7 @@ public void selectColumnsFromTableAliases() { .build(); assertNotNull(sql); - assertEquals("SELECT c.FIRST_NAME, c.LAST_NAME FROM CUSTOMERS AS c", sql); + assertEquals("SELECT \"c\".\"FIRST_NAME\", \"c\".\"LAST_NAME\" FROM \"CUSTOMERS\" AS \"c\"", sql); } /** @@ -81,7 +81,9 @@ public void selectColumnsFromTableJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS INNER JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\" INNER JOIN \"ADDRESSES\" ON \"CUSTOMERS\".\"ADDRESS_ID\"=\"ADDRESSES\".\"ADDRESS_ID\"", + sql); } /** @@ -98,7 +100,9 @@ public void selectColumnsFromTableInnerJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS INNER JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\" INNER JOIN \"ADDRESSES\" ON \"CUSTOMERS\".\"ADDRESS_ID\"=\"ADDRESSES\".\"ADDRESS_ID\"", + sql); } /** @@ -115,7 +119,9 @@ public void selectColumnsFromTableOuterJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS OUTER JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\" OUTER JOIN \"ADDRESSES\" ON \"CUSTOMERS\".\"ADDRESS_ID\"=\"ADDRESSES\".\"ADDRESS_ID\"", + sql); } /** @@ -132,7 +138,9 @@ public void selectColumnsFromTableLeftJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS LEFT JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\" LEFT JOIN \"ADDRESSES\" ON \"CUSTOMERS\".\"ADDRESS_ID\"=\"ADDRESSES\".\"ADDRESS_ID\"", + sql); } /** @@ -149,7 +157,9 @@ public void selectColumnsFromTableRightJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS RIGHT JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\" RIGHT JOIN \"ADDRESSES\" ON \"CUSTOMERS\".\"ADDRESS_ID\"=\"ADDRESSES\".\"ADDRESS_ID\"", + sql); } /** @@ -166,7 +176,9 @@ public void selectColumnsFromTableFullJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS FULL JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\" FULL JOIN \"ADDRESSES\" ON \"CUSTOMERS\".\"ADDRESS_ID\"=\"ADDRESSES\".\"ADDRESS_ID\"", + sql); } /** @@ -183,7 +195,7 @@ public void selectDistinctColumnsFromTable() { .build(); assertNotNull(sql); - assertEquals("SELECT DISTINCT FIRST_NAME, LAST_NAME FROM CUSTOMERS", sql); + assertEquals("SELECT DISTINCT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\"", sql); } /** @@ -201,7 +213,7 @@ public void selectColumnsFromTableOrderByAndDesc() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS ORDER BY FIRST_NAME ASC, LAST_NAME DESC", sql); + assertEquals("SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\" ORDER BY \"FIRST_NAME\" ASC, \"LAST_NAME\" DESC", sql); } /** @@ -218,7 +230,7 @@ public void selectColumnsFromTableGroupBy() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS GROUP BY FIRST_NAME", sql); + assertEquals("SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\" GROUP BY \"FIRST_NAME\"", sql); } /** @@ -234,7 +246,7 @@ public void selectWhereSimple() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS WHERE (PRICE > ?)", sql); + assertEquals("SELECT * FROM \"CUSTOMERS\" WHERE (\"PRICE\" > ?)", sql); } /** @@ -251,7 +263,7 @@ public void selectWhereAnd() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS WHERE (PRICE > ?) AND (AMOUNT < ?)", sql); + assertEquals("SELECT * FROM \"CUSTOMERS\" WHERE (\"PRICE\" > ?) AND (\"AMOUNT\" < ?)", sql); } /** @@ -267,7 +279,7 @@ public void selectWhereOr() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS WHERE (PRICE > ? OR AMOUNT < ?)", sql); + assertEquals("SELECT * FROM \"CUSTOMERS\" WHERE (\"PRICE\" > ? OR \"AMOUNT\" < ?)", sql); } /** @@ -287,7 +299,7 @@ public void selectWhereExpr() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS WHERE (PRICE > ? OR AMOUNT < ?)", sql); + assertEquals("SELECT * FROM \"CUSTOMERS\" WHERE (\"PRICE\" > ? OR \"AMOUNT\" < ?)", sql); } /** @@ -303,7 +315,7 @@ public void selectLimit() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS LIMIT 10", sql); + assertEquals("SELECT * FROM \"CUSTOMERS\" LIMIT 10", sql); } /** @@ -320,7 +332,7 @@ public void selectLimitOffset() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS LIMIT 10 OFFSET 20", sql); + assertEquals("SELECT * FROM \"CUSTOMERS\" LIMIT 10 OFFSET 20", sql); } /** @@ -338,7 +350,8 @@ public void selectHaving() { .build(); assertNotNull(sql); - assertEquals("SELECT COUNT(FIRST_NAME), COUNTRY FROM CUSTOMERS GROUP BY COUNTRY HAVING COUNT(FIRST_NAME) > 5", sql); + assertEquals("SELECT COUNT(\"FIRST_NAME\"), \"COUNTRY\" FROM \"CUSTOMERS\" GROUP BY \"COUNTRY\" HAVING COUNT(\"FIRST_NAME\") > 5", + sql); } /** @@ -358,7 +371,7 @@ public void selectUnion() { .build(); assertNotNull(sql); - assertEquals("SELECT COUNTRY FROM CUSTOMERS UNION SELECT COUNTRY FROM SUPPLIERS", sql); + assertEquals("SELECT \"COUNTRY\" FROM \"CUSTOMERS\" UNION SELECT \"COUNTRY\" FROM \"SUPPLIERS\"", sql); } } diff --git a/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/SequenceTest.java b/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/SequenceTest.java index 522162179ae..57d39ddd78b 100644 --- a/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/SequenceTest.java +++ b/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/SequenceTest.java @@ -9,12 +9,11 @@ */ package org.eclipse.dirigible.database.sql.dialects.h2; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; /** * The Class SequenceTest. @@ -32,7 +31,7 @@ public void createSequence() { .build(); assertNotNull(sql); - assertEquals("CREATE SEQUENCE CUSTOMERS_SEQUENCE", sql); + assertEquals("CREATE SEQUENCE \"CUSTOMERS_SEQUENCE\"", sql); } /** @@ -46,7 +45,7 @@ public void alterSequence() { .build(); assertNotNull(sql); - assertEquals("ALTER SEQUENCE CUSTOMERS_SEQUENCE", sql); + assertEquals("ALTER SEQUENCE \"CUSTOMERS_SEQUENCE\"", sql); } /** @@ -60,7 +59,7 @@ public void dropSequnce() { .build(); assertNotNull(sql); - assertEquals("DROP SEQUENCE CUSTOMERS_SEQUENCE", sql); + assertEquals("DROP SEQUENCE \"CUSTOMERS_SEQUENCE\"", sql); } /** diff --git a/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/UpdateTest.java b/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/UpdateTest.java index 6d9e4832782..030d77e69cb 100644 --- a/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/UpdateTest.java +++ b/modules/database/database-sql-h2/src/test/java/org/eclipse/dirigible/database/sql/dialects/h2/UpdateTest.java @@ -9,12 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.h2; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class UpdateTest. */ @@ -32,7 +32,7 @@ public void updateSimple() { .build(); assertNotNull(sql); - assertEquals("UPDATE CUSTOMERS SET FIRST_NAME = 'John'", sql); + assertEquals("UPDATE \"CUSTOMERS\" SET \"FIRST_NAME\" = 'John'", sql); } /** @@ -48,7 +48,7 @@ public void updateValues() { .build(); assertNotNull(sql); - assertEquals("UPDATE CUSTOMERS SET FIRST_NAME = 'John', LAST_NAME = 'Smith'", sql); + assertEquals("UPDATE \"CUSTOMERS\" SET \"FIRST_NAME\" = 'John', \"LAST_NAME\" = 'Smith'", sql); } /** @@ -66,7 +66,9 @@ public void updateWhere() { .build(); assertNotNull(sql); - assertEquals("UPDATE CUSTOMERS SET FIRST_NAME = 'John', LAST_NAME = 'Smith' WHERE (AGE > ?) AND (COMPANY = 'SAP')", sql); + assertEquals( + "UPDATE \"CUSTOMERS\" SET \"FIRST_NAME\" = 'John', \"LAST_NAME\" = 'Smith' WHERE (\"AGE\" > ?) AND (\"COMPANY\" = 'SAP')", + sql); } /** @@ -87,7 +89,9 @@ public void updateWhereSelect() { .build(); assertNotNull(sql); - assertEquals("UPDATE CUSTOMERS SET FIRST_NAME = 'John', SALARY = SELECT MAX(SALARY) FROM BENEFITS WHERE (COMPANY = 'SAP')", sql); + assertEquals( + "UPDATE \"CUSTOMERS\" SET \"FIRST_NAME\" = 'John', \"SALARY\" = SELECT MAX(\"SALARY\") FROM \"BENEFITS\" WHERE (\"COMPANY\" = 'SAP')", + sql); } /** @@ -109,7 +113,8 @@ public void updateWhereExpr() { .build(); assertNotNull(sql); - assertEquals("UPDATE CUSTOMERS SET FIRST_NAME = 'John', LAST_NAME = 'Smith' WHERE (PRICE > ? OR AMOUNT < ? AND COMPANY = 'SAP')", + assertEquals( + "UPDATE \"CUSTOMERS\" SET \"FIRST_NAME\" = 'John', \"LAST_NAME\" = 'Smith' WHERE (\"PRICE\" > ? OR \"AMOUNT\" < ? AND \"COMPANY\" = 'SAP')", sql); } diff --git a/modules/database/database-sql-hana/pom.xml b/modules/database/database-sql-hana/pom.xml index a8784f21c9b..7076e254d3d 100644 --- a/modules/database/database-sql-hana/pom.xml +++ b/modules/database/database-sql-hana/pom.xml @@ -18,6 +18,11 @@ + + org.springframework.boot + spring-boot-starter-test + test + org.eclipse.dirigible dirigible-components-data-sources diff --git a/modules/database/database-sql-hana/src/main/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaAlterTableBuilder.java b/modules/database/database-sql-hana/src/main/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaAlterTableBuilder.java index cb1c09cd1c9..ebd444a812f 100644 --- a/modules/database/database-sql-hana/src/main/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaAlterTableBuilder.java +++ b/modules/database/database-sql-hana/src/main/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaAlterTableBuilder.java @@ -15,7 +15,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; - /** * The Class HanaAlterTableBuilder. */ @@ -73,7 +72,7 @@ protected void generateColumnsForAlter(StringBuilder sql) { protected String traverseColumnNamesForDrop() { StringBuilder snippet = new StringBuilder(); for (String[] column : this.getColumns()) { - String columnName = (isCaseSensitive()) ? encapsulate(column[0]) : column[0]; + String columnName = encapsulate(column[0]); snippet.append(KEYWORD_DROP) .append(SPACE) .append(OPEN); @@ -167,7 +166,7 @@ protected void generateUniqueIndices(StringBuilder sql) { protected void generateUniqueIndex(StringBuilder sql, CreateTableUniqueIndexBuilder uniqueIndex) { if (uniqueIndex != null) { if (uniqueIndex.getName() != null) { - String uniqueIndexName = (isCaseSensitive()) ? encapsulate(uniqueIndex.getName()) : uniqueIndex.getName(); + String uniqueIndexName = encapsulate(uniqueIndex.getName()); sql.append(KEYWORD_ADD) .append(SPACE) .append(KEYWORD_CONSTRAINT) diff --git a/modules/database/database-sql-hana/src/main/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaCreatePublicSynonymBuilder.java b/modules/database/database-sql-hana/src/main/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaCreatePublicSynonymBuilder.java index 82f73626189..c79bb8671ae 100644 --- a/modules/database/database-sql-hana/src/main/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaCreatePublicSynonymBuilder.java +++ b/modules/database/database-sql-hana/src/main/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaCreatePublicSynonymBuilder.java @@ -34,7 +34,7 @@ public HanaCreatePublicSynonymBuilder(ISqlDialect dialect, String synonym) { */ @Override protected void generateSynonym(StringBuilder sql) { - String synonymName = (isCaseSensitive()) ? encapsulate(this.getSynonym(), true) : this.getSynonym(); + String synonymName = encapsulate(this.getSynonym(), true); sql.append(SPACE) .append(KEYWORD_PUBLIC) .append(SPACE) diff --git a/modules/database/database-sql-hana/src/main/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaCreateTableBuilder.java b/modules/database/database-sql-hana/src/main/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaCreateTableBuilder.java index 7bad9a4dd12..5d97e61d8f7 100644 --- a/modules/database/database-sql-hana/src/main/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaCreateTableBuilder.java +++ b/modules/database/database-sql-hana/src/main/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaCreateTableBuilder.java @@ -9,11 +9,6 @@ */ package org.eclipse.dirigible.database.sql.dialects.hana; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Set; - import org.eclipse.dirigible.database.sql.ISqlDialect; import org.eclipse.dirigible.database.sql.builders.table.CreateTableBuilder; import org.eclipse.dirigible.database.sql.builders.table.CreateTableIndexBuilder; @@ -21,6 +16,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Arrays; +import java.util.Set; + /** * The HANA Create Table Builder. */ @@ -52,7 +50,7 @@ public HanaCreateTableBuilder(ISqlDialect dialect, String table, String tableTyp */ @Override protected void generateTable(StringBuilder sql) { - String tableName = (isCaseSensitive()) ? encapsulate(this.getTable(), true) : this.getTable(); + String tableName = encapsulate(this.getTable(), true); String tableType = ""; if (this.tableType.equalsIgnoreCase(KEYWORD_COLUMN) || this.tableType.equalsIgnoreCase(KEYWORD_COLUMNSTORE)) { diff --git a/modules/database/database-sql-hana/src/main/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaCreateTableTypeBuilder.java b/modules/database/database-sql-hana/src/main/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaCreateTableTypeBuilder.java index f6ed2ac3633..68480756363 100644 --- a/modules/database/database-sql-hana/src/main/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaCreateTableTypeBuilder.java +++ b/modules/database/database-sql-hana/src/main/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaCreateTableTypeBuilder.java @@ -9,13 +9,6 @@ */ package org.eclipse.dirigible.database.sql.dialects.hana; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.Stream; - import org.eclipse.dirigible.database.sql.DataType; import org.eclipse.dirigible.database.sql.ISqlDialect; import org.eclipse.dirigible.database.sql.SqlException; @@ -24,6 +17,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; + /** * The Class HanaCreateTableTypeBuilder. */ @@ -37,10 +37,10 @@ public class HanaCreateTableTypeBuilder extends CreateTableTypeBuilder { List.of(DataType.VARCHAR, DataType.CHAR, DataType.NVARCHAR, DataType.ALPHANUM, DataType.SHORTTEXT, DataType.DECIMAL)); /** The table type. */ - private String tableType; + private final String tableType; /** The columns. */ - private List columns = new ArrayList<>(); + private final List columns = new ArrayList<>(); /** The primary key. */ private CreateTablePrimaryKeyBuilder primaryKey; @@ -124,7 +124,7 @@ private String iterateColumns() { boolean isColumnName = true; for (String arg : column) { if (isColumnName) { - String columnName = (isCaseSensitive()) ? encapsulate(arg) : arg; + String columnName = encapsulate(arg); snippet.append(columnName) .append(SPACE); isColumnName = false; @@ -148,7 +148,7 @@ private String iterateColumns() { * @param sql the sql */ private void generateTableType(StringBuilder sql) { - String tableTypeName = (isCaseSensitive()) ? encapsulate(this.getTableType(), true) : this.getTableType(); + String tableTypeName = encapsulate(this.getTableType(), true); sql.append(SPACE) .append(KEYWORD_TABLE_TYPE) .append(SPACE) @@ -220,7 +220,6 @@ public CreateTableTypeBuilder column(String name, DataType type, Boolean isPrima definition = new String[] {name, getDialect().getDataTypeName(type)}; } - if (!isNullable) { definition = Stream.of(definition, new String[] {getDialect().getNotNullArgument()}) .flatMap(Stream::of) @@ -254,7 +253,7 @@ protected void generatePrimaryKey(StringBuilder sql) { sql.append(COMMA) .append(SPACE); if (this.primaryKey.getName() != null) { - String primaryKeyName = (isCaseSensitive()) ? encapsulate(this.primaryKey.getName()) : this.primaryKey.getName(); + String primaryKeyName = encapsulate(this.primaryKey.getName()); sql.append(KEYWORD_CONSTRAINT) .append(SPACE) .append(primaryKeyName) @@ -312,7 +311,7 @@ protected String traverseColumnNames(Set names) { StringBuilder snippet = new StringBuilder(); snippet.append(SPACE); for (String column : names) { - String columnName = (isCaseSensitive()) ? encapsulate(column) : column; + String columnName = encapsulate(column); snippet.append(columnName) .append(SPACE) .append(COMMA) diff --git a/modules/database/database-sql-hana/src/main/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaDropPublicSynonymBuilder.java b/modules/database/database-sql-hana/src/main/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaDropPublicSynonymBuilder.java index 1bfdc70b223..04f98dab8ea 100644 --- a/modules/database/database-sql-hana/src/main/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaDropPublicSynonymBuilder.java +++ b/modules/database/database-sql-hana/src/main/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaDropPublicSynonymBuilder.java @@ -34,7 +34,7 @@ public HanaDropPublicSynonymBuilder(ISqlDialect dialect, String synonym) { */ @Override protected void generateSynonym(StringBuilder sql) { - String synonymName = (isCaseSensitive()) ? encapsulate(this.getSynonym(), true) : this.getSynonym(); + String synonymName = encapsulate(this.getSynonym(), true); sql.append(SPACE) .append(KEYWORD_PUBLIC) .append(SPACE) diff --git a/modules/database/database-sql-hana/src/main/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaDropTableTypeBuilder.java b/modules/database/database-sql-hana/src/main/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaDropTableTypeBuilder.java index e729b3ab2b9..c2e54d26d3a 100644 --- a/modules/database/database-sql-hana/src/main/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaDropTableTypeBuilder.java +++ b/modules/database/database-sql-hana/src/main/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaDropTableTypeBuilder.java @@ -23,7 +23,7 @@ public class HanaDropTableTypeBuilder extends DropTableTypeBuilder { private static final Logger logger = LoggerFactory.getLogger(HanaDropTableTypeBuilder.class); /** The table type. */ - private String tableType; + private final String tableType; /** * Instantiates a new abstract drop sql builder. @@ -67,7 +67,7 @@ public String generate() { * @param sql the sql */ private void generateTableType(StringBuilder sql) { - String tableTypeName = (isCaseSensitive()) ? encapsulate(this.getTableType(), true) : this.getTableType(); + String tableTypeName = encapsulate(this.getTableType(), true); sql.append(SPACE) .append(KEYWORD_TABLE_TYPE) .append(SPACE) diff --git a/modules/database/database-sql-hana/src/main/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaNextValueSequenceBuilder.java b/modules/database/database-sql-hana/src/main/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaNextValueSequenceBuilder.java index 59225bf8e83..ca75e2afd4e 100644 --- a/modules/database/database-sql-hana/src/main/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaNextValueSequenceBuilder.java +++ b/modules/database/database-sql-hana/src/main/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaNextValueSequenceBuilder.java @@ -9,11 +9,11 @@ */ package org.eclipse.dirigible.database.sql.dialects.hana; -import static java.text.MessageFormat.format; - import org.eclipse.dirigible.database.sql.ISqlDialect; import org.eclipse.dirigible.database.sql.builders.sequence.NextValueSequenceBuilder; +import static java.text.MessageFormat.format; + /** * The HANA Next Value Sequence Builder. */ @@ -39,7 +39,7 @@ public HanaNextValueSequenceBuilder(ISqlDialect dialect, String sequence) { */ @Override public String generate() { - String sequenceName = (isCaseSensitive()) ? encapsulate(this.getSequence(), true) : this.getSequence(); + String sequenceName = encapsulate(this.getSequence(), true); String sql = format(PATTERN_SELECT_NEXT_VAL_SEQUENCE, sequenceName); return sql; } diff --git a/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/CreateViewTest.java b/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/CreateViewTest.java index dcb93c08280..c409a85634c 100644 --- a/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/CreateViewTest.java +++ b/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/CreateViewTest.java @@ -9,12 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.hana; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class CreateViewTest. */ @@ -40,7 +40,7 @@ public void createViewAsSelect() { .build(); assertNotNull(sql); - assertEquals("CREATE VIEW CUSTOMERS_VIEW ( ID , FIRST_NAME , LAST_NAME ) AS SELECT * FROM CUSTOMERS", sql); + assertEquals("CREATE VIEW \"CUSTOMERS_VIEW\" ( \"ID\" , \"FIRST_NAME\" , \"LAST_NAME\" ) AS SELECT * FROM \"CUSTOMERS\"", sql); } } diff --git a/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/DeleteTest.java b/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/DeleteTest.java index 64245be818c..bf3ae62512b 100644 --- a/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/DeleteTest.java +++ b/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/DeleteTest.java @@ -9,12 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.hana; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class DeleteTest. */ @@ -31,7 +31,7 @@ public void deleteSimple() { .build(); assertNotNull(sql); - assertEquals("DELETE FROM CUSTOMERS", sql); + assertEquals("DELETE FROM \"CUSTOMERS\"", sql); } /** @@ -47,7 +47,7 @@ public void deleteWhere() { .build(); assertNotNull(sql); - assertEquals("DELETE FROM CUSTOMERS WHERE (AGE > ?) AND (COMPANY = 'SAP')", sql); + assertEquals("DELETE FROM \"CUSTOMERS\" WHERE (\"AGE\" > ?) AND (\"COMPANY\" = 'SAP')", sql); } } diff --git a/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/DropTableTest.java b/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/DropTableTest.java index 5204a24591b..8acf3cc0cef 100644 --- a/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/DropTableTest.java +++ b/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/DropTableTest.java @@ -9,12 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.hana; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class DropTableTest. */ @@ -31,8 +31,7 @@ public void dropTable() { .build(); assertNotNull(sql); - assertEquals("DROP TABLE CUSTOMERS", sql); + assertEquals("DROP TABLE \"CUSTOMERS\"", sql); } - } diff --git a/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/DropTableTypeTest.java b/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/DropTableTypeTest.java index 64c3e3442bd..f836cf1accf 100644 --- a/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/DropTableTypeTest.java +++ b/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/DropTableTypeTest.java @@ -9,13 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.hana; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.eclipse.dirigible.commons.config.Configuration; import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class DropTableTypeTest. */ @@ -32,7 +31,7 @@ public void dropTableType() { .build(); assertNotNull(sql); - assertEquals("DROP TYPE CUSTOMERS_STRUCTURE", sql); + assertEquals("DROP TYPE \"CUSTOMERS_STRUCTURE\"", sql); } /** @@ -40,17 +39,12 @@ public void dropTableType() { */ @Test public void dropTableTypeCaseSensitive() { - Configuration.set("DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE", "true"); - try { - String sql = SqlFactory.getNative(new HanaSqlDialect()) - .drop() - .tableType("CUSTOMERS_STRUCTURE") - .build(); + String sql = SqlFactory.getNative(new HanaSqlDialect()) + .drop() + .tableType("CUSTOMERS_STRUCTURE") + .build(); - assertNotNull(sql); - assertEquals("DROP TYPE \"CUSTOMERS_STRUCTURE\"", sql); - } finally { - Configuration.set("DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE", "false"); - } + assertNotNull(sql); + assertEquals("DROP TYPE \"CUSTOMERS_STRUCTURE\"", sql); } } diff --git a/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/DropViewTest.java b/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/DropViewTest.java index 1dee2302f2b..a7bc46dc09e 100644 --- a/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/DropViewTest.java +++ b/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/DropViewTest.java @@ -9,12 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.hana; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class DropViewTest. */ @@ -31,7 +31,7 @@ public void dropView() { .build(); assertNotNull(sql); - assertEquals("DROP VIEW CUSTOMERS_VIEW", sql); + assertEquals("DROP VIEW \"CUSTOMERS_VIEW\"", sql); } } diff --git a/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaCreateTableBuilderTest.java b/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaCreateTableBuilderTest.java index 98dddf04479..743059d445e 100644 --- a/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaCreateTableBuilderTest.java +++ b/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaCreateTableBuilderTest.java @@ -9,20 +9,18 @@ */ package org.eclipse.dirigible.database.sql.dialects.hana; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import org.eclipse.dirigible.database.sql.*; +import org.hamcrest.MatcherAssert; +import org.hamcrest.Matchers; +import org.junit.Test; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import java.util.List; -import org.eclipse.dirigible.commons.config.Configuration; -import org.eclipse.dirigible.database.sql.*; -import org.hamcrest.MatcherAssert; -import org.hamcrest.Matchers; -import org.junit.Test; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.*; /** * The Class HanaCreateTableBuilderTest. @@ -44,7 +42,7 @@ public void createTableGeneric() { assertNotNull(sql); assertEquals( - "CREATE COLUMN TABLE CUSTOMERS ( ID INTEGER NOT NULL PRIMARY KEY , FIRST_NAME VARCHAR (20) NOT NULL UNIQUE , LAST_NAME VARCHAR (30) )", + "CREATE COLUMN TABLE \"CUSTOMERS\" ( \"ID\" INTEGER NOT NULL PRIMARY KEY , \"FIRST_NAME\" VARCHAR (20) NOT NULL UNIQUE , \"LAST_NAME\" VARCHAR (30) )", sql); } @@ -53,24 +51,18 @@ public void createTableGeneric() { */ @Test public void createTableCaseSensitiveGeneric() { - Configuration.set("DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE", "true"); - try { - String sql = SqlFactory.getDefault() - .create() - .table("myapp::test.customers") - .column("Id", DataType.INTEGER, Modifiers.PRIMARY_KEY, Modifiers.NOT_NULL, Modifiers.NON_UNIQUE) - .column("First_Name", DataType.VARCHAR, Modifiers.REGULAR, Modifiers.NOT_NULL, Modifiers.UNIQUE, "(20)") - .column("Last_Name", DataType.VARCHAR, Modifiers.REGULAR, Modifiers.NULLABLE, Modifiers.NON_UNIQUE, - "(30)") - .build(); - - assertNotNull(sql); - assertEquals( - "CREATE TABLE \"myapp::test.customers\" ( \"Id\" INTEGER NOT NULL PRIMARY KEY , \"First_Name\" VARCHAR (20) NOT NULL UNIQUE , \"Last_Name\" VARCHAR (30) )", - sql); - } finally { - Configuration.set("DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE", "false"); - } + String sql = SqlFactory.getDefault() + .create() + .table("myapp::test.customers") + .column("Id", DataType.INTEGER, Modifiers.PRIMARY_KEY, Modifiers.NOT_NULL, Modifiers.NON_UNIQUE) + .column("First_Name", DataType.VARCHAR, Modifiers.REGULAR, Modifiers.NOT_NULL, Modifiers.UNIQUE, "(20)") + .column("Last_Name", DataType.VARCHAR, Modifiers.REGULAR, Modifiers.NULLABLE, Modifiers.NON_UNIQUE, "(30)") + .build(); + + assertNotNull(sql); + assertEquals( + "CREATE TABLE \"myapp::test.customers\" ( \"Id\" INTEGER NOT NULL PRIMARY KEY , \"First_Name\" VARCHAR (20) NOT NULL UNIQUE , \"Last_Name\" VARCHAR (30) )", + sql); } /** @@ -88,7 +80,7 @@ public void createTableColumn() { assertNotNull(sql); assertEquals( - "CREATE COLUMN TABLE CUSTOMERS ( ID INTEGER NOT NULL PRIMARY KEY , FIRST_NAME VARCHAR (20) NOT NULL UNIQUE , LAST_NAME VARCHAR (30) )", + "CREATE COLUMN TABLE \"CUSTOMERS\" ( \"ID\" INTEGER NOT NULL PRIMARY KEY , \"FIRST_NAME\" VARCHAR (20) NOT NULL UNIQUE , \"LAST_NAME\" VARCHAR (30) )", sql); } @@ -107,7 +99,7 @@ public void createRowTable() { assertNotNull(sql); assertEquals( - "CREATE ROW TABLE CUSTOMERS ( ID INTEGER NOT NULL PRIMARY KEY , FIRST_NAME VARCHAR (20) NOT NULL UNIQUE , LAST_NAME VARCHAR (30) )", + "CREATE ROW TABLE \"CUSTOMERS\" ( \"ID\" INTEGER NOT NULL PRIMARY KEY , \"FIRST_NAME\" VARCHAR (20) NOT NULL UNIQUE , \"LAST_NAME\" VARCHAR (30) )", sql); } @@ -126,7 +118,7 @@ public void createTableColumnTypeSafe() { assertNotNull(sql); assertEquals( - "CREATE COLUMN TABLE CUSTOMERS ( ID INTEGER NOT NULL PRIMARY KEY , FIRST_NAME VARCHAR (20) UNIQUE , LAST_NAME VARCHAR (30) )", + "CREATE COLUMN TABLE \"CUSTOMERS\" ( \"ID\" INTEGER NOT NULL PRIMARY KEY , \"FIRST_NAME\" VARCHAR (20) UNIQUE , \"LAST_NAME\" VARCHAR (30) )", sql); } @@ -146,7 +138,7 @@ public void createTableWithCompositeKeyWithSetPKOnColumnLevel() { assertNotNull(sql); assertEquals( - "CREATE COLUMN TABLE CUSTOMERS ( ID INTEGER NOT NULL , ID2 INTEGER NOT NULL , FIRST_NAME VARCHAR (20) UNIQUE , LAST_NAME VARCHAR (30) , PRIMARY KEY(ID , ID2) )", + "CREATE COLUMN TABLE \"CUSTOMERS\" ( \"ID\" INTEGER NOT NULL , \"ID2\" INTEGER NOT NULL , \"FIRST_NAME\" VARCHAR (20) UNIQUE , \"LAST_NAME\" VARCHAR (30) , PRIMARY KEY(\"ID\" , \"ID2\") )", sql); } @@ -167,7 +159,7 @@ public void createTableWithCompositeKeyWithSetPKOnConstraintLevel() { assertNotNull(sql); assertEquals( - "CREATE COLUMN TABLE CUSTOMERS ( ID INTEGER NOT NULL , ID2 INTEGER NOT NULL , FIRST_NAME VARCHAR (20) UNIQUE , LAST_NAME VARCHAR (30) , PRIMARY KEY ( ID , ID2 ))", + "CREATE COLUMN TABLE \"CUSTOMERS\" ( \"ID\" INTEGER NOT NULL , \"ID2\" INTEGER NOT NULL , \"FIRST_NAME\" VARCHAR (20) UNIQUE , \"LAST_NAME\" VARCHAR (30) , PRIMARY KEY ( \"ID\" , \"ID2\" ))", sql); } @@ -188,7 +180,7 @@ public void createTableWithCompositeKeyWithSetPKOnConstraintAndColumnLevel() { assertNotNull(sql); assertEquals( - "CREATE COLUMN TABLE CUSTOMERS ( ID INTEGER NOT NULL , ID2 INTEGER NOT NULL , FIRST_NAME VARCHAR (20) UNIQUE , LAST_NAME VARCHAR (30) , PRIMARY KEY(ID , ID2) )", + "CREATE COLUMN TABLE \"CUSTOMERS\" ( \"ID\" INTEGER NOT NULL , \"ID2\" INTEGER NOT NULL , \"FIRST_NAME\" VARCHAR (20) UNIQUE , \"LAST_NAME\" VARCHAR (30) , PRIMARY KEY(\"ID\" , \"ID2\") )", sql); } @@ -206,7 +198,7 @@ public void createTableWithSetPKOnConstraintAndColumnLevel() { .build(); assertNotNull(sql); - assertEquals("CREATE COLUMN TABLE CUSTOMERS ( ID INTEGER NOT NULL PRIMARY KEY , FIRST_NAME VARCHAR (20) UNIQUE )", sql); + assertEquals("CREATE COLUMN TABLE \"CUSTOMERS\" ( \"ID\" INTEGER NOT NULL PRIMARY KEY , \"FIRST_NAME\" VARCHAR (20) UNIQUE )", sql); } /** @@ -223,7 +215,7 @@ public void parseTableWithoutPK() { .build(); assertNotNull(sql); - assertEquals("CREATE COLUMN TABLE CUSTOMERS ( ID INTEGER NOT NULL , FIRST_NAME VARCHAR (20) UNIQUE )", sql); + assertEquals("CREATE COLUMN TABLE \"CUSTOMERS\" ( \"ID\" INTEGER NOT NULL , \"FIRST_NAME\" VARCHAR (20) UNIQUE )", sql); } /** @@ -243,11 +235,11 @@ public void createRowTableWithIndexes() { assertNotNull("Unexpected result from builder", sql); assertTrue("Expected create table statement was not found", sql.contains( - "CREATE ROW TABLE CUSTOMERS ( ID INTEGER NOT NULL PRIMARY KEY , FIRST_NAME VARCHAR (20) NOT NULL UNIQUE , LAST_NAME VARCHAR (30) );")); - assertTrue("Expected unique index statement was not found", sql.contains("CREATE UNIQUE CPBTREE INDEX I2 ON CUSTOMERS ( ID ) ASC")); - assertTrue("Expected index statement was not found", sql.contains("CREATE BTREE INDEX I1 ON CUSTOMERS ( LAST_NAME ) DESC")); + "CREATE ROW TABLE \"CUSTOMERS\" ( \"ID\" INTEGER NOT NULL PRIMARY KEY , \"FIRST_NAME\" VARCHAR (20) NOT NULL UNIQUE , \"LAST_NAME\" VARCHAR (30) );")); + assertThat(sql).contains("CREATE UNIQUE CPBTREE INDEX \"I2\" ON \"CUSTOMERS\" ( \"ID\" ) ASC"); + assertThat(sql).contains("CREATE BTREE INDEX \"I1\" ON \"CUSTOMERS\" ( \"LAST_NAME\" ) DESC"); int expectedStatementLength = - "CREATE ROW TABLE CUSTOMERS ( ID INTEGER NOT NULL PRIMARY KEY , FIRST_NAME VARCHAR (20) NOT NULL UNIQUE , LAST_NAME VARCHAR (30) ); CREATE UNIQUE CPBTREE INDEX I2 ON CUSTOMERS ( ID ) ASC; CREATE BTREE INDEX I1 ON CUSTOMERS ( LAST_NAME ) DESC".length(); + "CREATE ROW TABLE \"CUSTOMERS\" ( \"ID\" INTEGER NOT NULL PRIMARY KEY , \"FIRST_NAME\" VARCHAR (20) NOT NULL UNIQUE , \"LAST_NAME\" VARCHAR (30) ); CREATE UNIQUE CPBTREE INDEX \"I2\" ON \"CUSTOMERS\" ( \"ID\" ) ASC; CREATE BTREE INDEX \"I1\" ON \"CUSTOMERS\" ( \"LAST_NAME\" ) DESC".length(); assertEquals("Unexpected length of statement", expectedStatementLength, sql.length()); } @@ -267,12 +259,11 @@ public void testCreateTableWithIndexes() { .buildTable(); assertEquals("Unexpected create table statement", - "CREATE ROW TABLE CUSTOMERS ( ID INTEGER NOT NULL PRIMARY KEY , FIRST_NAME VARCHAR (20) NOT NULL UNIQUE , LAST_NAME VARCHAR (30) )", + "CREATE ROW TABLE \"CUSTOMERS\" ( \"ID\" INTEGER NOT NULL PRIMARY KEY , \"FIRST_NAME\" VARCHAR (20) NOT NULL UNIQUE , \"LAST_NAME\" VARCHAR (30) )", table.getCreateTableStatement()); - Collection expected = Arrays.asList("CREATE UNIQUE CPBTREE INDEX I2 ON CUSTOMERS ( ID ) ASC", - "CREATE BTREE INDEX I1 ON CUSTOMERS ( LAST_NAME ) DESC"); - + Collection expected = Arrays.asList("CREATE UNIQUE CPBTREE INDEX \"I2\" ON \"CUSTOMERS\" ( \"ID\" ) ASC", + "CREATE BTREE INDEX \"I1\" ON \"CUSTOMERS\" ( \"LAST_NAME\" ) DESC"); MatcherAssert.assertThat("Indices equality without order", table.getCreateIndicesStatements(), Matchers.containsInAnyOrder(expected.toArray())); @@ -293,7 +284,7 @@ public void testCreateGlobalTemporaryTable() { assertNotNull(sql); assertEquals( - "CREATE GLOBAL TEMPORARY TABLE CUSTOMERS ( ID INTEGER NOT NULL PRIMARY KEY , FIRST_NAME VARCHAR (20) NOT NULL UNIQUE , LAST_NAME VARCHAR (30) )", + "CREATE GLOBAL TEMPORARY TABLE \"CUSTOMERS\" ( \"ID\" INTEGER NOT NULL PRIMARY KEY , \"FIRST_NAME\" VARCHAR (20) NOT NULL UNIQUE , \"LAST_NAME\" VARCHAR (30) )", sql); } @@ -310,7 +301,8 @@ public void testCreateGlobalTemporaryColumnTable() { .build(); assertNotNull(sql); - assertEquals("CREATE GLOBAL TEMPORARY COLUMN TABLE CUSTOMERS ( FIRST_NAME VARCHAR (20) NOT NULL UNIQUE , LAST_NAME VARCHAR (30) )", + assertEquals( + "CREATE GLOBAL TEMPORARY COLUMN TABLE \"CUSTOMERS\" ( \"FIRST_NAME\" VARCHAR (20) NOT NULL UNIQUE , \"LAST_NAME\" VARCHAR (30) )", sql); } diff --git a/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaCreateTableTypeBuilderTest.java b/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaCreateTableTypeBuilderTest.java index 6e78385a112..4e9c25ebbd2 100644 --- a/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaCreateTableTypeBuilderTest.java +++ b/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/HanaCreateTableTypeBuilderTest.java @@ -9,14 +9,13 @@ */ package org.eclipse.dirigible.database.sql.dialects.hana; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.eclipse.dirigible.commons.config.Configuration; import org.eclipse.dirigible.database.sql.DataType; import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class HanaCreateTableTypeBuilderTest. */ @@ -27,23 +26,18 @@ public class HanaCreateTableTypeBuilderTest { */ @Test public void executeCreateTableTypeCaseSensitive() { - Configuration.set("DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE", "true"); - try { - String sql = SqlFactory.getNative(new HanaSqlDialect()) - .create() - .tableType("CUSTOMERS_STRUCTURE") - .column("CATEGORY_ID", DataType.INTEGER) - .column("NAME", DataType.VARCHAR, "255") - .column("TYPES", DataType.VARCHAR, true, false, "220") - .build(); + String sql = SqlFactory.getNative(new HanaSqlDialect()) + .create() + .tableType("CUSTOMERS_STRUCTURE") + .column("CATEGORY_ID", DataType.INTEGER) + .column("NAME", DataType.VARCHAR, "255") + .column("TYPES", DataType.VARCHAR, true, false, "220") + .build(); - assertNotNull(sql); - assertEquals( - "CREATE TYPE \"CUSTOMERS_STRUCTURE\" AS TABLE ( \"CATEGORY_ID\" INTEGER , \"NAME\" VARCHAR (255) , \"TYPES\" VARCHAR (220) NOT NULL PRIMARY KEY )", - sql); - } finally { - Configuration.set("DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE", "false"); - } + assertNotNull(sql); + assertEquals( + "CREATE TYPE \"CUSTOMERS_STRUCTURE\" AS TABLE ( \"CATEGORY_ID\" INTEGER , \"NAME\" VARCHAR (255) , \"TYPES\" VARCHAR (220) NOT NULL PRIMARY KEY )", + sql); } /** @@ -61,7 +55,7 @@ public void executeCreateTableType() { assertNotNull(sql); assertEquals( - "CREATE TYPE CUSTOMERS_STRUCTURE AS TABLE ( CATEGORY_ID INTEGER , NAME VARCHAR (255) , TYPES VARCHAR (220) NOT NULL PRIMARY KEY )", + "CREATE TYPE \"CUSTOMERS_STRUCTURE\" AS TABLE ( \"CATEGORY_ID\" INTEGER , \"NAME\" VARCHAR (255) , \"TYPES\" VARCHAR (220) NOT NULL PRIMARY KEY )", sql); } @@ -70,23 +64,18 @@ public void executeCreateTableType() { */ @Test public void executeCreateTableTypeWithCompositePrimaryKey() { - Configuration.set("DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE", "true"); - try { - String sql = SqlFactory.getNative(new HanaSqlDialect()) - .create() - .tableType("CUSTOMERS_STRUCTURE") - .column("CATEGORY_ID", DataType.INTEGER) - .column("NAME", DataType.VARCHAR, true, false, "255") - .column("TYPES", DataType.VARCHAR, true, false, "220") - .build(); + String sql = SqlFactory.getNative(new HanaSqlDialect()) + .create() + .tableType("CUSTOMERS_STRUCTURE") + .column("CATEGORY_ID", DataType.INTEGER) + .column("NAME", DataType.VARCHAR, true, false, "255") + .column("TYPES", DataType.VARCHAR, true, false, "220") + .build(); - assertNotNull(sql); - assertEquals( - "CREATE TYPE \"CUSTOMERS_STRUCTURE\" AS TABLE ( \"CATEGORY_ID\" INTEGER , \"NAME\" VARCHAR (255) NOT NULL , \"TYPES\" VARCHAR (220) NOT NULL , PRIMARY KEY(NAME , TYPES) )", - sql); - } finally { - Configuration.set("DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE", "false"); - } + assertNotNull(sql); + assertEquals( + "CREATE TYPE \"CUSTOMERS_STRUCTURE\" AS TABLE ( \"CATEGORY_ID\" INTEGER , \"NAME\" VARCHAR (255) NOT NULL , \"TYPES\" VARCHAR (220) NOT NULL , PRIMARY KEY(NAME , TYPES) )", + sql); } } diff --git a/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/InsertTest.java b/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/InsertTest.java index 37eda3f560e..76f8f5fd657 100644 --- a/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/InsertTest.java +++ b/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/InsertTest.java @@ -9,12 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.hana; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class InsertTest. */ @@ -33,7 +33,7 @@ public void insertSimple() { .build(); assertNotNull(sql); - assertEquals("INSERT INTO CUSTOMERS (FIRST_NAME, LAST_NAME) VALUES (?, ?)", sql); + assertEquals("INSERT INTO \"CUSTOMERS\" (\"FIRST_NAME\", \"LAST_NAME\") VALUES (?, ?)", sql); } /** @@ -51,7 +51,7 @@ public void insertValues() { .build(); assertNotNull(sql); - assertEquals("INSERT INTO CUSTOMERS (FIRST_NAME, LAST_NAME) VALUES (?, 'Smith')", sql); + assertEquals("INSERT INTO \"CUSTOMERS\" (\"FIRST_NAME\", \"LAST_NAME\") VALUES (?, 'Smith')", sql); } /** @@ -72,7 +72,7 @@ public void insertSelect() { .build(); assertNotNull(sql); - assertEquals("INSERT INTO CUSTOMERS (FIRST_NAME, LAST_NAME) SELECT * FROM SUPPLIERS", sql); + assertEquals("INSERT INTO \"CUSTOMERS\" (\"FIRST_NAME\", \"LAST_NAME\") SELECT * FROM \"SUPPLIERS\"", sql); } } diff --git a/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/SchemaTest.java b/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/SchemaTest.java index f975efe4d3a..c1db4fa3773 100644 --- a/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/SchemaTest.java +++ b/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/SchemaTest.java @@ -9,41 +9,27 @@ */ package org.eclipse.dirigible.database.sql.dialects.hana; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.when; - -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; - -import org.eclipse.dirigible.commons.config.Configuration; import org.eclipse.dirigible.database.sql.DatabaseArtifactTypes; import org.eclipse.dirigible.database.sql.SqlFactory; -import org.eclipse.dirigible.database.sql.dialects.hana.HanaSqlDialect; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Answers; import org.mockito.Mock; -import org.mockito.MockedStatic; -import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; +import java.sql.*; + +import static org.junit.Assert.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; + /** * The Class SchemaTest. */ @RunWith(MockitoJUnitRunner.class) public class SchemaTest { - /** The Constant DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE_CONF_KEY. */ - private static final String DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE_CONF_KEY = "DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE"; - /** The mock connection. */ @Mock(answer = Answers.RETURNS_DEEP_STUBS) private Connection mockConnection; @@ -69,39 +55,18 @@ public void openMocks() { // PowerMockito.mockStatic(Configuration.class); } - /** * Execute create schema with case sensitive. */ @Test public void executeCreateSchemaWithCaseSensitive() { - try (MockedStatic configuration = Mockito.mockStatic(Configuration.class)) { - configuration.when(() -> Configuration.get(DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE_CONF_KEY, "false")) - .thenReturn("true"); - String sql = SqlFactory.getNative(new HanaSqlDialect()) - .create() - .schema("MySchema_1") - .build(); - assertNotNull(sql); - assertEquals("CREATE SCHEMA \"MySchema_1\"", sql); - } - } - /** - * Execute create schema no case sensitive. - */ - @Test - public void executeCreateSchemaNoCaseSensitive() { - try (MockedStatic configuration = Mockito.mockStatic(Configuration.class)) { - configuration.when(() -> Configuration.get(DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE_CONF_KEY, "false")) - .thenReturn("false"); - String sql = SqlFactory.getNative(new HanaSqlDialect()) - .create() - .schema("MySchema_1") - .build(); - assertNotNull(sql); - assertEquals("CREATE SCHEMA MySchema_1", sql); - } + String sql = SqlFactory.getNative(new HanaSqlDialect()) + .create() + .schema("MySchema_1") + .build(); + assertNotNull(sql); + assertEquals("CREATE SCHEMA \"MySchema_1\"", sql); } /** @@ -109,34 +74,14 @@ public void executeCreateSchemaNoCaseSensitive() { */ @Test public void executeDropSchemaWithCaseSensitive() { - try (MockedStatic configuration = Mockito.mockStatic(Configuration.class)) { - configuration.when(() -> Configuration.get(DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE_CONF_KEY, "false")) - .thenReturn("true"); - String sql = SqlFactory.getNative(new HanaSqlDialect()) - .drop() - .schema("MySchema_1") - .build(); - - assertNotNull(sql); - assertEquals("DROP SCHEMA \"MySchema_1\"", sql); - } - } - /** - * Execute drop schema no case sensitive. - */ - @Test - public void executeDropSchemaNoCaseSensitive() { - try (MockedStatic configuration = Mockito.mockStatic(Configuration.class)) { - configuration.when(() -> Configuration.get(DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE_CONF_KEY, "false")) - .thenReturn("false"); - String sql = SqlFactory.getNative(new HanaSqlDialect()) - .drop() - .schema("MySchema_1") - .build(); - assertNotNull(sql); - assertEquals("DROP SCHEMA MySchema_1", sql); - } + String sql = SqlFactory.getNative(new HanaSqlDialect()) + .drop() + .schema("MySchema_1") + .build(); + + assertNotNull(sql); + assertEquals("DROP SCHEMA \"MySchema_1\"", sql); } /** diff --git a/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/SelectTest.java b/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/SelectTest.java index bba604cf279..6f351d9cc5a 100644 --- a/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/SelectTest.java +++ b/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/SelectTest.java @@ -9,13 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.hana; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.eclipse.dirigible.commons.config.Configuration; import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class SelectTest. */ @@ -33,7 +32,7 @@ public void selectStar() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS", sql); + assertEquals("SELECT * FROM \"CUSTOMERS\"", sql); } /** @@ -49,7 +48,7 @@ public void selectColumnsFromTable() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS", sql); + assertEquals("SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\"", sql); } /** @@ -65,7 +64,7 @@ public void selectColumnsFromTableAliases() { .build(); assertNotNull(sql); - assertEquals("SELECT c.FIRST_NAME, c.LAST_NAME FROM CUSTOMERS AS c", sql); + assertEquals("SELECT \"c\".\"FIRST_NAME\", \"c\".\"LAST_NAME\" FROM \"CUSTOMERS\" AS \"c\"", sql); } /** @@ -82,7 +81,9 @@ public void selectColumnsFromTableJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS INNER JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\" INNER JOIN \"ADDRESSES\" ON \"CUSTOMERS\".\"ADDRESS_ID\"=\"ADDRESSES\".\"ADDRESS_ID\"", + sql); } /** @@ -99,7 +100,9 @@ public void selectColumnsFromTableInnerJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS INNER JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\" INNER JOIN \"ADDRESSES\" ON \"CUSTOMERS\".\"ADDRESS_ID\"=\"ADDRESSES\".\"ADDRESS_ID\"", + sql); } /** @@ -116,7 +119,9 @@ public void selectColumnsFromTableOuterJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS OUTER JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\" OUTER JOIN \"ADDRESSES\" ON \"CUSTOMERS\".\"ADDRESS_ID\"=\"ADDRESSES\".\"ADDRESS_ID\"", + sql); } /** @@ -133,7 +138,9 @@ public void selectColumnsFromTableLeftJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS LEFT JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\" LEFT JOIN \"ADDRESSES\" ON \"CUSTOMERS\".\"ADDRESS_ID\"=\"ADDRESSES\".\"ADDRESS_ID\"", + sql); } /** @@ -150,7 +157,9 @@ public void selectColumnsFromTableRightJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS RIGHT JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\" RIGHT JOIN \"ADDRESSES\" ON \"CUSTOMERS\".\"ADDRESS_ID\"=\"ADDRESSES\".\"ADDRESS_ID\"", + sql); } /** @@ -167,7 +176,9 @@ public void selectColumnsFromTableFullJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS FULL JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\" FULL JOIN \"ADDRESSES\" ON \"CUSTOMERS\".\"ADDRESS_ID\"=\"ADDRESSES\".\"ADDRESS_ID\"", + sql); } /** @@ -184,7 +195,7 @@ public void selectDistinctColumnsFromTable() { .build(); assertNotNull(sql); - assertEquals("SELECT DISTINCT FIRST_NAME, LAST_NAME FROM CUSTOMERS", sql); + assertEquals("SELECT DISTINCT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\"", sql); } /** @@ -202,7 +213,7 @@ public void selectColumnsFromTableOrderByAndDesc() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS ORDER BY FIRST_NAME ASC, LAST_NAME DESC", sql); + assertEquals("SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\" ORDER BY \"FIRST_NAME\" ASC, \"LAST_NAME\" DESC", sql); } /** @@ -219,7 +230,7 @@ public void selectColumnsFromTableGroupBy() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS GROUP BY FIRST_NAME", sql); + assertEquals("SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\" GROUP BY \"FIRST_NAME\"", sql); } /** @@ -235,7 +246,7 @@ public void selectWhereSimple() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS WHERE (PRICE > ?)", sql); + assertEquals("SELECT * FROM \"CUSTOMERS\" WHERE (\"PRICE\" > ?)", sql); } /** @@ -252,7 +263,7 @@ public void selectWhereAnd() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS WHERE (PRICE > ?) AND (AMOUNT < ?)", sql); + assertEquals("SELECT * FROM \"CUSTOMERS\" WHERE (\"PRICE\" > ?) AND (\"AMOUNT\" < ?)", sql); } /** @@ -268,7 +279,7 @@ public void selectWhereOr() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS WHERE (PRICE > ? OR AMOUNT < ?)", sql); + assertEquals("SELECT * FROM \"CUSTOMERS\" WHERE (\"PRICE\" > ? OR \"AMOUNT\" < ?)", sql); } /** @@ -288,7 +299,7 @@ public void selectWhereExpr() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS WHERE (PRICE > ? OR AMOUNT < ?)", sql); + assertEquals("SELECT * FROM \"CUSTOMERS\" WHERE (\"PRICE\" > ? OR \"AMOUNT\" < ?)", sql); } /** @@ -304,7 +315,7 @@ public void selectLimit() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS LIMIT 10", sql); + assertEquals("SELECT * FROM \"CUSTOMERS\" LIMIT 10", sql); } /** @@ -321,7 +332,7 @@ public void selectLimitOffset() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS LIMIT 10 OFFSET 20", sql); + assertEquals("SELECT * FROM \"CUSTOMERS\" LIMIT 10 OFFSET 20", sql); } /** @@ -339,7 +350,8 @@ public void selectHaving() { .build(); assertNotNull(sql); - assertEquals("SELECT COUNT(FIRST_NAME), COUNTRY FROM CUSTOMERS GROUP BY COUNTRY HAVING COUNT(FIRST_NAME) > 5", sql); + assertEquals("SELECT COUNT(\"FIRST_NAME\"), \"COUNTRY\" FROM \"CUSTOMERS\" GROUP BY \"COUNTRY\" HAVING COUNT(\"FIRST_NAME\") > 5", + sql); } /** @@ -359,7 +371,7 @@ public void selectUnion() { .build(); assertNotNull(sql); - assertEquals("SELECT COUNTRY FROM CUSTOMERS UNION SELECT COUNTRY FROM SUPPLIERS", sql); + assertEquals("SELECT \"COUNTRY\" FROM \"CUSTOMERS\" UNION SELECT \"COUNTRY\" FROM \"SUPPLIERS\"", sql); } /** @@ -367,19 +379,14 @@ public void selectUnion() { */ @Test public void selectFunctionCaseSensitive() { - Configuration.set("DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE", "true"); - try { - String sql = SqlFactory.getDefault() - .select() - .column("COS(0.0) c") - .from("DUMMY") - .build(); - - assertNotNull(sql); - assertEquals("SELECT COS(0.0) \"c\" FROM \"DUMMY\"", sql); - } finally { - Configuration.set("DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE", "false"); - } + String sql = SqlFactory.getDefault() + .select() + .column("COS(0.0) c") + .from("DUMMY") + .build(); + + assertNotNull(sql); + assertEquals("SELECT COS(0.0) \"c\" FROM \"DUMMY\"", sql); } } diff --git a/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/SequenceTest.java b/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/SequenceTest.java index 89ca61ed0d3..6534d0efc81 100644 --- a/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/SequenceTest.java +++ b/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/SequenceTest.java @@ -9,12 +9,11 @@ */ package org.eclipse.dirigible.database.sql.dialects.hana; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; /** * The Class SequenceTest. @@ -32,7 +31,7 @@ public void createSequence() { .build(); assertNotNull(sql); - assertEquals("CREATE SEQUENCE CUSTOMERS_SEQUENCE", sql); + assertEquals("CREATE SEQUENCE \"CUSTOMERS_SEQUENCE\"", sql); } /** @@ -46,7 +45,7 @@ public void alterSequence() { .build(); assertNotNull(sql); - assertEquals("ALTER SEQUENCE CUSTOMERS_SEQUENCE", sql); + assertEquals("ALTER SEQUENCE \"CUSTOMERS_SEQUENCE\"", sql); } /** @@ -60,7 +59,7 @@ public void dropSequence() { .build(); assertNotNull(sql); - assertEquals("DROP SEQUENCE CUSTOMERS_SEQUENCE RESTRICT", sql); + assertEquals("DROP SEQUENCE \"CUSTOMERS_SEQUENCE\" RESTRICT", sql); } /** @@ -73,7 +72,7 @@ public void nextvalSequnce() { .build(); assertNotNull(sql); - assertEquals("SELECT CUSTOMERS_SEQUENCE.NEXTVAL FROM DUMMY", sql); + assertEquals("SELECT \"CUSTOMERS_SEQUENCE\".NEXTVAL FROM DUMMY", sql); } } diff --git a/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/SynonymTest.java b/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/SynonymTest.java index c3e407c1a79..7c22c9ce968 100644 --- a/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/SynonymTest.java +++ b/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/SynonymTest.java @@ -9,18 +9,6 @@ */ package org.eclipse.dirigible.database.sql.dialects.hana; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; - -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; - import org.eclipse.dirigible.database.sql.DatabaseArtifactTypes; import org.eclipse.dirigible.database.sql.ISqlKeywords; import org.eclipse.dirigible.database.sql.SqlFactory; @@ -29,6 +17,11 @@ import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; +import java.sql.*; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.when; + /** * The Class SynonymTest. */ @@ -63,10 +56,9 @@ public void executeCreateSynonym() { .build(); assertNotNull(sql); - assertEquals("CREATE SYNONYM CUSTOMERS_SEQUENCE FOR CUSTOMERS", sql); + assertEquals("CREATE SYNONYM \"CUSTOMERS_SEQUENCE\" FOR \"CUSTOMERS\"", sql); } - /** * Execute drop synonym. */ @@ -78,7 +70,7 @@ public void executeDropSynonym() { .build(); assertNotNull(sql); - assertEquals("DROP SYNONYM CUSTOMERS_SEQUENCE", sql); + assertEquals("DROP SYNONYM \"CUSTOMERS_SEQUENCE\"", sql); } /** diff --git a/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/UpdateTest.java b/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/UpdateTest.java index a31c034341f..04a009165ef 100644 --- a/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/UpdateTest.java +++ b/modules/database/database-sql-hana/src/test/java/org/eclipse/dirigible/database/sql/dialects/hana/UpdateTest.java @@ -9,12 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.hana; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class UpdateTest. */ @@ -32,7 +32,7 @@ public void updateSimple() { .build(); assertNotNull(sql); - assertEquals("UPDATE CUSTOMERS SET FIRST_NAME = 'John'", sql); + assertEquals("UPDATE \"CUSTOMERS\" SET \"FIRST_NAME\" = 'John'", sql); } /** @@ -48,7 +48,7 @@ public void updateValues() { .build(); assertNotNull(sql); - assertEquals("UPDATE CUSTOMERS SET FIRST_NAME = 'John', LAST_NAME = 'Smith'", sql); + assertEquals("UPDATE \"CUSTOMERS\" SET \"FIRST_NAME\" = 'John', \"LAST_NAME\" = 'Smith'", sql); } /** @@ -66,7 +66,9 @@ public void updateWhere() { .build(); assertNotNull(sql); - assertEquals("UPDATE CUSTOMERS SET FIRST_NAME = 'John', LAST_NAME = 'Smith' WHERE (AGE > ?) AND (COMPANY = 'SAP')", sql); + assertEquals( + "UPDATE \"CUSTOMERS\" SET \"FIRST_NAME\" = 'John', \"LAST_NAME\" = 'Smith' WHERE (\"AGE\" > ?) AND (\"COMPANY\" = 'SAP')", + sql); } /** @@ -87,7 +89,9 @@ public void updateWhereSelect() { .build(); assertNotNull(sql); - assertEquals("UPDATE CUSTOMERS SET FIRST_NAME = 'John', SALARY = SELECT MAX(SALARY) FROM BENEFITS WHERE (COMPANY = 'SAP')", sql); + assertEquals( + "UPDATE \"CUSTOMERS\" SET \"FIRST_NAME\" = 'John', \"SALARY\" = SELECT MAX(\"SALARY\") FROM \"BENEFITS\" WHERE (\"COMPANY\" = 'SAP')", + sql); } /** @@ -109,7 +113,8 @@ public void updateWhereExpr() { .build(); assertNotNull(sql); - assertEquals("UPDATE CUSTOMERS SET FIRST_NAME = 'John', LAST_NAME = 'Smith' WHERE (PRICE > ? OR AMOUNT < ? AND COMPANY = 'SAP')", + assertEquals( + "UPDATE \"CUSTOMERS\" SET \"FIRST_NAME\" = 'John', \"LAST_NAME\" = 'Smith' WHERE (\"PRICE\" > ? OR \"AMOUNT\" < ? AND \"COMPANY\" = 'SAP')", sql); } diff --git a/modules/database/database-sql-mariadb/src/main/java/org/eclipse/dirigible/database/sql/dialects/mariadb/MariaDBSelectBuilder.java b/modules/database/database-sql-mariadb/src/main/java/org/eclipse/dirigible/database/sql/dialects/mariadb/MariaDBSelectBuilder.java index 2774e738941..1a0ca0a5dcd 100644 --- a/modules/database/database-sql-mariadb/src/main/java/org/eclipse/dirigible/database/sql/dialects/mariadb/MariaDBSelectBuilder.java +++ b/modules/database/database-sql-mariadb/src/main/java/org/eclipse/dirigible/database/sql/dialects/mariadb/MariaDBSelectBuilder.java @@ -20,7 +20,7 @@ public MariaDBSelectBuilder(ISqlDialect dialect) { @Override protected String encapsulateWhere(String where) { - return encapsulateMany(where, '`'); + return encapsulateMany(where, getEscapeSymbol()); } } diff --git a/modules/database/database-sql-mariadb/src/main/java/org/eclipse/dirigible/database/sql/dialects/mariadb/MariaDBSqlDialect.java b/modules/database/database-sql-mariadb/src/main/java/org/eclipse/dirigible/database/sql/dialects/mariadb/MariaDBSqlDialect.java index 488e2f29f95..fe6dd56673f 100644 --- a/modules/database/database-sql-mariadb/src/main/java/org/eclipse/dirigible/database/sql/dialects/mariadb/MariaDBSqlDialect.java +++ b/modules/database/database-sql-mariadb/src/main/java/org/eclipse/dirigible/database/sql/dialects/mariadb/MariaDBSqlDialect.java @@ -9,6 +9,11 @@ */ package org.eclipse.dirigible.database.sql.dialects.mariadb; +import org.eclipse.dirigible.database.sql.ISqlKeywords; +import org.eclipse.dirigible.database.sql.builders.AlterBranchingBuilder; +import org.eclipse.dirigible.database.sql.builders.records.InsertBuilder; +import org.eclipse.dirigible.database.sql.dialects.DefaultSqlDialect; + import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.ResultSet; @@ -17,10 +22,6 @@ import java.util.Collections; import java.util.HashSet; import java.util.Set; -import org.eclipse.dirigible.database.sql.ISqlKeywords; -import org.eclipse.dirigible.database.sql.builders.AlterBranchingBuilder; -import org.eclipse.dirigible.database.sql.builders.records.InsertBuilder; -import org.eclipse.dirigible.database.sql.dialects.DefaultSqlDialect; /** * The MariaDB SQL Dialect. @@ -46,7 +47,8 @@ public class MariaDBSqlDialect extends "HOUR", "LAST_DAY", "LOCALTIME", "LOCALTIMESTAMP", "MAKEDATE", "MAKETIME", "MICROSECOND", "MINUTE", "MONTH", "MONTHNAME", "NOW", "PERIOD_ADD", "PERIOD_DIFF", "QUARTER", "SECOND", "SEC_TO_TIME", "STR_TO_DATE", "SUBDATE", "SUBTIME", "SYSDATE", "TIMEDIFF", "TIMESTAMPADD", "TIMESTAMPDIFF", "TIME_FORMAT", "TIME_TO_SEC", "TO_DAYS", "TO_SECONDS", "UNIX_TIMESTAMP", "UTC_DATE", - "UTC_TIME", "UTC_TIMESTAMP", "WEEK", "WEEKDAY", "WEEKOFYEAR", "YEAR", "YEARWEEK", "COUNT"))); + "UTC_TIME", "UTC_TIMESTAMP", "WEEK", "WEEKDAY", "WEEKOFYEAR", "YEAR", "YEARWEEK", "COUNT", "AND", "OR", "BETWEEN", "IS", "NOT", + "NULL", "AVG", "MAX", "MIN"))); /** * Creates the. @@ -124,10 +126,7 @@ public boolean existsTable(Connection connection, String table) throws SQLExcept DatabaseMetaData metadata = connection.getMetaData(); ResultSet resultSet = metadata.getTables(null, null, DefaultSqlDialect.normalizeTableName(table.toUpperCase()), ISqlKeywords.METADATA_TABLE_TYPES.toArray(new String[] {})); - if (resultSet.next()) { - return true; - } - return false; + return resultSet.next(); } /** @@ -146,8 +145,8 @@ public Set getFunctionsNames() { * @return the escape symbol */ @Override - public String getEscapeSymbol() { - return "`"; + public char getEscapeSymbol() { + return '`'; } @Override diff --git a/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/CreateTableTest.java b/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/CreateTableTest.java index 9b8e186f182..d390137e769 100644 --- a/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/CreateTableTest.java +++ b/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/CreateTableTest.java @@ -9,15 +9,14 @@ */ package org.eclipse.dirigible.database.sql.dialects.mariadb; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.DataType; import org.eclipse.dirigible.database.sql.Modifiers; import org.eclipse.dirigible.database.sql.SqlFactory; -import org.eclipse.dirigible.database.sql.dialects.mariadb.MariaDBSqlDialect; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class CreateTableTest. */ @@ -38,7 +37,7 @@ public void createTableGeneric() { assertNotNull(sql); assertEquals( - "CREATE TABLE CUSTOMERS ( ID INTEGER NOT NULL PRIMARY KEY , FIRST_NAME VARCHAR (20) NOT NULL UNIQUE , LAST_NAME VARCHAR (30) )", + "CREATE TABLE `CUSTOMERS` ( `ID` INTEGER NOT NULL PRIMARY KEY , `FIRST_NAME` VARCHAR (20) NOT NULL UNIQUE , `LAST_NAME` VARCHAR (30) )", sql); } @@ -56,7 +55,8 @@ public void createTableTypeSafe() { .build(); assertNotNull(sql); - assertEquals("CREATE TABLE CUSTOMERS ( ID INTEGER NOT NULL PRIMARY KEY , FIRST_NAME VARCHAR (20) UNIQUE , LAST_NAME VARCHAR (30) )", + assertEquals( + "CREATE TABLE `CUSTOMERS` ( `ID` INTEGER NOT NULL PRIMARY KEY , `FIRST_NAME` VARCHAR (20) UNIQUE , `LAST_NAME` VARCHAR (30) )", sql); } @@ -65,15 +65,15 @@ public void createTableTypeSafe() { */ @Test public void createTableWithEscapedTableName() { - String sql = SqlFactory.getDefault() + String sql = SqlFactory.getNative(new MariaDBSqlDialect()) .create() - .table("'CUSTOMER'") + .table("`CUSTOMER`") .column("FIRST_NAME", DataType.VARCHAR, Modifiers.REGULAR, Modifiers.NULLABLE, Modifiers.NON_UNIQUE, "(20)") .column("LAST_NAME", DataType.VARCHAR, Modifiers.REGULAR, Modifiers.NULLABLE, Modifiers.NON_UNIQUE, "(30)") .build(); assertNotNull(sql); - assertEquals("CREATE TABLE 'CUSTOMER' ( FIRST_NAME VARCHAR (20) , LAST_NAME VARCHAR (30) )", sql); + assertEquals("CREATE TABLE `CUSTOMER` ( `FIRST_NAME` VARCHAR (20) , `LAST_NAME` VARCHAR (30) )", sql); } /** @@ -81,7 +81,7 @@ public void createTableWithEscapedTableName() { */ @Test public void createTableWithEscapedTableNameAndSchema() { - String sql = SqlFactory.getDefault() + String sql = SqlFactory.getNative(new MariaDBSqlDialect()) .create() .table("`DBADMIN`.`hdbtable-itest::compatible-length-change-hana`") .column("FIRST_NAME", DataType.VARCHAR, Modifiers.REGULAR, Modifiers.NULLABLE, Modifiers.NON_UNIQUE, "(20)") @@ -90,7 +90,7 @@ public void createTableWithEscapedTableNameAndSchema() { assertNotNull(sql); assertEquals( - "CREATE TABLE `DBADMIN`.`hdbtable-itest::compatible-length-change-hana` ( FIRST_NAME VARCHAR (20) , LAST_NAME VARCHAR (30) )", + "CREATE TABLE `DBADMIN`.`hdbtable-itest::compatible-length-change-hana` ( `FIRST_NAME` VARCHAR (20) , `LAST_NAME` VARCHAR (30) )", sql); } diff --git a/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/CreateViewTest.java b/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/CreateViewTest.java index 1051dba1d61..c43fa2b06e4 100644 --- a/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/CreateViewTest.java +++ b/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/CreateViewTest.java @@ -9,13 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.mariadb; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; -import org.eclipse.dirigible.database.sql.dialects.mariadb.MariaDBSqlDialect; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class CreateViewTest. */ @@ -33,7 +32,7 @@ public void createViewAsSelect() { .column("ID") .column("FIRST_NAME") .column("LAST_NAME") - .asSelect(SqlFactory.getDefault() + .asSelect(SqlFactory.getNative(new MariaDBSqlDialect()) .select() .column("*") .from("CUSTOMERS") @@ -41,7 +40,7 @@ public void createViewAsSelect() { .build(); assertNotNull(sql); - assertEquals("CREATE VIEW CUSTOMERS_VIEW ( ID , FIRST_NAME , LAST_NAME ) AS SELECT * FROM CUSTOMERS", sql); + assertEquals("CREATE VIEW `CUSTOMERS_VIEW` ( `ID` , `FIRST_NAME` , `LAST_NAME` ) AS SELECT * FROM `CUSTOMERS`", sql); } } diff --git a/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/DeleteTest.java b/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/DeleteTest.java index 605a2c6deb6..c27d0c95f61 100644 --- a/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/DeleteTest.java +++ b/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/DeleteTest.java @@ -9,13 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.mariadb; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; -import org.eclipse.dirigible.database.sql.dialects.mariadb.MariaDBSqlDialect; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class DeleteTest. */ @@ -32,7 +31,7 @@ public void deleteSimple() { .build(); assertNotNull(sql); - assertEquals("DELETE FROM CUSTOMERS", sql); + assertEquals("DELETE FROM `CUSTOMERS`", sql); } /** @@ -48,7 +47,7 @@ public void deleteWhere() { .build(); assertNotNull(sql); - assertEquals("DELETE FROM CUSTOMERS WHERE (AGE > ?) AND (COMPANY = 'SAP')", sql); + assertEquals("DELETE FROM `CUSTOMERS` WHERE (`AGE` > ?) AND (`COMPANY` = 'SAP')", sql); } } diff --git a/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/DropTableTest.java b/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/DropTableTest.java index 7e07c6169db..36229bbe638 100644 --- a/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/DropTableTest.java +++ b/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/DropTableTest.java @@ -9,13 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.mariadb; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; -import org.eclipse.dirigible.database.sql.dialects.mariadb.MariaDBSqlDialect; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class DropTableTest. */ @@ -32,8 +31,7 @@ public void dropTable() { .build(); assertNotNull(sql); - assertEquals("DROP TABLE CUSTOMERS", sql); + assertEquals("DROP TABLE `CUSTOMERS`", sql); } - } diff --git a/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/DropViewTest.java b/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/DropViewTest.java index 166162195b5..597224d45a1 100644 --- a/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/DropViewTest.java +++ b/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/DropViewTest.java @@ -9,13 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.mariadb; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; -import org.eclipse.dirigible.database.sql.dialects.mariadb.MariaDBSqlDialect; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class DropViewTest. */ @@ -32,7 +31,7 @@ public void dropView() { .build(); assertNotNull(sql); - assertEquals("DROP VIEW CUSTOMERS_VIEW", sql); + assertEquals("DROP VIEW `CUSTOMERS_VIEW`", sql); } } diff --git a/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/InsertTest.java b/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/InsertTest.java index 9bb5258f9ba..487d605a351 100644 --- a/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/InsertTest.java +++ b/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/InsertTest.java @@ -9,13 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.mariadb; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; -import org.eclipse.dirigible.database.sql.dialects.mariadb.MariaDBSqlDialect; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class InsertTest. */ @@ -34,7 +33,7 @@ public void insertSimple() { .build(); assertNotNull(sql); - assertEquals("INSERT INTO CUSTOMERS (FIRST_NAME, LAST_NAME) VALUES (?, ?)", sql); + assertEquals("INSERT INTO `CUSTOMERS` (`FIRST_NAME`, `LAST_NAME`) VALUES (?, ?)", sql); } /** @@ -52,7 +51,7 @@ public void insertValues() { .build(); assertNotNull(sql); - assertEquals("INSERT INTO CUSTOMERS (FIRST_NAME, LAST_NAME) VALUES (?, 'Smith')", sql); + assertEquals("INSERT INTO `CUSTOMERS` (`FIRST_NAME`, `LAST_NAME`) VALUES (?, 'Smith')", sql); } /** @@ -73,7 +72,7 @@ public void insertSelect() { .toString(); assertNotNull(sql); - assertEquals("INSERT INTO CUSTOMERS (FIRST_NAME, LAST_NAME) SELECT * FROM SUPPLIERS", sql); + assertEquals("INSERT INTO `CUSTOMERS` (`FIRST_NAME`, `LAST_NAME`) SELECT * FROM `SUPPLIERS`", sql); } } diff --git a/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/SelectTest.java b/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/SelectTest.java index e99f3dbe1e0..6cbecb0843b 100644 --- a/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/SelectTest.java +++ b/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/SelectTest.java @@ -9,13 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.mariadb; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; -import org.eclipse.dirigible.database.sql.dialects.mariadb.MariaDBSqlDialect; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class SelectTest. */ @@ -33,7 +32,7 @@ public void selectStar() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS", sql); + assertEquals("SELECT * FROM `CUSTOMERS`", sql); } /** @@ -49,7 +48,7 @@ public void selectColumnsFromTable() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS", sql); + assertEquals("SELECT `FIRST_NAME`, `LAST_NAME` FROM `CUSTOMERS`", sql); } /** @@ -65,7 +64,7 @@ public void selectColumnsFromTableAliases() { .build(); assertNotNull(sql); - assertEquals("SELECT c.FIRST_NAME, c.LAST_NAME FROM CUSTOMERS AS c", sql); + assertEquals("SELECT `c`.`FIRST_NAME`, `c`.`LAST_NAME` FROM `CUSTOMERS` AS `c`", sql); } /** @@ -82,7 +81,9 @@ public void selectColumnsFromTableJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS INNER JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT `FIRST_NAME`, `LAST_NAME` FROM `CUSTOMERS` INNER JOIN `ADDRESSES` ON `CUSTOMERS`.`ADDRESS_ID`=`ADDRESSES`.`ADDRESS_ID`", + sql); } /** @@ -99,7 +100,9 @@ public void selectColumnsFromTableInnerJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS INNER JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT `FIRST_NAME`, `LAST_NAME` FROM `CUSTOMERS` INNER JOIN `ADDRESSES` ON `CUSTOMERS`.`ADDRESS_ID`=`ADDRESSES`.`ADDRESS_ID`", + sql); } /** @@ -116,7 +119,9 @@ public void selectColumnsFromTableOuterJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS OUTER JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT `FIRST_NAME`, `LAST_NAME` FROM `CUSTOMERS` OUTER JOIN `ADDRESSES` ON `CUSTOMERS`.`ADDRESS_ID`=`ADDRESSES`.`ADDRESS_ID`", + sql); } /** @@ -133,7 +138,9 @@ public void selectColumnsFromTableLeftJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS LEFT JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT `FIRST_NAME`, `LAST_NAME` FROM `CUSTOMERS` LEFT JOIN `ADDRESSES` ON `CUSTOMERS`.`ADDRESS_ID`=`ADDRESSES`.`ADDRESS_ID`", + sql); } /** @@ -150,7 +157,9 @@ public void selectColumnsFromTableRightJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS RIGHT JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT `FIRST_NAME`, `LAST_NAME` FROM `CUSTOMERS` RIGHT JOIN `ADDRESSES` ON `CUSTOMERS`.`ADDRESS_ID`=`ADDRESSES`.`ADDRESS_ID`", + sql); } /** @@ -167,7 +176,9 @@ public void selectColumnsFromTableFullJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS FULL JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT `FIRST_NAME`, `LAST_NAME` FROM `CUSTOMERS` FULL JOIN `ADDRESSES` ON `CUSTOMERS`.`ADDRESS_ID`=`ADDRESSES`.`ADDRESS_ID`", + sql); } /** @@ -184,7 +195,7 @@ public void selectDistinctColumnsFromTable() { .build(); assertNotNull(sql); - assertEquals("SELECT DISTINCT FIRST_NAME, LAST_NAME FROM CUSTOMERS", sql); + assertEquals("SELECT DISTINCT `FIRST_NAME`, `LAST_NAME` FROM `CUSTOMERS`", sql); } /** @@ -202,7 +213,7 @@ public void selectColumnsFromTableOrderByAndDesc() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS ORDER BY FIRST_NAME ASC, LAST_NAME DESC", sql); + assertEquals("SELECT `FIRST_NAME`, `LAST_NAME` FROM `CUSTOMERS` ORDER BY `FIRST_NAME` ASC, `LAST_NAME` DESC", sql); } /** @@ -219,7 +230,7 @@ public void selectColumnsFromTableGroupBy() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS GROUP BY FIRST_NAME", sql); + assertEquals("SELECT `FIRST_NAME`, `LAST_NAME` FROM `CUSTOMERS` GROUP BY `FIRST_NAME`", sql); } /** @@ -235,7 +246,7 @@ public void selectWhereSimple() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS WHERE (PRICE > ?)", sql); + assertEquals("SELECT * FROM `CUSTOMERS` WHERE (`PRICE` > ?)", sql); } /** @@ -252,7 +263,7 @@ public void selectWhereAnd() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS WHERE (PRICE > ?) AND (AMOUNT < ?)", sql); + assertEquals("SELECT * FROM `CUSTOMERS` WHERE (`PRICE` > ?) AND (`AMOUNT` < ?)", sql); } /** @@ -268,7 +279,7 @@ public void selectWhereOr() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS WHERE (PRICE > ? OR AMOUNT < ?)", sql); + assertEquals("SELECT * FROM `CUSTOMERS` WHERE (`PRICE` > ? OR `AMOUNT` < ?)", sql); } /** @@ -288,7 +299,7 @@ public void selectWhereExpr() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS WHERE (PRICE > ? OR AMOUNT < ?)", sql); + assertEquals("SELECT * FROM `CUSTOMERS` WHERE (`PRICE` > ? OR `AMOUNT` < ?)", sql); } /** @@ -304,7 +315,7 @@ public void selectLimit() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS LIMIT 10", sql); + assertEquals("SELECT * FROM `CUSTOMERS` LIMIT 10", sql); } /** @@ -321,7 +332,7 @@ public void selectLimitOffset() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS LIMIT 10 OFFSET 20", sql); + assertEquals("SELECT * FROM `CUSTOMERS` LIMIT 10 OFFSET 20", sql); } /** @@ -339,7 +350,7 @@ public void selectHaving() { .build(); assertNotNull(sql); - assertEquals("SELECT COUNT(FIRST_NAME), COUNTRY FROM CUSTOMERS GROUP BY COUNTRY HAVING COUNT(FIRST_NAME) > 5", sql); + assertEquals("SELECT COUNT(`FIRST_NAME`), `COUNTRY` FROM `CUSTOMERS` GROUP BY `COUNTRY` HAVING COUNT(`FIRST_NAME`) > 5", sql); } /** @@ -359,7 +370,7 @@ public void selectUnion() { .build(); assertNotNull(sql); - assertEquals("SELECT COUNTRY FROM CUSTOMERS UNION SELECT COUNTRY FROM SUPPLIERS", sql); + assertEquals("SELECT `COUNTRY` FROM `CUSTOMERS` UNION SELECT `COUNTRY` FROM `SUPPLIERS`", sql); } } diff --git a/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/SequenceTest.java b/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/SequenceTest.java index 73dcf7131de..7b984ec7399 100644 --- a/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/SequenceTest.java +++ b/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/SequenceTest.java @@ -9,12 +9,11 @@ */ package org.eclipse.dirigible.database.sql.dialects.mariadb; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.*; + /** * The Class SequenceTest. */ @@ -48,7 +47,7 @@ public void alterSequence() { .build(); assertNotNull(sql); - assertEquals("ALTER SEQUENCE CUSTOMERS_SEQUENCE", sql); + assertEquals("ALTER SEQUENCE `CUSTOMERS_SEQUENCE`", sql); } /** diff --git a/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/UpdateTest.java b/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/UpdateTest.java index 73c2fe481d9..161c54d4de6 100644 --- a/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/UpdateTest.java +++ b/modules/database/database-sql-mariadb/src/test/java/org/eclipse/dirigible/database/sql/dialects/mariadb/UpdateTest.java @@ -9,13 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.mariadb; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; -import org.eclipse.dirigible.database.sql.dialects.mariadb.MariaDBSqlDialect; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class UpdateTest. */ @@ -33,7 +32,7 @@ public void updateSimple() { .build(); assertNotNull(sql); - assertEquals("UPDATE CUSTOMERS SET FIRST_NAME = 'John'", sql); + assertEquals("UPDATE `CUSTOMERS` SET `FIRST_NAME` = 'John'", sql); } /** @@ -49,7 +48,7 @@ public void updateValues() { .build(); assertNotNull(sql); - assertEquals("UPDATE CUSTOMERS SET FIRST_NAME = 'John', LAST_NAME = 'Smith'", sql); + assertEquals("UPDATE `CUSTOMERS` SET `FIRST_NAME` = 'John', `LAST_NAME` = 'Smith'", sql); } /** @@ -67,7 +66,7 @@ public void updateWhere() { .build(); assertNotNull(sql); - assertEquals("UPDATE CUSTOMERS SET FIRST_NAME = 'John', LAST_NAME = 'Smith' WHERE (AGE > ?) AND (COMPANY = 'SAP')", sql); + assertEquals("UPDATE `CUSTOMERS` SET `FIRST_NAME` = 'John', `LAST_NAME` = 'Smith' WHERE (`AGE` > ?) AND (`COMPANY` = 'SAP')", sql); } /** @@ -88,7 +87,9 @@ public void updateWhereSelect() { .build(); assertNotNull(sql); - assertEquals("UPDATE CUSTOMERS SET FIRST_NAME = 'John', SALARY = SELECT MAX(SALARY) FROM BENEFITS WHERE (COMPANY = 'SAP')", sql); + assertEquals( + "UPDATE `CUSTOMERS` SET `FIRST_NAME` = 'John', `SALARY` = SELECT MAX(`SALARY`) FROM `BENEFITS` WHERE (`COMPANY` = 'SAP')", + sql); } /** @@ -110,7 +111,8 @@ public void updateWhereExpr() { .build(); assertNotNull(sql); - assertEquals("UPDATE CUSTOMERS SET FIRST_NAME = 'John', LAST_NAME = 'Smith' WHERE (PRICE > ? OR AMOUNT < ? AND COMPANY = 'SAP')", + assertEquals( + "UPDATE `CUSTOMERS` SET `FIRST_NAME` = 'John', `LAST_NAME` = 'Smith' WHERE (`PRICE` > ? OR `AMOUNT` < ? AND `COMPANY` = 'SAP')", sql); } diff --git a/modules/database/database-sql-mysql/src/main/java/org/eclipse/dirigible/database/sql/dialects/mysql/MySQLSqlDialect.java b/modules/database/database-sql-mysql/src/main/java/org/eclipse/dirigible/database/sql/dialects/mysql/MySQLSqlDialect.java index c6f55eda381..ebfd81d3f55 100644 --- a/modules/database/database-sql-mysql/src/main/java/org/eclipse/dirigible/database/sql/dialects/mysql/MySQLSqlDialect.java +++ b/modules/database/database-sql-mysql/src/main/java/org/eclipse/dirigible/database/sql/dialects/mysql/MySQLSqlDialect.java @@ -47,7 +47,8 @@ public class MySQLSqlDialect extends "HOUR", "LAST_DAY", "LOCALTIME", "LOCALTIMESTAMP", "MAKEDATE", "MAKETIME", "MICROSECOND", "MINUTE", "MONTH", "MONTHNAME", "NOW", "PERIOD_ADD", "PERIOD_DIFF", "QUARTER", "SECOND", "SEC_TO_TIME", "STR_TO_DATE", "SUBDATE", "SUBTIME", "SYSDATE", "TIMEDIFF", "TIMESTAMPADD", "TIMESTAMPDIFF", "TIME_FORMAT", "TIME_TO_SEC", "TO_DAYS", "TO_SECONDS", "UNIX_TIMESTAMP", "UTC_DATE", - "UTC_TIME", "UTC_TIMESTAMP", "WEEK", "WEEKDAY", "WEEKOFYEAR", "YEAR", "YEARWEEK", "COUNT"))); + "UTC_TIME", "UTC_TIMESTAMP", "WEEK", "WEEKDAY", "WEEKOFYEAR", "YEAR", "YEARWEEK", "COUNT", "AND", "OR", "BETWEEN", "IS", "NOT", + "NULL", "AVG", "MAX", "MIN"))); /** * Creates the. @@ -125,10 +126,7 @@ public boolean existsTable(Connection connection, String table) throws SQLExcept DatabaseMetaData metadata = connection.getMetaData(); ResultSet resultSet = metadata.getTables(null, null, DefaultSqlDialect.normalizeTableName(table.toUpperCase()), ISqlKeywords.METADATA_TABLE_TYPES.toArray(new String[] {})); - if (resultSet.next()) { - return true; - } - return false; + return resultSet.next(); } /** @@ -147,8 +145,8 @@ public Set getFunctionsNames() { * @return the escape symbol */ @Override - public String getEscapeSymbol() { - return "`"; + public char getEscapeSymbol() { + return '`'; } @Override diff --git a/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/CreateTableTest.java b/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/CreateTableTest.java index 4a579d82c7f..fa225bf7a7b 100644 --- a/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/CreateTableTest.java +++ b/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/CreateTableTest.java @@ -9,14 +9,14 @@ */ package org.eclipse.dirigible.database.sql.dialects.mysql; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.DataType; import org.eclipse.dirigible.database.sql.Modifiers; import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class CreateTableTest. */ @@ -37,7 +37,7 @@ public void createTableGeneric() { assertNotNull(sql); assertEquals( - "CREATE TABLE CUSTOMERS ( ID INTEGER NOT NULL PRIMARY KEY , FIRST_NAME VARCHAR (20) NOT NULL UNIQUE , LAST_NAME VARCHAR (30) )", + "CREATE TABLE `CUSTOMERS` ( `ID` INTEGER NOT NULL PRIMARY KEY , `FIRST_NAME` VARCHAR (20) NOT NULL UNIQUE , `LAST_NAME` VARCHAR (30) )", sql); } @@ -55,7 +55,8 @@ public void createTableTypeSafe() { .build(); assertNotNull(sql); - assertEquals("CREATE TABLE CUSTOMERS ( ID INTEGER NOT NULL PRIMARY KEY , FIRST_NAME VARCHAR (20) UNIQUE , LAST_NAME VARCHAR (30) )", + assertEquals( + "CREATE TABLE `CUSTOMERS` ( `ID` INTEGER NOT NULL PRIMARY KEY , `FIRST_NAME` VARCHAR (20) UNIQUE , `LAST_NAME` VARCHAR (30) )", sql); } @@ -64,15 +65,15 @@ public void createTableTypeSafe() { */ @Test public void createTableWithEscapedTableName() { - String sql = SqlFactory.getDefault() + String sql = SqlFactory.getNative(new MySQLSqlDialect()) .create() - .table("'CUSTOMER'") + .table("`CUSTOMER`") .column("FIRST_NAME", DataType.VARCHAR, Modifiers.REGULAR, Modifiers.NULLABLE, Modifiers.NON_UNIQUE, "(20)") .column("LAST_NAME", DataType.VARCHAR, Modifiers.REGULAR, Modifiers.NULLABLE, Modifiers.NON_UNIQUE, "(30)") .build(); assertNotNull(sql); - assertEquals("CREATE TABLE 'CUSTOMER' ( FIRST_NAME VARCHAR (20) , LAST_NAME VARCHAR (30) )", sql); + assertEquals("CREATE TABLE `CUSTOMER` ( `FIRST_NAME` VARCHAR (20) , `LAST_NAME` VARCHAR (30) )", sql); } /** @@ -80,7 +81,7 @@ public void createTableWithEscapedTableName() { */ @Test public void createTableWithEscapedTableNameAndSchema() { - String sql = SqlFactory.getDefault() + String sql = SqlFactory.getNative(new MySQLSqlDialect()) .create() .table("`DBADMIN`.`hdbtable-itest::compatible-length-change-hana`") .column("FIRST_NAME", DataType.VARCHAR, Modifiers.REGULAR, Modifiers.NULLABLE, Modifiers.NON_UNIQUE, "(20)") @@ -89,7 +90,7 @@ public void createTableWithEscapedTableNameAndSchema() { assertNotNull(sql); assertEquals( - "CREATE TABLE `DBADMIN`.`hdbtable-itest::compatible-length-change-hana` ( FIRST_NAME VARCHAR (20) , LAST_NAME VARCHAR (30) )", + "CREATE TABLE `DBADMIN`.`hdbtable-itest::compatible-length-change-hana` ( `FIRST_NAME` VARCHAR (20) , `LAST_NAME` VARCHAR (30) )", sql); } diff --git a/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/CreateViewTest.java b/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/CreateViewTest.java index 363619ae92c..c700f9e14bd 100644 --- a/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/CreateViewTest.java +++ b/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/CreateViewTest.java @@ -9,12 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.mysql; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class CreateViewTest. */ @@ -32,7 +32,7 @@ public void createViewAsSelect() { .column("ID") .column("FIRST_NAME") .column("LAST_NAME") - .asSelect(SqlFactory.getDefault() + .asSelect(SqlFactory.getNative(new MySQLSqlDialect()) .select() .column("*") .from("CUSTOMERS") @@ -40,7 +40,7 @@ public void createViewAsSelect() { .build(); assertNotNull(sql); - assertEquals("CREATE VIEW CUSTOMERS_VIEW ( ID , FIRST_NAME , LAST_NAME ) AS SELECT * FROM CUSTOMERS", sql); + assertEquals("CREATE VIEW `CUSTOMERS_VIEW` ( `ID` , `FIRST_NAME` , `LAST_NAME` ) AS SELECT * FROM `CUSTOMERS`", sql); } } diff --git a/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/DeleteTest.java b/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/DeleteTest.java index 06a7d7a6930..614ebc0d930 100644 --- a/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/DeleteTest.java +++ b/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/DeleteTest.java @@ -9,12 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.mysql; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class DeleteTest. */ @@ -31,7 +31,7 @@ public void deleteSimple() { .build(); assertNotNull(sql); - assertEquals("DELETE FROM CUSTOMERS", sql); + assertEquals("DELETE FROM `CUSTOMERS`", sql); } /** @@ -47,7 +47,7 @@ public void deleteWhere() { .build(); assertNotNull(sql); - assertEquals("DELETE FROM CUSTOMERS WHERE (AGE > ?) AND (COMPANY = 'SAP')", sql); + assertEquals("DELETE FROM `CUSTOMERS` WHERE (`AGE` > ?) AND (`COMPANY` = 'SAP')", sql); } } diff --git a/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/DropTableTest.java b/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/DropTableTest.java index ad14ccd75e5..1d057d7d0e9 100644 --- a/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/DropTableTest.java +++ b/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/DropTableTest.java @@ -9,12 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.mysql; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class DropTableTest. */ @@ -31,8 +31,7 @@ public void dropTable() { .build(); assertNotNull(sql); - assertEquals("DROP TABLE CUSTOMERS", sql); + assertEquals("DROP TABLE `CUSTOMERS`", sql); } - } diff --git a/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/DropViewTest.java b/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/DropViewTest.java index 5ecfc19125d..67cc765d2dc 100644 --- a/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/DropViewTest.java +++ b/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/DropViewTest.java @@ -9,12 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.mysql; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class DropViewTest. */ @@ -31,7 +31,7 @@ public void dropView() { .build(); assertNotNull(sql); - assertEquals("DROP VIEW CUSTOMERS_VIEW", sql); + assertEquals("DROP VIEW `CUSTOMERS_VIEW`", sql); } } diff --git a/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/InsertTest.java b/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/InsertTest.java index 6059861da41..2b4685721ae 100644 --- a/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/InsertTest.java +++ b/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/InsertTest.java @@ -9,12 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.mysql; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class InsertTest. */ @@ -33,7 +33,7 @@ public void insertSimple() { .build(); assertNotNull(sql); - assertEquals("INSERT INTO CUSTOMERS (FIRST_NAME, LAST_NAME) VALUES (?, ?)", sql); + assertEquals("INSERT INTO `CUSTOMERS` (`FIRST_NAME`, `LAST_NAME`) VALUES (?, ?)", sql); } /** @@ -51,7 +51,7 @@ public void insertValues() { .build(); assertNotNull(sql); - assertEquals("INSERT INTO CUSTOMERS (FIRST_NAME, LAST_NAME) VALUES (?, 'Smith')", sql); + assertEquals("INSERT INTO `CUSTOMERS` (`FIRST_NAME`, `LAST_NAME`) VALUES (?, 'Smith')", sql); } /** @@ -72,7 +72,7 @@ public void insertSelect() { .toString(); assertNotNull(sql); - assertEquals("INSERT INTO CUSTOMERS (FIRST_NAME, LAST_NAME) SELECT * FROM SUPPLIERS", sql); + assertEquals("INSERT INTO `CUSTOMERS` (`FIRST_NAME`, `LAST_NAME`) SELECT * FROM `SUPPLIERS`", sql); } } diff --git a/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/SelectTest.java b/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/SelectTest.java index 390d2d87f93..0589d7d0b7e 100644 --- a/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/SelectTest.java +++ b/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/SelectTest.java @@ -9,12 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.mysql; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class SelectTest. */ @@ -32,7 +32,7 @@ public void selectStar() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS", sql); + assertEquals("SELECT * FROM `CUSTOMERS`", sql); } /** @@ -48,7 +48,7 @@ public void selectColumnsFromTable() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS", sql); + assertEquals("SELECT `FIRST_NAME`, `LAST_NAME` FROM `CUSTOMERS`", sql); } /** @@ -64,7 +64,7 @@ public void selectColumnsFromTableAliases() { .build(); assertNotNull(sql); - assertEquals("SELECT c.FIRST_NAME, c.LAST_NAME FROM CUSTOMERS AS c", sql); + assertEquals("SELECT `c`.`FIRST_NAME`, `c`.`LAST_NAME` FROM `CUSTOMERS` AS `c`", sql); } /** @@ -81,7 +81,9 @@ public void selectColumnsFromTableJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS INNER JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT `FIRST_NAME`, `LAST_NAME` FROM `CUSTOMERS` INNER JOIN `ADDRESSES` ON `CUSTOMERS`.`ADDRESS_ID`=`ADDRESSES`.`ADDRESS_ID`", + sql); } /** @@ -98,7 +100,9 @@ public void selectColumnsFromTableInnerJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS INNER JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT `FIRST_NAME`, `LAST_NAME` FROM `CUSTOMERS` INNER JOIN `ADDRESSES` ON `CUSTOMERS`.`ADDRESS_ID`=`ADDRESSES`.`ADDRESS_ID`", + sql); } /** @@ -115,7 +119,9 @@ public void selectColumnsFromTableOuterJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS OUTER JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT `FIRST_NAME`, `LAST_NAME` FROM `CUSTOMERS` OUTER JOIN `ADDRESSES` ON `CUSTOMERS`.`ADDRESS_ID`=`ADDRESSES`.`ADDRESS_ID`", + sql); } /** @@ -132,7 +138,9 @@ public void selectColumnsFromTableLeftJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS LEFT JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT `FIRST_NAME`, `LAST_NAME` FROM `CUSTOMERS` LEFT JOIN `ADDRESSES` ON `CUSTOMERS`.`ADDRESS_ID`=`ADDRESSES`.`ADDRESS_ID`", + sql); } /** @@ -149,7 +157,9 @@ public void selectColumnsFromTableRightJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS RIGHT JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT `FIRST_NAME`, `LAST_NAME` FROM `CUSTOMERS` RIGHT JOIN `ADDRESSES` ON `CUSTOMERS`.`ADDRESS_ID`=`ADDRESSES`.`ADDRESS_ID`", + sql); } /** @@ -166,7 +176,9 @@ public void selectColumnsFromTableFullJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS FULL JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT `FIRST_NAME`, `LAST_NAME` FROM `CUSTOMERS` FULL JOIN `ADDRESSES` ON `CUSTOMERS`.`ADDRESS_ID`=`ADDRESSES`.`ADDRESS_ID`", + sql); } /** @@ -183,7 +195,7 @@ public void selectDistinctColumnsFromTable() { .build(); assertNotNull(sql); - assertEquals("SELECT DISTINCT FIRST_NAME, LAST_NAME FROM CUSTOMERS", sql); + assertEquals("SELECT DISTINCT `FIRST_NAME`, `LAST_NAME` FROM `CUSTOMERS`", sql); } /** @@ -201,7 +213,7 @@ public void selectColumnsFromTableOrderByAndDesc() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS ORDER BY FIRST_NAME ASC, LAST_NAME DESC", sql); + assertEquals("SELECT `FIRST_NAME`, `LAST_NAME` FROM `CUSTOMERS` ORDER BY `FIRST_NAME` ASC, `LAST_NAME` DESC", sql); } /** @@ -218,7 +230,7 @@ public void selectColumnsFromTableGroupBy() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS GROUP BY FIRST_NAME", sql); + assertEquals("SELECT `FIRST_NAME`, `LAST_NAME` FROM `CUSTOMERS` GROUP BY `FIRST_NAME`", sql); } /** @@ -234,7 +246,7 @@ public void selectWhereSimple() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS WHERE (PRICE > ?)", sql); + assertEquals("SELECT * FROM `CUSTOMERS` WHERE (`PRICE` > ?)", sql); } /** @@ -251,7 +263,7 @@ public void selectWhereAnd() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS WHERE (PRICE > ?) AND (AMOUNT < ?)", sql); + assertEquals("SELECT * FROM `CUSTOMERS` WHERE (`PRICE` > ?) AND (`AMOUNT` < ?)", sql); } /** @@ -267,7 +279,7 @@ public void selectWhereOr() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS WHERE (PRICE > ? OR AMOUNT < ?)", sql); + assertEquals("SELECT * FROM `CUSTOMERS` WHERE (`PRICE` > ? OR `AMOUNT` < ?)", sql); } /** @@ -287,7 +299,7 @@ public void selectWhereExpr() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS WHERE (PRICE > ? OR AMOUNT < ?)", sql); + assertEquals("SELECT * FROM `CUSTOMERS` WHERE (`PRICE` > ? OR `AMOUNT` < ?)", sql); } /** @@ -303,7 +315,7 @@ public void selectLimit() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS LIMIT 10", sql); + assertEquals("SELECT * FROM `CUSTOMERS` LIMIT 10", sql); } /** @@ -320,7 +332,7 @@ public void selectLimitOffset() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS LIMIT 10 OFFSET 20", sql); + assertEquals("SELECT * FROM `CUSTOMERS` LIMIT 10 OFFSET 20", sql); } /** @@ -338,7 +350,7 @@ public void selectHaving() { .build(); assertNotNull(sql); - assertEquals("SELECT COUNT(FIRST_NAME), COUNTRY FROM CUSTOMERS GROUP BY COUNTRY HAVING COUNT(FIRST_NAME) > 5", sql); + assertEquals("SELECT COUNT(`FIRST_NAME`), `COUNTRY` FROM `CUSTOMERS` GROUP BY `COUNTRY` HAVING COUNT(`FIRST_NAME`) > 5", sql); } /** @@ -358,7 +370,7 @@ public void selectUnion() { .build(); assertNotNull(sql); - assertEquals("SELECT COUNTRY FROM CUSTOMERS UNION SELECT COUNTRY FROM SUPPLIERS", sql); + assertEquals("SELECT `COUNTRY` FROM `CUSTOMERS` UNION SELECT `COUNTRY` FROM `SUPPLIERS`", sql); } } diff --git a/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/SequenceTest.java b/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/SequenceTest.java index 71123fa4378..419256658fd 100644 --- a/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/SequenceTest.java +++ b/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/SequenceTest.java @@ -9,13 +9,11 @@ */ package org.eclipse.dirigible.database.sql.dialects.mysql; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.*; + /** * The Class SequenceTest. */ @@ -49,7 +47,7 @@ public void alterSequence() { .build(); assertNotNull(sql); - assertEquals("ALTER SEQUENCE CUSTOMERS_SEQUENCE", sql); + assertEquals("ALTER SEQUENCE `CUSTOMERS_SEQUENCE`", sql); } /** diff --git a/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/UpdateTest.java b/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/UpdateTest.java index fe557782c04..d2e4bcfbcb6 100644 --- a/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/UpdateTest.java +++ b/modules/database/database-sql-mysql/src/test/java/org/eclipse/dirigible/database/sql/dialects/mysql/UpdateTest.java @@ -9,12 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.mysql; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class UpdateTest. */ @@ -32,7 +32,7 @@ public void updateSimple() { .build(); assertNotNull(sql); - assertEquals("UPDATE CUSTOMERS SET FIRST_NAME = 'John'", sql); + assertEquals("UPDATE `CUSTOMERS` SET `FIRST_NAME` = 'John'", sql); } /** @@ -48,7 +48,7 @@ public void updateValues() { .build(); assertNotNull(sql); - assertEquals("UPDATE CUSTOMERS SET FIRST_NAME = 'John', LAST_NAME = 'Smith'", sql); + assertEquals("UPDATE `CUSTOMERS` SET `FIRST_NAME` = 'John', `LAST_NAME` = 'Smith'", sql); } /** @@ -66,7 +66,7 @@ public void updateWhere() { .build(); assertNotNull(sql); - assertEquals("UPDATE CUSTOMERS SET FIRST_NAME = 'John', LAST_NAME = 'Smith' WHERE (AGE > ?) AND (COMPANY = 'SAP')", sql); + assertEquals("UPDATE `CUSTOMERS` SET `FIRST_NAME` = 'John', `LAST_NAME` = 'Smith' WHERE (`AGE` > ?) AND (`COMPANY` = 'SAP')", sql); } /** @@ -87,7 +87,9 @@ public void updateWhereSelect() { .build(); assertNotNull(sql); - assertEquals("UPDATE CUSTOMERS SET FIRST_NAME = 'John', SALARY = SELECT MAX(SALARY) FROM BENEFITS WHERE (COMPANY = 'SAP')", sql); + assertEquals( + "UPDATE `CUSTOMERS` SET `FIRST_NAME` = 'John', `SALARY` = SELECT MAX(`SALARY`) FROM `BENEFITS` WHERE (`COMPANY` = 'SAP')", + sql); } /** @@ -109,7 +111,8 @@ public void updateWhereExpr() { .build(); assertNotNull(sql); - assertEquals("UPDATE CUSTOMERS SET FIRST_NAME = 'John', LAST_NAME = 'Smith' WHERE (PRICE > ? OR AMOUNT < ? AND COMPANY = 'SAP')", + assertEquals( + "UPDATE `CUSTOMERS` SET `FIRST_NAME` = 'John', `LAST_NAME` = 'Smith' WHERE (`PRICE` > ? OR `AMOUNT` < ? AND `COMPANY` = 'SAP')", sql); } diff --git a/modules/database/database-sql-postgres/src/main/java/org/eclipse/dirigible/database/sql/dialects/postgres/PostgresNextValueSequenceBuilder.java b/modules/database/database-sql-postgres/src/main/java/org/eclipse/dirigible/database/sql/dialects/postgres/PostgresNextValueSequenceBuilder.java index cffc347d698..6fcf9cff92d 100644 --- a/modules/database/database-sql-postgres/src/main/java/org/eclipse/dirigible/database/sql/dialects/postgres/PostgresNextValueSequenceBuilder.java +++ b/modules/database/database-sql-postgres/src/main/java/org/eclipse/dirigible/database/sql/dialects/postgres/PostgresNextValueSequenceBuilder.java @@ -9,11 +9,11 @@ */ package org.eclipse.dirigible.database.sql.dialects.postgres; -import static java.text.MessageFormat.format; - import org.eclipse.dirigible.database.sql.ISqlDialect; import org.eclipse.dirigible.database.sql.builders.sequence.NextValueSequenceBuilder; +import static java.text.MessageFormat.format; + /** * The PostgreSQL Next Value Sequence Builder. */ @@ -39,7 +39,7 @@ public PostgresNextValueSequenceBuilder(ISqlDialect dialect, String sequence) { */ @Override public String generate() { - String sequenceName = (isCaseSensitive()) ? encapsulate(this.getSequence(), true) : this.getSequence(); + String sequenceName = encapsulate(this.getSequence(), true); String sql = format(PATTERN_SELECT_NEXT_VAL_SEQUENCE, sequenceName); return sql; } diff --git a/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/CreateTableTest.java b/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/CreateTableTest.java index 24d366d47a4..c51aa062c31 100644 --- a/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/CreateTableTest.java +++ b/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/CreateTableTest.java @@ -9,13 +9,13 @@ */ package org.eclipse.dirigible.database.sql.dialects.postgres; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.DataType; import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class CreateTableTest. */ @@ -36,7 +36,7 @@ public void createTableGeneric() { assertNotNull(sql); assertEquals( - "CREATE TABLE CUSTOMERS ( ID INTEGER NOT NULL PRIMARY KEY , FIRST_NAME VARCHAR (20) NOT NULL UNIQUE , LAST_NAME VARCHAR (30) )", + "CREATE TABLE \"CUSTOMERS\" ( \"ID\" INTEGER NOT NULL PRIMARY KEY , \"FIRST_NAME\" VARCHAR (20) NOT NULL UNIQUE , \"LAST_NAME\" VARCHAR (30) )", sql); } @@ -54,7 +54,8 @@ public void createTableTypeSafe() { .build(); assertNotNull(sql); - assertEquals("CREATE TABLE CUSTOMERS ( ID INTEGER NOT NULL PRIMARY KEY , FIRST_NAME VARCHAR (20) UNIQUE , LAST_NAME VARCHAR (30) )", + assertEquals( + "CREATE TABLE \"CUSTOMERS\" ( \"ID\" INTEGER NOT NULL PRIMARY KEY , \"FIRST_NAME\" VARCHAR (20) UNIQUE , \"LAST_NAME\" VARCHAR (30) )", sql); } diff --git a/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/CreateViewTest.java b/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/CreateViewTest.java index f25cc6ca288..43410c3a75a 100644 --- a/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/CreateViewTest.java +++ b/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/CreateViewTest.java @@ -9,12 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.postgres; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class CreateViewTest. */ @@ -40,7 +40,7 @@ public void createViewAsSelect() { .build(); assertNotNull(sql); - assertEquals("CREATE VIEW CUSTOMERS_VIEW ( ID , FIRST_NAME , LAST_NAME ) AS SELECT * FROM CUSTOMERS", sql); + assertEquals("CREATE VIEW \"CUSTOMERS_VIEW\" ( \"ID\" , \"FIRST_NAME\" , \"LAST_NAME\" ) AS SELECT * FROM \"CUSTOMERS\"", sql); } /** @@ -56,7 +56,7 @@ public void createViewAsValues() { .build(); assertNotNull(sql); - assertEquals("CREATE VIEW STATES ( STATE ) AS VALUES 'STARTED', 'STOPPED', 'FAILED', 'IN PROCESS'", sql); + assertEquals("CREATE VIEW \"STATES\" ( \"STATE\" ) AS VALUES 'STARTED', 'STOPPED', 'FAILED', 'IN PROCESS'", sql); } } diff --git a/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/DeleteTest.java b/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/DeleteTest.java index 2b760fddd31..83c21b47e4a 100644 --- a/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/DeleteTest.java +++ b/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/DeleteTest.java @@ -9,12 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.postgres; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class DeleteTest. */ @@ -31,7 +31,7 @@ public void deleteSimple() { .build(); assertNotNull(sql); - assertEquals("DELETE FROM CUSTOMERS", sql); + assertEquals("DELETE FROM \"CUSTOMERS\"", sql); } /** @@ -47,7 +47,7 @@ public void deleteWhere() { .build(); assertNotNull(sql); - assertEquals("DELETE FROM CUSTOMERS WHERE (AGE > ?) AND (COMPANY = 'SAP')", sql); + assertEquals("DELETE FROM \"CUSTOMERS\" WHERE (\"AGE\" > ?) AND (\"COMPANY\" = 'SAP')", sql); } } diff --git a/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/DropTableTest.java b/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/DropTableTest.java index 5524f23dbd5..ea7c7bd5b58 100644 --- a/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/DropTableTest.java +++ b/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/DropTableTest.java @@ -9,12 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.postgres; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class DropTableTest. */ @@ -31,8 +31,7 @@ public void dropTable() { .build(); assertNotNull(sql); - assertEquals("DROP TABLE CUSTOMERS", sql); + assertEquals("DROP TABLE \"CUSTOMERS\"", sql); } - } diff --git a/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/DropViewTest.java b/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/DropViewTest.java index 352e7ecc35f..5f11461af70 100644 --- a/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/DropViewTest.java +++ b/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/DropViewTest.java @@ -9,12 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.postgres; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class DropViewTest. */ @@ -31,7 +31,7 @@ public void dropView() { .build(); assertNotNull(sql); - assertEquals("DROP VIEW CUSTOMERS_VIEW", sql); + assertEquals("DROP VIEW \"CUSTOMERS_VIEW\"", sql); } } diff --git a/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/InsertTest.java b/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/InsertTest.java index 9e8696304e3..3a8a0f60711 100644 --- a/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/InsertTest.java +++ b/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/InsertTest.java @@ -9,12 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.postgres; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class InsertTest. */ @@ -33,7 +33,7 @@ public void insertSimple() { .build(); assertNotNull(sql); - assertEquals("INSERT INTO CUSTOMERS (FIRST_NAME, LAST_NAME) VALUES (?, ?)", sql); + assertEquals("INSERT INTO \"CUSTOMERS\" (\"FIRST_NAME\", \"LAST_NAME\") VALUES (?, ?)", sql); } /** @@ -51,7 +51,7 @@ public void insertValues() { .build(); assertNotNull(sql); - assertEquals("INSERT INTO CUSTOMERS (FIRST_NAME, LAST_NAME) VALUES (?, 'Smith')", sql); + assertEquals("INSERT INTO \"CUSTOMERS\" (\"FIRST_NAME\", \"LAST_NAME\") VALUES (?, 'Smith')", sql); } /** @@ -72,7 +72,7 @@ public void insertSelect() { .build(); assertNotNull(sql); - assertEquals("INSERT INTO CUSTOMERS (FIRST_NAME, LAST_NAME) SELECT * FROM SUPPLIERS", sql); + assertEquals("INSERT INTO \"CUSTOMERS\" (\"FIRST_NAME\", \"LAST_NAME\") SELECT * FROM \"SUPPLIERS\"", sql); } } diff --git a/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/SelectTest.java b/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/SelectTest.java index 01d4e757e99..efec0ea4364 100644 --- a/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/SelectTest.java +++ b/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/SelectTest.java @@ -9,12 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.postgres; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class SelectTest. */ @@ -32,7 +32,7 @@ public void selectStar() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS", sql); + assertEquals("SELECT * FROM \"CUSTOMERS\"", sql); } /** @@ -48,7 +48,7 @@ public void selectColumnsFromTable() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS", sql); + assertEquals("SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\"", sql); } /** @@ -64,7 +64,7 @@ public void selectColumnsFromTableAliases() { .build(); assertNotNull(sql); - assertEquals("SELECT c.FIRST_NAME, c.LAST_NAME FROM CUSTOMERS AS c", sql); + assertEquals("SELECT \"c\".\"FIRST_NAME\", \"c\".\"LAST_NAME\" FROM \"CUSTOMERS\" AS \"c\"", sql); } /** @@ -81,7 +81,9 @@ public void selectColumnsFromTableJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS INNER JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\" INNER JOIN \"ADDRESSES\" ON \"CUSTOMERS\".\"ADDRESS_ID\"=\"ADDRESSES\".\"ADDRESS_ID\"", + sql); } /** @@ -98,7 +100,9 @@ public void selectColumnsFromTableInnerJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS INNER JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\" INNER JOIN \"ADDRESSES\" ON \"CUSTOMERS\".\"ADDRESS_ID\"=\"ADDRESSES\".\"ADDRESS_ID\"", + sql); } /** @@ -115,7 +119,9 @@ public void selectColumnsFromTableOuterJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS OUTER JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\" OUTER JOIN \"ADDRESSES\" ON \"CUSTOMERS\".\"ADDRESS_ID\"=\"ADDRESSES\".\"ADDRESS_ID\"", + sql); } /** @@ -132,7 +138,9 @@ public void selectColumnsFromTableLeftJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS LEFT JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\" LEFT JOIN \"ADDRESSES\" ON \"CUSTOMERS\".\"ADDRESS_ID\"=\"ADDRESSES\".\"ADDRESS_ID\"", + sql); } /** @@ -149,7 +157,9 @@ public void selectColumnsFromTableRightJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS RIGHT JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\" RIGHT JOIN \"ADDRESSES\" ON \"CUSTOMERS\".\"ADDRESS_ID\"=\"ADDRESSES\".\"ADDRESS_ID\"", + sql); } /** @@ -166,7 +176,9 @@ public void selectColumnsFromTableFullJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS FULL JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\" FULL JOIN \"ADDRESSES\" ON \"CUSTOMERS\".\"ADDRESS_ID\"=\"ADDRESSES\".\"ADDRESS_ID\"", + sql); } /** @@ -183,7 +195,7 @@ public void selectDistinctColumnsFromTable() { .build(); assertNotNull(sql); - assertEquals("SELECT DISTINCT FIRST_NAME, LAST_NAME FROM CUSTOMERS", sql); + assertEquals("SELECT DISTINCT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\"", sql); } /** @@ -201,7 +213,7 @@ public void selectColumnsFromTableOrderByAndDesc() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS ORDER BY FIRST_NAME ASC, LAST_NAME DESC", sql); + assertEquals("SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\" ORDER BY \"FIRST_NAME\" ASC, \"LAST_NAME\" DESC", sql); } /** @@ -218,7 +230,7 @@ public void selectColumnsFromTableGroupBy() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS GROUP BY FIRST_NAME", sql); + assertEquals("SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\" GROUP BY \"FIRST_NAME\"", sql); } /** @@ -234,7 +246,7 @@ public void selectWhereSimple() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS WHERE (PRICE > ?)", sql); + assertEquals("SELECT * FROM \"CUSTOMERS\" WHERE (\"PRICE\" > ?)", sql); } /** @@ -251,7 +263,7 @@ public void selectWhereAnd() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS WHERE (PRICE > ?) AND (AMOUNT < ?)", sql); + assertEquals("SELECT * FROM \"CUSTOMERS\" WHERE (\"PRICE\" > ?) AND (\"AMOUNT\" < ?)", sql); } /** @@ -267,7 +279,7 @@ public void selectWhereOr() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS WHERE (PRICE > ? OR AMOUNT < ?)", sql); + assertEquals("SELECT * FROM \"CUSTOMERS\" WHERE (\"PRICE\" > ? OR \"AMOUNT\" < ?)", sql); } /** @@ -287,7 +299,7 @@ public void selectWhereExpr() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS WHERE (PRICE > ? OR AMOUNT < ?)", sql); + assertEquals("SELECT * FROM \"CUSTOMERS\" WHERE (\"PRICE\" > ? OR \"AMOUNT\" < ?)", sql); } /** @@ -303,7 +315,7 @@ public void selectLimit() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS LIMIT 10", sql); + assertEquals("SELECT * FROM \"CUSTOMERS\" LIMIT 10", sql); } /** @@ -320,7 +332,7 @@ public void selectLimitOffset() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS LIMIT 10 OFFSET 20", sql); + assertEquals("SELECT * FROM \"CUSTOMERS\" LIMIT 10 OFFSET 20", sql); } /** @@ -338,7 +350,8 @@ public void selectHaving() { .build(); assertNotNull(sql); - assertEquals("SELECT COUNT(FIRST_NAME), COUNTRY FROM CUSTOMERS GROUP BY COUNTRY HAVING COUNT(FIRST_NAME) > 5", sql); + assertEquals("SELECT COUNT(\"FIRST_NAME\"), \"COUNTRY\" FROM \"CUSTOMERS\" GROUP BY \"COUNTRY\" HAVING COUNT(\"FIRST_NAME\") > 5", + sql); } /** @@ -358,7 +371,7 @@ public void selectUnion() { .build(); assertNotNull(sql); - assertEquals("SELECT COUNTRY FROM CUSTOMERS UNION SELECT COUNTRY FROM SUPPLIERS", sql); + assertEquals("SELECT \"COUNTRY\" FROM \"CUSTOMERS\" UNION SELECT \"COUNTRY\" FROM \"SUPPLIERS\"", sql); } } diff --git a/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/SequenceTest.java b/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/SequenceTest.java index 9a8775daa86..7806400c91f 100644 --- a/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/SequenceTest.java +++ b/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/SequenceTest.java @@ -9,12 +9,11 @@ */ package org.eclipse.dirigible.database.sql.dialects.postgres; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; /** * The Class SequenceTest. @@ -32,7 +31,7 @@ public void createSequence() { .build(); assertNotNull(sql); - assertEquals("CREATE SEQUENCE CUSTOMERS_SEQUENCE", sql); + assertEquals("CREATE SEQUENCE \"CUSTOMERS_SEQUENCE\"", sql); } /** @@ -46,7 +45,7 @@ public void alterSequence() { .build(); assertNotNull(sql); - assertEquals("ALTER SEQUENCE CUSTOMERS_SEQUENCE", sql); + assertEquals("ALTER SEQUENCE \"CUSTOMERS_SEQUENCE\"", sql); } /** @@ -60,7 +59,7 @@ public void dropSequnce() { .build(); assertNotNull(sql); - assertEquals("DROP SEQUENCE CUSTOMERS_SEQUENCE", sql); + assertEquals("DROP SEQUENCE \"CUSTOMERS_SEQUENCE\"", sql); } /** @@ -73,7 +72,7 @@ public void nextvalSequnce() { .build(); assertNotNull(sql); - assertEquals("SELECT nextval('CUSTOMERS_SEQUENCE')", sql); + assertEquals("SELECT nextval('\"CUSTOMERS_SEQUENCE\"')", sql); } } diff --git a/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/UpdateTest.java b/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/UpdateTest.java index 48f7d29558d..59e39aff0aa 100644 --- a/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/UpdateTest.java +++ b/modules/database/database-sql-postgres/src/test/java/org/eclipse/dirigible/database/sql/dialects/postgres/UpdateTest.java @@ -9,12 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.postgres; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class UpdateTest. */ @@ -32,7 +32,7 @@ public void updateSimple() { .build(); assertNotNull(sql); - assertEquals("UPDATE CUSTOMERS SET FIRST_NAME = 'John'", sql); + assertEquals("UPDATE \"CUSTOMERS\" SET \"FIRST_NAME\" = 'John'", sql); } /** @@ -48,7 +48,7 @@ public void updateValues() { .build(); assertNotNull(sql); - assertEquals("UPDATE CUSTOMERS SET FIRST_NAME = 'John', LAST_NAME = 'Smith'", sql); + assertEquals("UPDATE \"CUSTOMERS\" SET \"FIRST_NAME\" = 'John', \"LAST_NAME\" = 'Smith'", sql); } /** @@ -66,7 +66,9 @@ public void updateWhere() { .build(); assertNotNull(sql); - assertEquals("UPDATE CUSTOMERS SET FIRST_NAME = 'John', LAST_NAME = 'Smith' WHERE (AGE > ?) AND (COMPANY = 'SAP')", sql); + assertEquals( + "UPDATE \"CUSTOMERS\" SET \"FIRST_NAME\" = 'John', \"LAST_NAME\" = 'Smith' WHERE (\"AGE\" > ?) AND (\"COMPANY\" = 'SAP')", + sql); } /** @@ -87,7 +89,9 @@ public void updateWhereSelect() { .build(); assertNotNull(sql); - assertEquals("UPDATE CUSTOMERS SET FIRST_NAME = 'John', SALARY = SELECT MAX(SALARY) FROM BENEFITS WHERE (COMPANY = 'SAP')", sql); + assertEquals( + "UPDATE \"CUSTOMERS\" SET \"FIRST_NAME\" = 'John', \"SALARY\" = SELECT MAX(\"SALARY\") FROM \"BENEFITS\" WHERE (\"COMPANY\" = 'SAP')", + sql); } /** @@ -109,7 +113,8 @@ public void updateWhereExpr() { .build(); assertNotNull(sql); - assertEquals("UPDATE CUSTOMERS SET FIRST_NAME = 'John', LAST_NAME = 'Smith' WHERE (PRICE > ? OR AMOUNT < ? AND COMPANY = 'SAP')", + assertEquals( + "UPDATE \"CUSTOMERS\" SET \"FIRST_NAME\" = 'John', \"LAST_NAME\" = 'Smith' WHERE (\"PRICE\" > ? OR \"AMOUNT\" < ? AND \"COMPANY\" = 'SAP')", sql); } diff --git a/modules/database/database-sql-snowflake/src/main/java/org/eclipse/dirigible/database/sql/dialects/snowflake/SnowflakeCreateTableBuilder.java b/modules/database/database-sql-snowflake/src/main/java/org/eclipse/dirigible/database/sql/dialects/snowflake/SnowflakeCreateTableBuilder.java index f7d2df56922..13b199e3d91 100644 --- a/modules/database/database-sql-snowflake/src/main/java/org/eclipse/dirigible/database/sql/dialects/snowflake/SnowflakeCreateTableBuilder.java +++ b/modules/database/database-sql-snowflake/src/main/java/org/eclipse/dirigible/database/sql/dialects/snowflake/SnowflakeCreateTableBuilder.java @@ -9,9 +9,6 @@ */ package org.eclipse.dirigible.database.sql.dialects.snowflake; -import java.util.Arrays; -import java.util.stream.Stream; - import org.eclipse.dirigible.commons.config.Configuration; import org.eclipse.dirigible.database.sql.DataType; import org.eclipse.dirigible.database.sql.ISqlDialect; @@ -19,6 +16,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Arrays; +import java.util.stream.Stream; + /** * The Class SnowflakeCreateTableBuilder. */ @@ -109,7 +109,7 @@ public SnowflakeCreateTableBuilder column(String name, DataType type, Boolean is */ @Override protected void generateTable(StringBuilder sql) { - String tableName = (isCaseSensitive()) ? encapsulate(this.getTable(), true) : this.getTable(); + String tableName = encapsulate(this.getTable(), true); String tableType = Configuration.get("SNOWFLAKE_DEFAULT_TABLE_TYPE", KEYWORD_HYBRID); if (this.tableType.equalsIgnoreCase(KEYWORD_HYBRID)) { diff --git a/modules/database/database-sql-snowflake/src/main/java/org/eclipse/dirigible/database/sql/dialects/snowflake/SnowflakeSqlDialect.java b/modules/database/database-sql-snowflake/src/main/java/org/eclipse/dirigible/database/sql/dialects/snowflake/SnowflakeSqlDialect.java index 07b71750850..cf977f02fea 100644 --- a/modules/database/database-sql-snowflake/src/main/java/org/eclipse/dirigible/database/sql/dialects/snowflake/SnowflakeSqlDialect.java +++ b/modules/database/database-sql-snowflake/src/main/java/org/eclipse/dirigible/database/sql/dialects/snowflake/SnowflakeSqlDialect.java @@ -9,6 +9,14 @@ */ package org.eclipse.dirigible.database.sql.dialects.snowflake; +import org.eclipse.dirigible.database.sql.builders.AlterBranchingBuilder; +import org.eclipse.dirigible.database.sql.builders.DropBranchingBuilder; +import org.eclipse.dirigible.database.sql.builders.records.DeleteBuilder; +import org.eclipse.dirigible.database.sql.builders.records.InsertBuilder; +import org.eclipse.dirigible.database.sql.builders.records.SelectBuilder; +import org.eclipse.dirigible.database.sql.builders.records.UpdateBuilder; +import org.eclipse.dirigible.database.sql.dialects.DefaultSqlDialect; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -18,15 +26,6 @@ import java.util.HashSet; import java.util.Set; -import org.eclipse.dirigible.database.sql.builders.AlterBranchingBuilder; -import org.eclipse.dirigible.database.sql.builders.CreateBranchingBuilder; -import org.eclipse.dirigible.database.sql.builders.DropBranchingBuilder; -import org.eclipse.dirigible.database.sql.builders.records.DeleteBuilder; -import org.eclipse.dirigible.database.sql.builders.records.InsertBuilder; -import org.eclipse.dirigible.database.sql.builders.records.SelectBuilder; -import org.eclipse.dirigible.database.sql.builders.records.UpdateBuilder; -import org.eclipse.dirigible.database.sql.dialects.DefaultSqlDialect; - /** * The Snowflake SQL Dialect. */ @@ -34,8 +33,8 @@ public class SnowflakeSqlDialect extends DefaultSqlDialect { /** The Constant FUNCTIONS. */ - public static final Set FUNCTIONS = Collections.synchronizedSet(new HashSet(Arrays.asList(new String[] {"ABS", "ACOS", - "ACOSH", "ADD_MONTHS", "ALERT_HISTORY", "ALL_USER_NAMES", "ANY_VALUE", "APPROX_COUNT_DISTINCT", "APPROX_PERCENTILE", + public static final Set FUNCTIONS = Collections.synchronizedSet(new HashSet(Arrays.asList("ABS", "ACOS", "ACOSH", + "ADD_MONTHS", "ALERT_HISTORY", "ALL_USER_NAMES", "ANY_VALUE", "APPROX_COUNT_DISTINCT", "APPROX_PERCENTILE", "APPROX_PERCENTILE_ACCUMULATE", "APPROX_PERCENTILE_COMBINE", "APPROX_PERCENTILE_ESTIMATE", "APPROX_TOP_K", "APPROX_TOP_K_ACCUMULATE", "APPROX_TOP_K_COMBINE", "APPROX_TOP_K_ESTIMATE", "APPROXIMATE_JACCARD_INDEX", "APPROXIMATE_SIMILARITY", "ARRAY_AGG", "ARRAY_APPEND", "ARRAY_CAT", "ARRAY_COMPACT", "ARRAY_CONSTRUCT", @@ -134,7 +133,7 @@ public class SnowflakeSqlDialect extends "TRY_TO_DECIMAL", "TRY_TO_NUMBER", "TRY_TO_NUMERIC", "TRY_TO_DOUBLE", "TRY_TO_GEOGRAPHY", "TRY_TO_GEOMETRY", "TRY_TO_TIME", "TRY_TO_TIMESTAMP", "TYPEOF", "UNICODE", "UNIFORM", "UPPER", "UUID_STRING", "VALIDATE", "VALIDATE_PIPE_LOAD", "VAR_POP", "VAR_SAMP", "VARIANCE", "VARIANCE_SAMP", "VARIANCE_POP", "WAREHOUSE_LOAD_HISTORY", "WAREHOUSE_METERING_HISTORY", "WIDTH_BUCKET", - "XMLGET", "YEAR", "DAY", "WEEK", "MONTH", "QUARTER", "ZEROIFNULL", "ZIPF"}))); + "XMLGET", "YEAR", "DAY", "WEEK", "MONTH", "QUARTER", "ZEROIFNULL", "ZIPF", "AND", "OR"))); /** * Nextval. @@ -206,10 +205,7 @@ public boolean existsSchema(Connection connection, String schema) throws SQLExce PreparedStatement statement = connection.prepareStatement(sql); statement.setString(1, schema); ResultSet resultSet = statement.executeQuery(); - if (resultSet.next()) { - return true; - } - return false; + return resultSet.next(); } } diff --git a/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/CreateTableTest.java b/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/CreateTableTest.java index 6e2efaff132..f680bac35d4 100644 --- a/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/CreateTableTest.java +++ b/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/CreateTableTest.java @@ -9,13 +9,13 @@ */ package org.eclipse.dirigible.database.sql.dialects.snowflake; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.DataType; import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class CreateTableTest. */ @@ -36,7 +36,7 @@ public void createTableGeneric() { assertNotNull(sql); assertEquals( - "CREATE HYBRID TABLE CUSTOMERS ( ID INTEGER NOT NULL PRIMARY KEY , FIRST_NAME VARCHAR (20) NOT NULL UNIQUE , LAST_NAME VARCHAR (30) )", + "CREATE HYBRID TABLE \"CUSTOMERS\" ( \"ID\" INTEGER NOT NULL PRIMARY KEY , \"FIRST_NAME\" VARCHAR (20) NOT NULL UNIQUE , \"LAST_NAME\" VARCHAR (30) )", sql); } @@ -55,7 +55,7 @@ public void createTableTypeSafe() { assertNotNull(sql); assertEquals( - "CREATE HYBRID TABLE CUSTOMERS ( ID INTEGER NOT NULL PRIMARY KEY , FIRST_NAME VARCHAR (20) UNIQUE , LAST_NAME VARCHAR (30) )", + "CREATE HYBRID TABLE \"CUSTOMERS\" ( \"ID\" INTEGER NOT NULL PRIMARY KEY , \"FIRST_NAME\" VARCHAR (20) UNIQUE , \"LAST_NAME\" VARCHAR (30) )", sql); } @@ -74,7 +74,7 @@ public void createTableTypeIceberg() { assertNotNull(sql); assertEquals( - "CREATE ICEBERG TABLE CUSTOMERS ( ID INTEGER NOT NULL PRIMARY KEY , FIRST_NAME VARCHAR (20) UNIQUE , LAST_NAME VARCHAR (30) )", + "CREATE ICEBERG TABLE \"CUSTOMERS\" ( \"ID\" INTEGER NOT NULL PRIMARY KEY , \"FIRST_NAME\" VARCHAR (20) UNIQUE , \"LAST_NAME\" VARCHAR (30) )", sql); } diff --git a/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/CreateViewTest.java b/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/CreateViewTest.java index 2e16c54c02e..573629869f5 100644 --- a/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/CreateViewTest.java +++ b/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/CreateViewTest.java @@ -9,12 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.snowflake; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class CreateViewTest. */ @@ -40,7 +40,7 @@ public void createViewAsSelect() { .build(); assertNotNull(sql); - assertEquals("CREATE VIEW CUSTOMERS_VIEW ( ID , FIRST_NAME , LAST_NAME ) AS SELECT * FROM CUSTOMERS", sql); + assertEquals("CREATE VIEW \"CUSTOMERS_VIEW\" ( \"ID\" , \"FIRST_NAME\" , \"LAST_NAME\" ) AS SELECT * FROM \"CUSTOMERS\"", sql); } } diff --git a/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/DeleteTest.java b/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/DeleteTest.java index 08c1e3087dc..f0a4abba06e 100644 --- a/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/DeleteTest.java +++ b/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/DeleteTest.java @@ -9,12 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.snowflake; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class DeleteTest. */ @@ -31,7 +31,7 @@ public void deleteSimple() { .build(); assertNotNull(sql); - assertEquals("DELETE FROM CUSTOMERS", sql); + assertEquals("DELETE FROM \"CUSTOMERS\"", sql); } /** @@ -47,7 +47,7 @@ public void deleteWhere() { .build(); assertNotNull(sql); - assertEquals("DELETE FROM CUSTOMERS WHERE (AGE > ?) AND (COMPANY = 'SNOWFLAKE')", sql); + assertEquals("DELETE FROM \"CUSTOMERS\" WHERE (\"AGE\" > ?) AND (\"COMPANY\" = 'SNOWFLAKE')", sql); } } diff --git a/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/DropTableTest.java b/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/DropTableTest.java index 65ceaf64887..e0236f40067 100644 --- a/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/DropTableTest.java +++ b/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/DropTableTest.java @@ -9,12 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.snowflake; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class DropTableTest. */ @@ -31,8 +31,7 @@ public void dropTable() { .build(); assertNotNull(sql); - assertEquals("DROP TABLE CUSTOMERS", sql); + assertEquals("DROP TABLE \"CUSTOMERS\"", sql); } - } diff --git a/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/DropViewTest.java b/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/DropViewTest.java index 7e7eed51dd5..09d19aefe69 100644 --- a/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/DropViewTest.java +++ b/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/DropViewTest.java @@ -9,12 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.snowflake; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class DropViewTest. */ @@ -31,7 +31,7 @@ public void dropView() { .build(); assertNotNull(sql); - assertEquals("DROP VIEW CUSTOMERS_VIEW", sql); + assertEquals("DROP VIEW \"CUSTOMERS_VIEW\"", sql); } } diff --git a/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/InsertTest.java b/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/InsertTest.java index b5ebea25dba..122f38e9ef0 100644 --- a/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/InsertTest.java +++ b/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/InsertTest.java @@ -9,12 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.snowflake; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class InsertTest. */ @@ -33,7 +33,7 @@ public void insertSimple() { .build(); assertNotNull(sql); - assertEquals("INSERT INTO CUSTOMERS (FIRST_NAME, LAST_NAME) VALUES (?, ?)", sql); + assertEquals("INSERT INTO \"CUSTOMERS\" (\"FIRST_NAME\", \"LAST_NAME\") VALUES (?, ?)", sql); } /** @@ -51,7 +51,7 @@ public void insertValues() { .build(); assertNotNull(sql); - assertEquals("INSERT INTO CUSTOMERS (FIRST_NAME, LAST_NAME) VALUES (?, 'Smith')", sql); + assertEquals("INSERT INTO \"CUSTOMERS\" (\"FIRST_NAME\", \"LAST_NAME\") VALUES (?, 'Smith')", sql); } /** @@ -72,7 +72,7 @@ public void insertSelect() { .toString(); assertNotNull(sql); - assertEquals("INSERT INTO CUSTOMERS (FIRST_NAME, LAST_NAME) SELECT * FROM SUPPLIERS", sql); + assertEquals("INSERT INTO \"CUSTOMERS\" (\"FIRST_NAME\", \"LAST_NAME\") SELECT * FROM \"SUPPLIERS\"", sql); } } diff --git a/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/SelectTest.java b/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/SelectTest.java index 02099a38433..8e52e506cdd 100644 --- a/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/SelectTest.java +++ b/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/SelectTest.java @@ -9,12 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.snowflake; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class SelectTest. */ @@ -32,7 +32,7 @@ public void selectStar() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS", sql); + assertEquals("SELECT * FROM \"CUSTOMERS\"", sql); } /** @@ -48,7 +48,7 @@ public void selectColumnsFromTable() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS", sql); + assertEquals("SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\"", sql); } /** @@ -64,7 +64,7 @@ public void selectColumnsFromTableAliases() { .build(); assertNotNull(sql); - assertEquals("SELECT c.FIRST_NAME, c.LAST_NAME FROM CUSTOMERS AS c", sql); + assertEquals("SELECT \"c\".\"FIRST_NAME\", \"c\".\"LAST_NAME\" FROM \"CUSTOMERS\" AS \"c\"", sql); } /** @@ -81,7 +81,9 @@ public void selectColumnsFromTableJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS INNER JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\" INNER JOIN \"ADDRESSES\" ON \"CUSTOMERS\".\"ADDRESS_ID\"=\"ADDRESSES\".\"ADDRESS_ID\"", + sql); } /** @@ -98,7 +100,9 @@ public void selectColumnsFromTableInnerJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS INNER JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\" INNER JOIN \"ADDRESSES\" ON \"CUSTOMERS\".\"ADDRESS_ID\"=\"ADDRESSES\".\"ADDRESS_ID\"", + sql); } /** @@ -115,7 +119,9 @@ public void selectColumnsFromTableOuterJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS OUTER JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\" OUTER JOIN \"ADDRESSES\" ON \"CUSTOMERS\".\"ADDRESS_ID\"=\"ADDRESSES\".\"ADDRESS_ID\"", + sql); } /** @@ -132,7 +138,9 @@ public void selectColumnsFromTableLeftJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS LEFT JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\" LEFT JOIN \"ADDRESSES\" ON \"CUSTOMERS\".\"ADDRESS_ID\"=\"ADDRESSES\".\"ADDRESS_ID\"", + sql); } /** @@ -149,7 +157,9 @@ public void selectColumnsFromTableRightJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS RIGHT JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\" RIGHT JOIN \"ADDRESSES\" ON \"CUSTOMERS\".\"ADDRESS_ID\"=\"ADDRESSES\".\"ADDRESS_ID\"", + sql); } /** @@ -166,7 +176,9 @@ public void selectColumnsFromTableFullJoin() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS FULL JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); + assertEquals( + "SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\" FULL JOIN \"ADDRESSES\" ON \"CUSTOMERS\".\"ADDRESS_ID\"=\"ADDRESSES\".\"ADDRESS_ID\"", + sql); } /** @@ -183,7 +195,7 @@ public void selectDistinctColumnsFromTable() { .build(); assertNotNull(sql); - assertEquals("SELECT DISTINCT FIRST_NAME, LAST_NAME FROM CUSTOMERS", sql); + assertEquals("SELECT DISTINCT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\"", sql); } /** @@ -201,7 +213,7 @@ public void selectColumnsFromTableOrderByAndDesc() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS ORDER BY FIRST_NAME ASC, LAST_NAME DESC", sql); + assertEquals("SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\" ORDER BY \"FIRST_NAME\" ASC, \"LAST_NAME\" DESC", sql); } /** @@ -218,7 +230,7 @@ public void selectColumnsFromTableGroupBy() { .build(); assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS GROUP BY FIRST_NAME", sql); + assertEquals("SELECT \"FIRST_NAME\", \"LAST_NAME\" FROM \"CUSTOMERS\" GROUP BY \"FIRST_NAME\"", sql); } /** @@ -234,7 +246,7 @@ public void selectWhereSimple() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS WHERE (PRICE > ?)", sql); + assertEquals("SELECT * FROM \"CUSTOMERS\" WHERE (\"PRICE\" > ?)", sql); } /** @@ -251,7 +263,7 @@ public void selectWhereAnd() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS WHERE (PRICE > ?) AND (AMOUNT < ?)", sql); + assertEquals("SELECT * FROM \"CUSTOMERS\" WHERE (\"PRICE\" > ?) AND (\"AMOUNT\" < ?)", sql); } /** @@ -267,7 +279,7 @@ public void selectWhereOr() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS WHERE (PRICE > ? OR AMOUNT < ?)", sql); + assertEquals("SELECT * FROM \"CUSTOMERS\" WHERE (\"PRICE\" > ? OR \"AMOUNT\" < ?)", sql); } /** @@ -287,7 +299,7 @@ public void selectWhereExpr() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS WHERE (PRICE > ? OR AMOUNT < ?)", sql); + assertEquals("SELECT * FROM \"CUSTOMERS\" WHERE (\"PRICE\" > ? OR \"AMOUNT\" < ?)", sql); } /** @@ -303,7 +315,7 @@ public void selectLimit() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS LIMIT 10", sql); + assertEquals("SELECT * FROM \"CUSTOMERS\" LIMIT 10", sql); } /** @@ -320,7 +332,7 @@ public void selectLimitOffset() { .build(); assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS LIMIT 10 OFFSET 20", sql); + assertEquals("SELECT * FROM \"CUSTOMERS\" LIMIT 10 OFFSET 20", sql); } /** @@ -338,7 +350,8 @@ public void selectHaving() { .build(); assertNotNull(sql); - assertEquals("SELECT COUNT(FIRST_NAME), COUNTRY FROM CUSTOMERS GROUP BY COUNTRY HAVING COUNT(FIRST_NAME) > 5", sql); + assertEquals("SELECT COUNT(\"FIRST_NAME\"), \"COUNTRY\" FROM \"CUSTOMERS\" GROUP BY \"COUNTRY\" HAVING COUNT(\"FIRST_NAME\") > 5", + sql); } /** @@ -358,7 +371,7 @@ public void selectUnion() { .build(); assertNotNull(sql); - assertEquals("SELECT COUNTRY FROM CUSTOMERS UNION SELECT COUNTRY FROM SUPPLIERS", sql); + assertEquals("SELECT \"COUNTRY\" FROM \"CUSTOMERS\" UNION SELECT \"COUNTRY\" FROM \"SUPPLIERS\"", sql); } } diff --git a/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/SequenceTest.java b/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/SequenceTest.java index 7e492d0ea9c..94bd96c3264 100644 --- a/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/SequenceTest.java +++ b/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/SequenceTest.java @@ -9,12 +9,11 @@ */ package org.eclipse.dirigible.database.sql.dialects.snowflake; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; /** * The Class SequenceTest. @@ -32,7 +31,7 @@ public void createSequence() { .build(); assertNotNull(sql); - assertEquals("CREATE SEQUENCE CUSTOMERS_SEQUENCE", sql); + assertEquals("CREATE SEQUENCE \"CUSTOMERS_SEQUENCE\"", sql); } /** @@ -46,7 +45,7 @@ public void alterSequence() { .build(); assertNotNull(sql); - assertEquals("ALTER SEQUENCE CUSTOMERS_SEQUENCE", sql); + assertEquals("ALTER SEQUENCE \"CUSTOMERS_SEQUENCE\"", sql); } /** @@ -60,7 +59,7 @@ public void dropSequnce() { .build(); assertNotNull(sql); - assertEquals("DROP SEQUENCE CUSTOMERS_SEQUENCE", sql); + assertEquals("DROP SEQUENCE \"CUSTOMERS_SEQUENCE\"", sql); } /** diff --git a/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/UpdateTest.java b/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/UpdateTest.java index c26e05959eb..8905bb6d694 100644 --- a/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/UpdateTest.java +++ b/modules/database/database-sql-snowflake/src/test/java/org/eclipse/dirigible/database/sql/dialects/snowflake/UpdateTest.java @@ -9,12 +9,12 @@ */ package org.eclipse.dirigible.database.sql.dialects.snowflake; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.eclipse.dirigible.database.sql.SqlFactory; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * The Class UpdateTest. */ @@ -32,7 +32,7 @@ public void updateSimple() { .build(); assertNotNull(sql); - assertEquals("UPDATE CUSTOMERS SET FIRST_NAME = 'John'", sql); + assertEquals("UPDATE \"CUSTOMERS\" SET \"FIRST_NAME\" = 'John'", sql); } /** @@ -48,7 +48,7 @@ public void updateValues() { .build(); assertNotNull(sql); - assertEquals("UPDATE CUSTOMERS SET FIRST_NAME = 'John', LAST_NAME = 'Smith'", sql); + assertEquals("UPDATE \"CUSTOMERS\" SET \"FIRST_NAME\" = 'John', \"LAST_NAME\" = 'Smith'", sql); } /** @@ -66,7 +66,9 @@ public void updateWhere() { .build(); assertNotNull(sql); - assertEquals("UPDATE CUSTOMERS SET FIRST_NAME = 'John', LAST_NAME = 'Smith' WHERE (AGE > ?) AND (COMPANY = 'SNOWFLAKE')", sql); + assertEquals( + "UPDATE \"CUSTOMERS\" SET \"FIRST_NAME\" = 'John', \"LAST_NAME\" = 'Smith' WHERE (\"AGE\" > ?) AND (\"COMPANY\" = 'SNOWFLAKE')", + sql); } /** @@ -87,7 +89,8 @@ public void updateWhereSelect() { .build(); assertNotNull(sql); - assertEquals("UPDATE CUSTOMERS SET FIRST_NAME = 'John', SALARY = SELECT MAX(SALARY) FROM BENEFITS WHERE (COMPANY = 'SNOWFLAKE')", + assertEquals( + "UPDATE \"CUSTOMERS\" SET \"FIRST_NAME\" = 'John', \"SALARY\" = SELECT MAX(\"SALARY\") FROM \"BENEFITS\" WHERE (\"COMPANY\" = 'SNOWFLAKE')", sql); } @@ -111,7 +114,7 @@ public void updateWhereExpr() { assertNotNull(sql); assertEquals( - "UPDATE CUSTOMERS SET FIRST_NAME = 'John', LAST_NAME = 'Smith' WHERE (PRICE > ? OR AMOUNT < ? AND COMPANY = 'SNOWFLAKE')", + "UPDATE \"CUSTOMERS\" SET \"FIRST_NAME\" = 'John', \"LAST_NAME\" = 'Smith' WHERE (\"PRICE\" > ? OR \"AMOUNT\" < ? AND \"COMPANY\" = 'SNOWFLAKE')", sql); } diff --git a/modules/database/database-sql-sybase/.gitignore b/modules/database/database-sql-sybase/.gitignore deleted file mode 100644 index 8c37bd5c84d..00000000000 --- a/modules/database/database-sql-sybase/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -# folders -dist/ -.settings/ -target/ -dirigible_local/ - -# files -.DS_Store -.project -.classpath -*.bak -*.class -*.jar -derby.log \ No newline at end of file diff --git a/modules/database/database-sql-sybase/about.html b/modules/database/database-sql-sybase/about.html deleted file mode 100644 index bcb03d59e0f..00000000000 --- a/modules/database/database-sql-sybase/about.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - -About - - -

About This Content

- -

April 25, 2020

-

License

- -

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise -indicated below, the Content is provided to you under the terms and conditions of the -Eclipse Public License Version 2.0 ("EPL"). A copy of the EPL is available -at http://www.eclipse.org/legal/epl-v20.html. -For purposes of the EPL, "Program" will mean the Content.

- -

If you did not receive this Content directly from the Eclipse Foundation, the Content is -being redistributed by another party ("Redistributor") and different terms and conditions may -apply to your use of any object code in the Content. Check the Redistributor's license that was -provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise -indicated below, the terms and conditions of the EPL still apply to any source code in the Content -and such source code may be obtained at http://www.eclipse.org.

- - - diff --git a/modules/database/database-sql-sybase/pom.xml b/modules/database/database-sql-sybase/pom.xml deleted file mode 100644 index b1b29ae9356..00000000000 --- a/modules/database/database-sql-sybase/pom.xml +++ /dev/null @@ -1,36 +0,0 @@ - - 4.0.0 - - - org.eclipse.dirigible - dirigible-database-parent - 11.0.0-SNAPSHOT - ../pom.xml - - - Database - SQL Builders - Sybase - dirigible-database-sql-sybase - jar - - - ${project.artifactId} - - - - - org.eclipse.dirigible - dirigible-commons-config - - - org.eclipse.dirigible - dirigible-database-sql - - - - - ../../../licensing-header.txt - ../../../ - - - diff --git a/modules/database/database-sql-sybase/src/main/java/org/eclipse/dirigible/database/sql/dialects/sybase/SybaseCreateBranchingBuilder.java b/modules/database/database-sql-sybase/src/main/java/org/eclipse/dirigible/database/sql/dialects/sybase/SybaseCreateBranchingBuilder.java deleted file mode 100644 index 8ee3477e0bb..00000000000 --- a/modules/database/database-sql-sybase/src/main/java/org/eclipse/dirigible/database/sql/dialects/sybase/SybaseCreateBranchingBuilder.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2024 Eclipse Dirigible contributors - * - * All rights reserved. This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v2.0 which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v20.html - * - * SPDX-FileCopyrightText: Eclipse Dirigible contributors SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.dirigible.database.sql.dialects.sybase; - -import org.eclipse.dirigible.database.sql.ISqlDialect; -import org.eclipse.dirigible.database.sql.builders.CreateBranchingBuilder; -import org.eclipse.dirigible.database.sql.builders.sequence.CreateSequenceBuilder; - -/** - * The Sybase Create Branching Builder. - */ -public class SybaseCreateBranchingBuilder extends CreateBranchingBuilder { - - /** - * Instantiates a new Sybase create branching builder. - * - * @param dialect the dialect - */ - public SybaseCreateBranchingBuilder(ISqlDialect dialect) { - super(dialect); - } - - /** - * Sequence. - * - * @param sequence the sequence - * @return the creates the sequence builder - */ - @Override - public CreateSequenceBuilder sequence(String sequence) { - return new SybaseCreateSequenceBuilder(this.getDialect(), sequence); - } - -} diff --git a/modules/database/database-sql-sybase/src/main/java/org/eclipse/dirigible/database/sql/dialects/sybase/SybaseCreateSequenceBuilder.java b/modules/database/database-sql-sybase/src/main/java/org/eclipse/dirigible/database/sql/dialects/sybase/SybaseCreateSequenceBuilder.java deleted file mode 100644 index 32d8174c6f7..00000000000 --- a/modules/database/database-sql-sybase/src/main/java/org/eclipse/dirigible/database/sql/dialects/sybase/SybaseCreateSequenceBuilder.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2024 Eclipse Dirigible contributors - * - * All rights reserved. This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v2.0 which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v20.html - * - * SPDX-FileCopyrightText: Eclipse Dirigible contributors SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.dirigible.database.sql.dialects.sybase; - -import org.eclipse.dirigible.database.sql.ISqlDialect; -import org.eclipse.dirigible.database.sql.builders.sequence.CreateSequenceBuilder; - -/** - * The Sybase Create Sequence Builder. - */ -public class SybaseCreateSequenceBuilder extends CreateSequenceBuilder { - - /** - * Instantiates a new Sybase create sequence builder. - * - * @param dialect the dialect - * @param sequence the sequence - */ - public SybaseCreateSequenceBuilder(ISqlDialect dialect, String sequence) { - super(dialect, sequence); - } - - /** - * Generate start. - * - * @param sql the sql - */ - @Override - protected void generateStart(StringBuilder sql) { - throw new IllegalStateException("Sybase ASE does not support Sequences"); - } - -} diff --git a/modules/database/database-sql-sybase/src/main/java/org/eclipse/dirigible/database/sql/dialects/sybase/SybaseDropBranchingBuilder.java b/modules/database/database-sql-sybase/src/main/java/org/eclipse/dirigible/database/sql/dialects/sybase/SybaseDropBranchingBuilder.java deleted file mode 100644 index cead577fabd..00000000000 --- a/modules/database/database-sql-sybase/src/main/java/org/eclipse/dirigible/database/sql/dialects/sybase/SybaseDropBranchingBuilder.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2024 Eclipse Dirigible contributors - * - * All rights reserved. This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v2.0 which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v20.html - * - * SPDX-FileCopyrightText: Eclipse Dirigible contributors SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.dirigible.database.sql.dialects.sybase; - -import org.eclipse.dirigible.database.sql.ISqlDialect; -import org.eclipse.dirigible.database.sql.builders.DropBranchingBuilder; -import org.eclipse.dirigible.database.sql.builders.sequence.DropSequenceBuilder; - -/** - * The Sybase Drop Branching Builder. - */ -public class SybaseDropBranchingBuilder extends DropBranchingBuilder { - - /** - * Instantiates a new Sybase create branching builder. - * - * @param dialect the dialect - */ - public SybaseDropBranchingBuilder(ISqlDialect dialect) { - super(dialect); - } - - /** - * Sequence. - * - * @param sequence the sequence - * @return the drop sequence builder - */ - @Override - public DropSequenceBuilder sequence(String sequence) { - return new SybaseDropSequenceBuilder(this.getDialect(), sequence); - } - -} diff --git a/modules/database/database-sql-sybase/src/main/java/org/eclipse/dirigible/database/sql/dialects/sybase/SybaseDropSequenceBuilder.java b/modules/database/database-sql-sybase/src/main/java/org/eclipse/dirigible/database/sql/dialects/sybase/SybaseDropSequenceBuilder.java deleted file mode 100644 index 15c0e07e234..00000000000 --- a/modules/database/database-sql-sybase/src/main/java/org/eclipse/dirigible/database/sql/dialects/sybase/SybaseDropSequenceBuilder.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2024 Eclipse Dirigible contributors - * - * All rights reserved. This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v2.0 which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v20.html - * - * SPDX-FileCopyrightText: Eclipse Dirigible contributors SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.dirigible.database.sql.dialects.sybase; - -import org.eclipse.dirigible.database.sql.ISqlDialect; -import org.eclipse.dirigible.database.sql.builders.sequence.DropSequenceBuilder; - -/** - * The Sybase Drop Sequence Builder. - */ -public class SybaseDropSequenceBuilder extends DropSequenceBuilder { - - /** - * Instantiates a new Sybase drop sequence builder. - * - * @param dialect the dialect - * @param sequence the sequence - */ - public SybaseDropSequenceBuilder(ISqlDialect dialect, String sequence) { - super(dialect, sequence); - } - - /** - * Generate. - * - * @return the string - */ - @Override - public String generate() { - throw new IllegalStateException("Sybase does not support Sequences"); - } - -} diff --git a/modules/database/database-sql-sybase/src/main/java/org/eclipse/dirigible/database/sql/dialects/sybase/SybaseLastValueIdentityBuilder.java b/modules/database/database-sql-sybase/src/main/java/org/eclipse/dirigible/database/sql/dialects/sybase/SybaseLastValueIdentityBuilder.java deleted file mode 100644 index 6fd4c87d176..00000000000 --- a/modules/database/database-sql-sybase/src/main/java/org/eclipse/dirigible/database/sql/dialects/sybase/SybaseLastValueIdentityBuilder.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2024 Eclipse Dirigible contributors - * - * All rights reserved. This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v2.0 which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v20.html - * - * SPDX-FileCopyrightText: Eclipse Dirigible contributors SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.dirigible.database.sql.dialects.sybase; - -import static java.text.MessageFormat.format; - -import org.eclipse.dirigible.database.sql.ISqlDialect; -import org.eclipse.dirigible.database.sql.builders.sequence.LastValueIdentityBuilder; - -/** - * The Sybase Next Value Sequence Builder. - */ -public class SybaseLastValueIdentityBuilder extends LastValueIdentityBuilder { - - /** The Constant PATTERN_SELECT_LAST_VALUE_IDENTITY. */ - private static final String PATTERN_SELECT_LAST_VALUE_IDENTITY = "SELECT @@identity"; - - /** - * Instantiates a new Sybase last value identity builder. - * - * @param dialect the dialect - */ - public SybaseLastValueIdentityBuilder(ISqlDialect dialect) { - super(dialect); - } - - /** - * Generate. - * - * @return the string - */ - @Override - public String generate() { - String sql = format(PATTERN_SELECT_LAST_VALUE_IDENTITY); - return sql; - } -} diff --git a/modules/database/database-sql-sybase/src/main/java/org/eclipse/dirigible/database/sql/dialects/sybase/SybaseNextValueSequenceBuilder.java b/modules/database/database-sql-sybase/src/main/java/org/eclipse/dirigible/database/sql/dialects/sybase/SybaseNextValueSequenceBuilder.java deleted file mode 100644 index e574e224f0b..00000000000 --- a/modules/database/database-sql-sybase/src/main/java/org/eclipse/dirigible/database/sql/dialects/sybase/SybaseNextValueSequenceBuilder.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2024 Eclipse Dirigible contributors - * - * All rights reserved. This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v2.0 which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v20.html - * - * SPDX-FileCopyrightText: Eclipse Dirigible contributors SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.dirigible.database.sql.dialects.sybase; - -import org.eclipse.dirigible.database.sql.ISqlDialect; -import org.eclipse.dirigible.database.sql.builders.sequence.NextValueSequenceBuilder; - -/** - * The Sybase Next Value Sequence Builder. - */ -public class SybaseNextValueSequenceBuilder extends NextValueSequenceBuilder { - - /** - * Instantiates a new Sybase next value sequence builder. - * - * @param dialect the dialect - * @param sequence the sequence - */ - public SybaseNextValueSequenceBuilder(ISqlDialect dialect, String sequence) { - super(dialect, sequence); - } - - /** - * Generate. - * - * @return the string - */ - @Override - public String generate() { - throw new IllegalStateException("Sybase ASE does not support Sequences"); - } -} diff --git a/modules/database/database-sql-sybase/src/main/java/org/eclipse/dirigible/database/sql/dialects/sybase/SybaseSelectBuilder.java b/modules/database/database-sql-sybase/src/main/java/org/eclipse/dirigible/database/sql/dialects/sybase/SybaseSelectBuilder.java deleted file mode 100644 index 6f79972823a..00000000000 --- a/modules/database/database-sql-sybase/src/main/java/org/eclipse/dirigible/database/sql/dialects/sybase/SybaseSelectBuilder.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2024 Eclipse Dirigible contributors - * - * All rights reserved. This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v2.0 which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v20.html - * - * SPDX-FileCopyrightText: Eclipse Dirigible contributors SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.dirigible.database.sql.dialects.sybase; - -import org.eclipse.dirigible.database.sql.ISqlDialect; -import org.eclipse.dirigible.database.sql.builders.records.SelectBuilder; - -/** - * The Sybase Select Builder. - */ -public class SybaseSelectBuilder extends SelectBuilder { - - /** - * Instantiates a new Sybase select builder. - * - * @param dialect the dialect - */ - public SybaseSelectBuilder(ISqlDialect dialect) { - super(dialect); - } - - /** - * Generate limit and offset. - * - * @param sql the sql - * @param limit the limit - * @param offset the offset - */ - @Override - protected void generateLimitAndOffset(StringBuilder sql, int limit, int offset) { - if (limit > -1) { - sql.append(SPACE) - .append(KEYWORD_ROWS) - .append(SPACE) - .append(KEYWORD_LIMIT) - .append(SPACE) - .append(limit); - } - if (offset > -1) { - sql.append(SPACE) - .append(KEYWORD_OFFSET) - .append(SPACE) - .append(offset); - } - } - -} diff --git a/modules/database/database-sql-sybase/src/main/java/org/eclipse/dirigible/database/sql/dialects/sybase/SybaseSqlDialect.java b/modules/database/database-sql-sybase/src/main/java/org/eclipse/dirigible/database/sql/dialects/sybase/SybaseSqlDialect.java deleted file mode 100644 index 7efec441fcb..00000000000 --- a/modules/database/database-sql-sybase/src/main/java/org/eclipse/dirigible/database/sql/dialects/sybase/SybaseSqlDialect.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright (c) 2024 Eclipse Dirigible contributors - * - * All rights reserved. This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v2.0 which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v20.html - * - * SPDX-FileCopyrightText: Eclipse Dirigible contributors SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.dirigible.database.sql.dialects.sybase; - -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.dirigible.database.sql.DataType; -import org.eclipse.dirigible.database.sql.builders.AlterBranchingBuilder; -import org.eclipse.dirigible.database.sql.builders.CreateBranchingBuilder; -import org.eclipse.dirigible.database.sql.builders.DropBranchingBuilder; -import org.eclipse.dirigible.database.sql.builders.records.DeleteBuilder; -import org.eclipse.dirigible.database.sql.builders.records.InsertBuilder; -import org.eclipse.dirigible.database.sql.builders.records.UpdateBuilder; -import org.eclipse.dirigible.database.sql.dialects.DefaultSqlDialect; - -/** - * The Sybase SQL Dialect. - */ -public class SybaseSqlDialect extends - DefaultSqlDialect { - - /** The Constant FUNCTION_CURRENT_DATE. */ - public static final String FUNCTION_CURRENT_DATE = "current_date"; //$NON-NLS-1$ - - /** The Constant FUNCTION_CURRENT_TIME. */ - public static final String FUNCTION_CURRENT_TIME = "current_time"; //$NON-NLS-1$ - - /** The Constant FUNCTION_CURRENT_TIMESTAMP. */ - public static final String FUNCTION_CURRENT_TIMESTAMP = "getdate()"; //$NON-NLS-1$ - - /** The Constant FUNCTIONS. */ - public static final Set FUNCTIONS = Collections.synchronizedSet(new HashSet(Arrays.asList(new String[] {"abs", "acos", - "argn", "ascii", "asin", "atan", "atan2", "avg", "bfile", "biginttohex", "bit_length", "byte_length", "byte_length64", - "byte_substr64", "cast", "ceil", "ceiling", "char", "char_length", "char_length64", "charindex", "coalesce", "col_length", - "col_name", "connection_property", "convert", "corr", "cos", "cot", "covar_pop", "covar_samp", "count", "cume_dist", "date", - "dateadd", "dateceiling", "datediff", "datefloor", "dateformat", "datename", "datepart", "dateround", "datetime", "day", - "dayname", "days", "db_id", "db_name", "db_property", "degrees", "dense_rank", "difference", "dow", "errormsg", - "event_condition", "event_condition_name", "event_parameter", "exp", "exp_weighted_avg", "first_value", "floor", "getdate", - "graphical_plan", "grouping", "group_member", "hextobigint", "hextoint", "hour", "hours", "html_decode", "html_encode", - "html_plan", "http_decode", "http_encode", "http_header", "http_variable", "ifnull", "index_col", "insertstr", "inttohex", - "isdate", "isnull", "isnumeric", "lag", "last_value", "lcase", "lead", "left", "len", "length", "list", "ln", "locate", "log", - "log10", "lower", "ltrim", "max", "median", "min", "minute", "minutes", "mod", "month", "monthname", "months", "newid", - "next_connection", "next_database", "next_http_header", "next_http_variable", "now", "ntile", "nullif", "number", "object_id", - "object_name", "octet_length", "patindex", "percent_rank", "percentile_cont", "percentile_disc", "pi", "power", "property", - "property_description", "property_name", "property_number", "quarter", "radians", "rand", "rank", "regr_avgx", "regr_avgy", - "regr_count", "regr_intercept", "regr_r2", "regr_slope", "regr_sxx", "regr_sxy", "regr_syy", "remainder", "repeat", "replace", - "replicate", "reverse", "right", "round", "row_number", "rowid", "rtrim", "second", "seconds", "sign", "similar", "sin", - "sortkey", "soundex", "space", "sqlflagger", "sqrt", "square", "stddev", "stddev_pop", "stddev_samp", "str", "str_replace", - "string", "strtouuid", "stuff", "substring", "substring64", "sum", "suser_id", "suser_name", "tan", "today", "trim", "truncnum", - "ts_arma_ar", "ts_arma_const", "ts_arma_ma", "ts_autocorrelation", "ts_auto_arima", "ts_auto_arima_outlier", - "ts_auto_arima_result_aic", "ts_auto_arima_result_aicc", "ts_auto_arima_result_bic", "ts_auto_arima_result_forecast_value", - "ts_auto_arima_result_forecast_error", "ts_auto_arima_result_model_d", "ts_auto_arima_result_model_p", - "ts_auto_arima_result_model_q", "ts_auto_arima_result_model_s", "ts_auto_arima_result_residual_sigma", "ts_auto_uni_ar", - "ts_box_cox_xform", "ts_difference", "ts_double_array", "ts_estimate_missing", "ts_garch", "ts_garch_result_a", - "ts_garch_result_aic", "ts_garch_result_user", "ts_int_array", "ts_lack_of_fit", "ts_lack_of_fit_p", "ts_max_arma_ar", - "ts_max_arma_const", "ts_max_arma_likelihood", "ts_max_arma_ma", "ts_outlier_identification", "ts_partial_autocorrelation", - "ucase", "upper", "user_id", "user_name", "uuidtostr", "var_pop", "var_samp", "variance", "weeks", "weighted_avg", - "width_bucket", "year", "years", "ymd", - - "and", "or", "between", "binary", "case", "div", "in", "is", "not", "null", "like", "rlike", "xor" - - }))); - - /** - * Creates the. - * - * @return the sybase create branching builder - */ - @Override - public SybaseCreateBranchingBuilder create() { - return new SybaseCreateBranchingBuilder(this); - } - - /** - * Drop. - * - * @return the sybase drop branching builder - */ - @Override - public SybaseDropBranchingBuilder drop() { - return new SybaseDropBranchingBuilder(this); - } - - /** - * Nextval. - * - * @param sequence the sequence - * @return the sybase next value sequence builder - */ - @Override - public SybaseNextValueSequenceBuilder nextval(String sequence) { - return new SybaseNextValueSequenceBuilder(this, sequence); - - } - - /** - * Gets the data type name. - * - * @param dataType the data type - * @return the data type name - */ - @Override - public String getDataTypeName(DataType dataType) { - switch (dataType) { - case TIMESTAMP: - return "DATETIME"; - case BLOB: - return "IMAGE"; - case BOOLEAN: - return "BIT"; - case DOUBLE: - return "DOUBLE PRECISION"; - default: - return super.getDataTypeName(dataType); - } - } - - /** - * Lastval. - * - * @param args the args - * @return the sybase last value identity builder - */ - @Override - public SybaseLastValueIdentityBuilder lastval(String... args) { - return new SybaseLastValueIdentityBuilder(this); - } - - /** - * Select. - * - * @return the sybase select builder - */ - @Override - public SybaseSelectBuilder select() { - return new SybaseSelectBuilder(this); - } - - /** - * Function current date. - * - * @return the string - */ - @Override - public String functionCurrentDate() { - return FUNCTION_CURRENT_DATE; - } - - /** - * Function current time. - * - * @return the string - */ - @Override - public String functionCurrentTime() { - return FUNCTION_CURRENT_TIME; - } - - /** - * Function current timestamp. - * - * @return the string - */ - @Override - public String functionCurrentTimestamp() { - return FUNCTION_CURRENT_TIMESTAMP; - } - - /** - * Gets the functions names. - * - * @return the functions names - */ - @Override - public Set getFunctionsNames() { - return FUNCTIONS; - } - -} diff --git a/modules/database/database-sql-sybase/src/main/java/org/eclipse/dirigible/database/sql/dialects/sybase/SybaseSqlDialectProvider.java b/modules/database/database-sql-sybase/src/main/java/org/eclipse/dirigible/database/sql/dialects/sybase/SybaseSqlDialectProvider.java deleted file mode 100644 index a98cf641233..00000000000 --- a/modules/database/database-sql-sybase/src/main/java/org/eclipse/dirigible/database/sql/dialects/sybase/SybaseSqlDialectProvider.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2024 Eclipse Dirigible contributors - * - * All rights reserved. This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v2.0 which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v20.html - * - * SPDX-FileCopyrightText: Eclipse Dirigible contributors SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.dirigible.database.sql.dialects.sybase; - -import org.eclipse.dirigible.components.database.DatabaseSystem; -import org.eclipse.dirigible.database.sql.ISqlDialect; -import org.eclipse.dirigible.database.sql.ISqlDialectProvider; - -/** - * The Class SybaseSqlDialectProvider. - */ -public class SybaseSqlDialectProvider implements ISqlDialectProvider { - - @Override - public DatabaseSystem getDatabaseSystem() { - return DatabaseSystem.SYBASE; - } - - /** - * Gets the dialect. - * - * @return the dialect - */ - @Override - public ISqlDialect getDialect() { - return new SybaseSqlDialect(); - } - -} diff --git a/modules/database/database-sql-sybase/src/test/java/org/eclipse/dirigible/database/sql/dialects/sybase/CreateTableTest.java b/modules/database/database-sql-sybase/src/test/java/org/eclipse/dirigible/database/sql/dialects/sybase/CreateTableTest.java deleted file mode 100644 index 164adf9e12a..00000000000 --- a/modules/database/database-sql-sybase/src/test/java/org/eclipse/dirigible/database/sql/dialects/sybase/CreateTableTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2024 Eclipse Dirigible contributors - * - * All rights reserved. This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v2.0 which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v20.html - * - * SPDX-FileCopyrightText: Eclipse Dirigible contributors SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.dirigible.database.sql.dialects.sybase; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.eclipse.dirigible.database.sql.DataType; -import org.eclipse.dirigible.database.sql.SqlFactory; -import org.junit.Test; - -/** - * The Class CreateTableTest. - */ -public class CreateTableTest { - - /** - * Creates the table generic. - */ - @Test - public void createTableGeneric() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .create() - .table("CUSTOMERS") - .column("ID", DataType.INTEGER, true, false, false) - .column("FIRST_NAME", DataType.VARCHAR, false, false, true, "(20)") - .column("LAST_NAME", DataType.VARCHAR, false, true, false, "(30)") - .build(); - - assertNotNull(sql); - assertEquals( - "CREATE TABLE CUSTOMERS ( ID INTEGER NOT NULL PRIMARY KEY , FIRST_NAME VARCHAR (20) NOT NULL UNIQUE , LAST_NAME VARCHAR (30) )", - sql); - } - - /** - * Creates the table type safe. - */ - @Test - public void createTableTypeSafe() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .create() - .table("CUSTOMERS") - .columnInteger("ID", true, false, false) - .columnVarchar("FIRST_NAME", 20, false, true, true) - .columnVarchar("LAST_NAME", 30, false, true, false) - .build(); - - assertNotNull(sql); - assertEquals("CREATE TABLE CUSTOMERS ( ID INTEGER NOT NULL PRIMARY KEY , FIRST_NAME VARCHAR (20) UNIQUE , LAST_NAME VARCHAR (30) )", - sql); - } - -} diff --git a/modules/database/database-sql-sybase/src/test/java/org/eclipse/dirigible/database/sql/dialects/sybase/CreateViewTest.java b/modules/database/database-sql-sybase/src/test/java/org/eclipse/dirigible/database/sql/dialects/sybase/CreateViewTest.java deleted file mode 100644 index d372a342801..00000000000 --- a/modules/database/database-sql-sybase/src/test/java/org/eclipse/dirigible/database/sql/dialects/sybase/CreateViewTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2024 Eclipse Dirigible contributors - * - * All rights reserved. This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v2.0 which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v20.html - * - * SPDX-FileCopyrightText: Eclipse Dirigible contributors SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.dirigible.database.sql.dialects.sybase; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.eclipse.dirigible.database.sql.SqlFactory; -import org.junit.Test; - -/** - * The Class CreateViewTest. - */ -public class CreateViewTest extends CreateTableTest { - - /** - * Creates the view as select. - */ - @Test - public void createViewAsSelect() { - createTableGeneric(); - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .create() - .view("CUSTOMERS_VIEW") - .column("ID") - .column("FIRST_NAME") - .column("LAST_NAME") - .asSelect(SqlFactory.getDefault() - .select() - .column("*") - .from("CUSTOMERS") - .build()) - .build(); - - assertNotNull(sql); - assertEquals("CREATE VIEW CUSTOMERS_VIEW ( ID , FIRST_NAME , LAST_NAME ) AS SELECT * FROM CUSTOMERS", sql); - } - -} diff --git a/modules/database/database-sql-sybase/src/test/java/org/eclipse/dirigible/database/sql/dialects/sybase/DeleteTest.java b/modules/database/database-sql-sybase/src/test/java/org/eclipse/dirigible/database/sql/dialects/sybase/DeleteTest.java deleted file mode 100644 index 5c0d9f57f5b..00000000000 --- a/modules/database/database-sql-sybase/src/test/java/org/eclipse/dirigible/database/sql/dialects/sybase/DeleteTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2024 Eclipse Dirigible contributors - * - * All rights reserved. This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v2.0 which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v20.html - * - * SPDX-FileCopyrightText: Eclipse Dirigible contributors SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.dirigible.database.sql.dialects.sybase; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.eclipse.dirigible.database.sql.SqlFactory; -import org.junit.Test; - -/** - * The Class DeleteTest. - */ -public class DeleteTest { - - /** - * Delete simple. - */ - @Test - public void deleteSimple() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .delete() - .from("CUSTOMERS") - .build(); - - assertNotNull(sql); - assertEquals("DELETE FROM CUSTOMERS", sql); - } - - /** - * Delete where. - */ - @Test - public void deleteWhere() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .delete() - .from("CUSTOMERS") - .where("AGE > ?") - .where("COMPANY = 'SAP'") - .build(); - - assertNotNull(sql); - assertEquals("DELETE FROM CUSTOMERS WHERE (AGE > ?) AND (COMPANY = 'SAP')", sql); - } - -} diff --git a/modules/database/database-sql-sybase/src/test/java/org/eclipse/dirigible/database/sql/dialects/sybase/DropTableTest.java b/modules/database/database-sql-sybase/src/test/java/org/eclipse/dirigible/database/sql/dialects/sybase/DropTableTest.java deleted file mode 100644 index 4719f80197a..00000000000 --- a/modules/database/database-sql-sybase/src/test/java/org/eclipse/dirigible/database/sql/dialects/sybase/DropTableTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2024 Eclipse Dirigible contributors - * - * All rights reserved. This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v2.0 which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v20.html - * - * SPDX-FileCopyrightText: Eclipse Dirigible contributors SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.dirigible.database.sql.dialects.sybase; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.eclipse.dirigible.database.sql.SqlFactory; -import org.junit.Test; - -/** - * The Class DropTableTest. - */ -public class DropTableTest { - - /** - * Drop table. - */ - @Test - public void dropTable() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .drop() - .table("CUSTOMERS") - .build(); - - assertNotNull(sql); - assertEquals("DROP TABLE CUSTOMERS", sql); - } - - -} diff --git a/modules/database/database-sql-sybase/src/test/java/org/eclipse/dirigible/database/sql/dialects/sybase/DropViewTest.java b/modules/database/database-sql-sybase/src/test/java/org/eclipse/dirigible/database/sql/dialects/sybase/DropViewTest.java deleted file mode 100644 index c4ba5a0997c..00000000000 --- a/modules/database/database-sql-sybase/src/test/java/org/eclipse/dirigible/database/sql/dialects/sybase/DropViewTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2024 Eclipse Dirigible contributors - * - * All rights reserved. This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v2.0 which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v20.html - * - * SPDX-FileCopyrightText: Eclipse Dirigible contributors SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.dirigible.database.sql.dialects.sybase; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.eclipse.dirigible.database.sql.SqlFactory; -import org.junit.Test; - -/** - * The Class DropViewTest. - */ -public class DropViewTest { - - /** - * Drop view. - */ - @Test - public void dropView() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .drop() - .view("CUSTOMERS_VIEW") - .build(); - - assertNotNull(sql); - assertEquals("DROP VIEW CUSTOMERS_VIEW", sql); - } - -} diff --git a/modules/database/database-sql-sybase/src/test/java/org/eclipse/dirigible/database/sql/dialects/sybase/InsertTest.java b/modules/database/database-sql-sybase/src/test/java/org/eclipse/dirigible/database/sql/dialects/sybase/InsertTest.java deleted file mode 100644 index a84c67c912a..00000000000 --- a/modules/database/database-sql-sybase/src/test/java/org/eclipse/dirigible/database/sql/dialects/sybase/InsertTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2024 Eclipse Dirigible contributors - * - * All rights reserved. This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v2.0 which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v20.html - * - * SPDX-FileCopyrightText: Eclipse Dirigible contributors SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.dirigible.database.sql.dialects.sybase; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.eclipse.dirigible.database.sql.SqlFactory; -import org.junit.Test; - -/** - * The Class InsertTest. - */ -public class InsertTest { - - /** - * Insert simple. - */ - @Test - public void insertSimple() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .insert() - .into("CUSTOMERS") - .column("FIRST_NAME") - .column("LAST_NAME") - .build(); - - assertNotNull(sql); - assertEquals("INSERT INTO CUSTOMERS (FIRST_NAME, LAST_NAME) VALUES (?, ?)", sql); - } - - /** - * Insert values. - */ - @Test - public void insertValues() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .insert() - .into("CUSTOMERS") - .column("FIRST_NAME") - .column("LAST_NAME") - .value("?") - .value("'Smith'") - .build(); - - assertNotNull(sql); - assertEquals("INSERT INTO CUSTOMERS (FIRST_NAME, LAST_NAME) VALUES (?, 'Smith')", sql); - } - - /** - * Insert select. - */ - @Test - public void insertSelect() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .insert() - .into("CUSTOMERS") - .column("FIRST_NAME") - .column("LAST_NAME") - .select(SqlFactory.getNative(new SybaseSqlDialect()) - .select() - .column("*") - .from("SUPPLIERS") - .build()) - .build(); - - assertNotNull(sql); - assertEquals("INSERT INTO CUSTOMERS (FIRST_NAME, LAST_NAME) SELECT * FROM SUPPLIERS", sql); - } - -} diff --git a/modules/database/database-sql-sybase/src/test/java/org/eclipse/dirigible/database/sql/dialects/sybase/SelectTest.java b/modules/database/database-sql-sybase/src/test/java/org/eclipse/dirigible/database/sql/dialects/sybase/SelectTest.java deleted file mode 100644 index 67a99816e22..00000000000 --- a/modules/database/database-sql-sybase/src/test/java/org/eclipse/dirigible/database/sql/dialects/sybase/SelectTest.java +++ /dev/null @@ -1,364 +0,0 @@ -/* - * Copyright (c) 2024 Eclipse Dirigible contributors - * - * All rights reserved. This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v2.0 which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v20.html - * - * SPDX-FileCopyrightText: Eclipse Dirigible contributors SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.dirigible.database.sql.dialects.sybase; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.eclipse.dirigible.database.sql.SqlFactory; -import org.junit.Test; - -/** - * The Class SelectTest. - */ -public class SelectTest { - - /** - * Select star. - */ - @Test - public void selectStar() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .select() - .column("*") - .from("CUSTOMERS") - .build(); - - assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS", sql); - } - - /** - * Select columns from table. - */ - @Test - public void selectColumnsFromTable() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .select() - .column("FIRST_NAME") - .column("LAST_NAME") - .from("CUSTOMERS") - .build(); - - assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS", sql); - } - - /** - * Select columns from table aliases. - */ - @Test - public void selectColumnsFromTableAliases() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .select() - .column("c.FIRST_NAME") - .column("c.LAST_NAME") - .from("CUSTOMERS", "c") - .build(); - - assertNotNull(sql); - assertEquals("SELECT c.FIRST_NAME, c.LAST_NAME FROM CUSTOMERS AS c", sql); - } - - /** - * Select columns from table join. - */ - @Test - public void selectColumnsFromTableJoin() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .select() - .column("FIRST_NAME") - .column("LAST_NAME") - .from("CUSTOMERS") - .join("ADDRESSES", "CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID") - .build(); - - assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS INNER JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); - } - - /** - * Select columns from table inner join. - */ - @Test - public void selectColumnsFromTableInnerJoin() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .select() - .column("FIRST_NAME") - .column("LAST_NAME") - .from("CUSTOMERS") - .innerJoin("ADDRESSES", "CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID") - .build(); - - assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS INNER JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); - } - - /** - * Select columns from table outer join. - */ - @Test - public void selectColumnsFromTableOuterJoin() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .select() - .column("FIRST_NAME") - .column("LAST_NAME") - .from("CUSTOMERS") - .outerJoin("ADDRESSES", "CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID") - .build(); - - assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS OUTER JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); - } - - /** - * Select columns from table left join. - */ - @Test - public void selectColumnsFromTableLeftJoin() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .select() - .column("FIRST_NAME") - .column("LAST_NAME") - .from("CUSTOMERS") - .leftJoin("ADDRESSES", "CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID") - .build(); - - assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS LEFT JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); - } - - /** - * Select columns from table right join. - */ - @Test - public void selectColumnsFromTableRightJoin() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .select() - .column("FIRST_NAME") - .column("LAST_NAME") - .from("CUSTOMERS") - .rightJoin("ADDRESSES", "CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID") - .build(); - - assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS RIGHT JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); - } - - /** - * Select columns from table full join. - */ - @Test - public void selectColumnsFromTableFullJoin() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .select() - .column("FIRST_NAME") - .column("LAST_NAME") - .from("CUSTOMERS") - .fullJoin("ADDRESSES", "CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID") - .build(); - - assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS FULL JOIN ADDRESSES ON CUSTOMERS.ADDRESS_ID=ADDRESSES.ADDRESS_ID", sql); - } - - /** - * Select distinct columns from table. - */ - @Test - public void selectDistinctColumnsFromTable() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .select() - .distinct() - .column("FIRST_NAME") - .column("LAST_NAME") - .from("CUSTOMERS") - .build(); - - assertNotNull(sql); - assertEquals("SELECT DISTINCT FIRST_NAME, LAST_NAME FROM CUSTOMERS", sql); - } - - /** - * Select columns from table order by and desc. - */ - @Test - public void selectColumnsFromTableOrderByAndDesc() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .select() - .column("FIRST_NAME") - .column("LAST_NAME") - .from("CUSTOMERS") - .order("FIRST_NAME") - .order("LAST_NAME", false) - .build(); - - assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS ORDER BY FIRST_NAME ASC, LAST_NAME DESC", sql); - } - - /** - * Select columns from table group by. - */ - @Test - public void selectColumnsFromTableGroupBy() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .select() - .column("FIRST_NAME") - .column("LAST_NAME") - .from("CUSTOMERS") - .group("FIRST_NAME") - .build(); - - assertNotNull(sql); - assertEquals("SELECT FIRST_NAME, LAST_NAME FROM CUSTOMERS GROUP BY FIRST_NAME", sql); - } - - /** - * Select where simple. - */ - @Test - public void selectWhereSimple() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .select() - .column("*") - .from("CUSTOMERS") - .where("PRICE > ?") - .build(); - - assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS WHERE (PRICE > ?)", sql); - } - - /** - * Select where and. - */ - @Test - public void selectWhereAnd() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .select() - .column("*") - .from("CUSTOMERS") - .where("PRICE > ?") - .where("AMOUNT < ?") - .build(); - - assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS WHERE (PRICE > ?) AND (AMOUNT < ?)", sql); - } - - /** - * Select where or. - */ - @Test - public void selectWhereOr() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .select() - .column("*") - .from("CUSTOMERS") - .where("PRICE > ? OR AMOUNT < ?") - .build(); - - assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS WHERE (PRICE > ? OR AMOUNT < ?)", sql); - } - - /** - * Select where expr. - */ - @Test - public void selectWhereExpr() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .select() - .column("*") - .from("CUSTOMERS") - .where(SqlFactory.getNative(new SybaseSqlDialect()) - .expression() - .and("PRICE > ?") - .or("AMOUNT < ?") - .build()) - .build(); - - assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS WHERE (PRICE > ? OR AMOUNT < ?)", sql); - } - - /** - * Select limit. - */ - @Test - public void selectLimit() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .select() - .column("*") - .from("CUSTOMERS") - .limit(10) - .build(); - - assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS ROWS LIMIT 10", sql); - } - - /** - * Select limit offset. - */ - @Test - public void selectLimitOffset() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .select() - .column("*") - .from("CUSTOMERS") - .limit(10) - .offset(20) - .build(); - - assertNotNull(sql); - assertEquals("SELECT * FROM CUSTOMERS ROWS LIMIT 10 OFFSET 20", sql); - } - - /** - * Select having. - */ - @Test - public void selectHaving() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .select() - .column("COUNT(FIRST_NAME)") - .column("COUNTRY") - .from("CUSTOMERS") - .group("COUNTRY") - .having("COUNT(FIRST_NAME) > 5") - .build(); - - assertNotNull(sql); - assertEquals("SELECT COUNT(FIRST_NAME), COUNTRY FROM CUSTOMERS GROUP BY COUNTRY HAVING COUNT(FIRST_NAME) > 5", sql); - } - - /** - * Select union. - */ - @Test - public void selectUnion() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .select() - .column("COUNTRY") - .from("CUSTOMERS") - .union(SqlFactory.getNative(new SybaseSqlDialect()) - .select() - .column("COUNTRY") - .from("SUPPLIERS") - .build()) - .build(); - - assertNotNull(sql); - assertEquals("SELECT COUNTRY FROM CUSTOMERS UNION SELECT COUNTRY FROM SUPPLIERS", sql); - } - -} diff --git a/modules/database/database-sql-sybase/src/test/java/org/eclipse/dirigible/database/sql/dialects/sybase/SequenceTest.java b/modules/database/database-sql-sybase/src/test/java/org/eclipse/dirigible/database/sql/dialects/sybase/SequenceTest.java deleted file mode 100644 index 594e952ea11..00000000000 --- a/modules/database/database-sql-sybase/src/test/java/org/eclipse/dirigible/database/sql/dialects/sybase/SequenceTest.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2024 Eclipse Dirigible contributors - * - * All rights reserved. This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v2.0 which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v20.html - * - * SPDX-FileCopyrightText: Eclipse Dirigible contributors SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.dirigible.database.sql.dialects.sybase; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; - -import org.eclipse.dirigible.database.sql.SqlFactory; -import org.junit.Test; - -/** - * The Class SequenceTest. - */ -public class SequenceTest { - - /** - * Creates the sequence. - */ - @Test - public void createSequence() { - try { - SqlFactory.getNative(new SybaseSqlDialect()) - .create() - .sequence("CUSTOMERS_SEQUENCE") - .build(); - } catch (Exception e) { - return; - } - - fail("Does Sybase support Sequences?"); - } - - /** - * Alter sequence. - */ - @Test - public void alterSequence() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .alter() - .sequence("CUSTOMERS_SEQUENCE") - .build(); - - assertNotNull(sql); - assertEquals("ALTER SEQUENCE CUSTOMERS_SEQUENCE", sql); - } - - /** - * Drop sequnce. - */ - @Test - public void dropSequnce() { - try { - SqlFactory.getNative(new SybaseSqlDialect()) - .drop() - .sequence("CUSTOMERS_SEQUENCE") - .build(); - } catch (Exception e) { - return; - } - - fail("Does Sybase support Sequences?"); - } - - /** - * Nextval sequnce. - */ - @Test - public void nextvalSequnce() { - try { - SqlFactory.getNative(new SybaseSqlDialect()) - .nextval("CUSTOMERS_SEQUENCE") - .build(); - } catch (Exception e) { - return; - } - - fail("Does Sybase support Sequences?"); - } - -} diff --git a/modules/database/database-sql-sybase/src/test/java/org/eclipse/dirigible/database/sql/dialects/sybase/UpdateTest.java b/modules/database/database-sql-sybase/src/test/java/org/eclipse/dirigible/database/sql/dialects/sybase/UpdateTest.java deleted file mode 100644 index b2462b46d0e..00000000000 --- a/modules/database/database-sql-sybase/src/test/java/org/eclipse/dirigible/database/sql/dialects/sybase/UpdateTest.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2024 Eclipse Dirigible contributors - * - * All rights reserved. This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v2.0 which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v20.html - * - * SPDX-FileCopyrightText: Eclipse Dirigible contributors SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.dirigible.database.sql.dialects.sybase; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.eclipse.dirigible.database.sql.SqlFactory; -import org.junit.Test; - -/** - * The Class UpdateTest. - */ -public class UpdateTest { - - /** - * Update simple. - */ - @Test - public void updateSimple() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .update() - .table("CUSTOMERS") - .set("FIRST_NAME", "'John'") - .build(); - - assertNotNull(sql); - assertEquals("UPDATE CUSTOMERS SET FIRST_NAME = 'John'", sql); - } - - /** - * Update values. - */ - @Test - public void updateValues() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .update() - .table("CUSTOMERS") - .set("FIRST_NAME", "'John'") - .set("LAST_NAME", "'Smith'") - .build(); - - assertNotNull(sql); - assertEquals("UPDATE CUSTOMERS SET FIRST_NAME = 'John', LAST_NAME = 'Smith'", sql); - } - - /** - * Update where. - */ - @Test - public void updateWhere() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .update() - .table("CUSTOMERS") - .set("FIRST_NAME", "'John'") - .set("LAST_NAME", "'Smith'") - .where("AGE > ?") - .where("COMPANY = 'SAP'") - .build(); - - assertNotNull(sql); - assertEquals("UPDATE CUSTOMERS SET FIRST_NAME = 'John', LAST_NAME = 'Smith' WHERE (AGE > ?) AND (COMPANY = 'SAP')", sql); - } - - /** - * Update where select. - */ - @Test - public void updateWhereSelect() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .update() - .table("CUSTOMERS") - .set("FIRST_NAME", "'John'") - .set("SALARY", SqlFactory.getNative(new SybaseSqlDialect()) - .select() - .column("MAX(SALARY)") - .from("BENEFITS") - .build()) - .where("COMPANY = 'SAP'") - .build(); - - assertNotNull(sql); - assertEquals("UPDATE CUSTOMERS SET FIRST_NAME = 'John', SALARY = SELECT MAX(SALARY) FROM BENEFITS WHERE (COMPANY = 'SAP')", sql); - } - - /** - * Update where expr. - */ - @Test - public void updateWhereExpr() { - String sql = SqlFactory.getNative(new SybaseSqlDialect()) - .update() - .table("CUSTOMERS") - .set("FIRST_NAME", "'John'") - .set("LAST_NAME", "'Smith'") - .where(SqlFactory.getNative(new SybaseSqlDialect()) - .expression() - .and("PRICE > ?") - .or("AMOUNT < ?") - .and("COMPANY = 'SAP'") - .build()) - .build(); - - assertNotNull(sql); - assertEquals("UPDATE CUSTOMERS SET FIRST_NAME = 'John', LAST_NAME = 'Smith' WHERE (PRICE > ? OR AMOUNT < ? AND COMPANY = 'SAP')", - sql); - } - -} diff --git a/modules/database/database-sql/src/main/java/org/eclipse/dirigible/database/sql/ISqlDialect.java b/modules/database/database-sql/src/main/java/org/eclipse/dirigible/database/sql/ISqlDialect.java index c2ff63962ca..01610984607 100644 --- a/modules/database/database-sql/src/main/java/org/eclipse/dirigible/database/sql/ISqlDialect.java +++ b/modules/database/database-sql/src/main/java/org/eclipse/dirigible/database/sql/ISqlDialect.java @@ -217,7 +217,7 @@ public interface ISqlDialect