Skip to content

Commit

Permalink
Fixed: #4682 - MSSQL: Doesn't support (n CHAR) syntax, but only (n) s…
Browse files Browse the repository at this point in the history
…yntax.
  • Loading branch information
mkarg authored and MalloD12 committed Aug 30, 2023
1 parent d233ed0 commit 285a987
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Expand Up @@ -22,7 +22,9 @@ public DatabaseDataType toDatabaseDataType(Database database) {
if (database instanceof MSSQLDatabase) {
Object[] parameters = getParameters();
if (parameters.length > 0) {
String param1 = parameters[0].toString();
// MSSQL only supports (n) syntax but not (n CHAR) syntax, so we need to remove CHAR.
final String param1 = parameters[0].toString().replaceFirst("(?<=\\d+)\\s*(?i)CHAR$", "");
parameters[0] = param1;
if (!param1.matches("\\d+") || (new BigInteger(param1).compareTo(BigInteger.valueOf(8000)) > 0)) {

DatabaseDataType type = new DatabaseDataType(database.escapeDataTypeName("char"), 8000);
Expand Down
Expand Up @@ -26,7 +26,9 @@ public DatabaseDataType toDatabaseDataType(Database database) {
if (database instanceof MSSQLDatabase) {
Object[] parameters = getParameters();
if (parameters.length > 0) {
String param1 = parameters[0].toString();
// MSSQL only supports (n) syntax but not (n CHAR) syntax, so we need to remove CHAR.
final String param1 = parameters[0].toString().replaceFirst("(?<=\\d+)\\s*(?i)CHAR$", "");
parameters[0] = param1;
if (!param1.matches("\\d+") || (new BigInteger(param1).compareTo(BigInteger.valueOf(8000L)) > 0)) {

DatabaseDataType type = new DatabaseDataType(database.escapeDataTypeName("varchar"), "MAX");
Expand Down

0 comments on commit 285a987

Please sign in to comment.