Browse Source

fix: mssql default value query fails for text & ntext

Re #2766

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/2751/head
mertmit 2 years ago
parent
commit
54e5cb8e87
  1. 8
      packages/nocodb/src/lib/db/sql-client/lib/mssql/MssqlClient.ts

8
packages/nocodb/src/lib/db/sql-client/lib/mssql/MssqlClient.ts

@ -2379,13 +2379,13 @@ class MssqlClient extends KnexClient {
return this.schema ? `${this.schema}.${t}` : t;
}
alterTableRemoveColumn(t, n, o, existingQuery) {
alterTableRemoveColumn(t, n, _o, existingQuery) {
const shouldSanitize = true;
let query = existingQuery ? ';' : '';
if (n.cdf) {
query += this.genQuery(
`\nALTER TABLE ?? DROP CONSTRAINT ??;`,
[this.getTnPath(t), o.default_constraint_name || `DF_${t}_${n.cn}`],
[this.getTnPath(t), n.default_constraint_name || `DF_${t}_${n.cn}`],
shouldSanitize
);
}
@ -2625,6 +2625,10 @@ function getDefaultValue(n) {
}
return JSON.stringify(n.cdf);
break;
case 'text':
case 'ntext':
return `'${n.cdf}'`;
break;
default:
return JSON.stringify(n.cdf);
break;

Loading…
Cancel
Save