Database name not quoted at schema update

Description

The fix for requires some improvements to make it work. Otherwise the symptoms reported in the original bug can easily be reproduced.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "alter table NEW-UPGRADE33-SQL2012.dbo.ARTIFACT_DEFINITION add REQUIRED_ARTIFACT tinyint default 0 not null" via JDBC Statement at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67) at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlString(AbstractSchemaMigrator.java:559) at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlStrings(AbstractSchemaMigrator.java:580) at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.migrateTable(AbstractSchemaMigrator.java:297) at org.hibernate.tool.schema.internal.GroupedSchemaMigratorImpl.performTablesMigration(GroupedSchemaMigratorImpl.java:75) at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.performMigration(AbstractSchemaMigrator.java:207) at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.doMigration(AbstractSchemaMigrator.java:114) at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:94) at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:62) at com.atlassian.bamboo.hibernate.BambooSchemaHelper.updateSchemaIfNeeded(BambooSchemaHelper.java:42) ... 15 more Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '-'. at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:232) at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1672) at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(SQLServerStatement.java:903) at com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(SQLServerStatement.java:796) at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7535) at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2438) at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:208) at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:183) at com.microsoft.sqlserver.jdbc.SQLServerStatement.execute(SQLServerStatement.java:769) at com.mchange.v2.c3p0.impl.NewProxyStatement.execute(NewProxyStatement.java:75) at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54) ... 24 more

Environment

None

Status

Assignee

Unassigned

Reporter

Przemek Bruski

Fix versions

Labels

None

backPortable

Backport?

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Worked in

5.2.10

Components

Affects versions

5.2.12

Priority

Major