Browse Source

Merge branch 'develop' into feat/pnpm

pull/5903/head
Wing-Kam Wong 1 year ago
parent
commit
2caaad4563
  1. 2
      packages/nc-lib-gui/package.json
  2. 2
      packages/nocodb-sdk/package.json
  3. 4
      packages/nocodb/package.json
  4. 20
      packages/nocodb/src/db/BaseModelSqlv2.ts
  5. 2
      packages/nocodb/src/db/conditionV2.ts
  6. 24
      packages/nocodb/src/models/Column.ts
  7. 59
      packages/nocodb/src/services/meta-diffs.service.ts
  8. 2
      packages/nocodb/src/services/users/users.service.ts

2
packages/nc-lib-gui/package.json

@ -1,6 +1,6 @@
{ {
"name": "nc-lib-gui", "name": "nc-lib-gui",
"version": "0.109.3", "version": "0.109.4",
"description": "NocoDB GUI", "description": "NocoDB GUI",
"author": { "author": {
"name": "NocoDB", "name": "NocoDB",

2
packages/nocodb-sdk/package.json

@ -1,6 +1,6 @@
{ {
"name": "nocodb-sdk", "name": "nocodb-sdk",
"version": "0.109.3", "version": "0.109.4",
"description": "NocoDB SDK", "description": "NocoDB SDK",
"main": "build/main/index.js", "main": "build/main/index.js",
"typings": "build/main/index.d.ts", "typings": "build/main/index.d.ts",

4
packages/nocodb/package.json

@ -1,6 +1,6 @@
{ {
"name": "nocodb", "name": "nocodb",
"version": "0.109.3", "version": "0.109.4",
"description": "NocoDB Backend", "description": "NocoDB Backend",
"main": "dist/bundle.js", "main": "dist/bundle.js",
"author": { "author": {
@ -119,7 +119,7 @@
"mysql2": "^3.2.0", "mysql2": "^3.2.0",
"nanoid": "^3.1.20", "nanoid": "^3.1.20",
"nc-help": "^0.2.88", "nc-help": "^0.2.88",
"nc-lib-gui": "0.109.3", "nc-lib-gui": "0.109.4",
"nc-plugin": "^0.1.3", "nc-plugin": "^0.1.3",
"ncp": "^2.0.0", "ncp": "^2.0.0",
"nocodb-sdk": "file:../nocodb-sdk", "nocodb-sdk": "file:../nocodb-sdk",

20
packages/nocodb/src/db/BaseModelSqlv2.ts

@ -3966,7 +3966,25 @@ function _wherePk(primaryKeys: Column[], id) {
const ids = (id + '').split('___'); const ids = (id + '').split('___');
const where = {}; const where = {};
for (let i = 0; i < primaryKeys.length; ++i) { for (let i = 0; i < primaryKeys.length; ++i) {
where[primaryKeys[i].column_name] = ids[i]; //Cast the id to string.
const idAsString = ids[i] + '';
// Check if the id is a UUID and the column is binary(16)
const isUUIDBinary16 =
primaryKeys[i].ct === 'binary(16)' &&
(idAsString.length === 36 || idAsString.length === 32);
// If the id is a UUID and the column is binary(16), convert the id to a Buffer. Otherwise, return null to indicate that the id is not a UUID.
const idAsUUID = isUUIDBinary16
? idAsString.length === 32
? idAsString.replace(
/(.{8})(.{4})(.{4})(.{4})(.{12})/,
'$1-$2-$3-$4-$5',
)
: idAsString
: null;
where[primaryKeys[i].column_name] = idAsUUID
? Buffer.from(idAsUUID.replace(/-/g, ''), 'hex')
: ids[i];
} }
return where; return where;
} }

2
packages/nocodb/src/db/conditionV2.ts

@ -419,6 +419,8 @@ const parseConditionV2 = async (
].includes(column.uidt) ].includes(column.uidt)
) { ) {
qb = qb.where(field, val); qb = qb.where(field, val);
} else if (column.ct === 'timestamp') {
qb = qb.whereRaw('DATE(??) = DATE(?)', [field, val]);
} else { } else {
// mysql is case-insensitive for strings, turn to case-sensitive // mysql is case-insensitive for strings, turn to case-sensitive
qb = qb.whereRaw('BINARY ?? = ?', [field, val]); qb = qb.whereRaw('BINARY ?? = ?', [field, val]);

24
packages/nocodb/src/models/Column.ts

@ -1075,6 +1075,30 @@ export default class Column<T = any> implements ColumnType {
// set cache // set cache
await NocoCache.set(key, o); await NocoCache.set(key, o);
} }
// get model column list from cache
const columnListFromCache = await NocoCache.getList(CacheScope.COLUMN, [
oldCol.fk_model_id,
]);
// update column list in cache if cache exists
if (!columnListFromCache.list?.length) {
const updatedColumnList = columnListFromCache.list.map((column: any) => {
if (column.id === colId) {
return {
...column,
...updateObj,
};
}
return column;
});
await NocoCache.setList(
CacheScope.COLUMN,
[oldCol.fk_model_id],
updatedColumnList,
);
}
// set meta // set meta
await ncMeta.metaUpdate( await ncMeta.metaUpdate(
null, null,

59
packages/nocodb/src/services/meta-diffs.service.ts

@ -17,6 +17,7 @@ export enum MetaDiffType {
TABLE_REMOVE = 'TABLE_REMOVE', TABLE_REMOVE = 'TABLE_REMOVE',
TABLE_COLUMN_ADD = 'TABLE_COLUMN_ADD', TABLE_COLUMN_ADD = 'TABLE_COLUMN_ADD',
TABLE_COLUMN_TYPE_CHANGE = 'TABLE_COLUMN_TYPE_CHANGE', TABLE_COLUMN_TYPE_CHANGE = 'TABLE_COLUMN_TYPE_CHANGE',
TABLE_COLUMN_PROPS_CHANGED = 'TABLE_COLUMN_PROPS_CHANGED',
TABLE_COLUMN_REMOVE = 'TABLE_COLUMN_REMOVE', TABLE_COLUMN_REMOVE = 'TABLE_COLUMN_REMOVE',
VIEW_NEW = 'VIEW_NEW', VIEW_NEW = 'VIEW_NEW',
VIEW_REMOVE = 'VIEW_REMOVE', VIEW_REMOVE = 'VIEW_REMOVE',
@ -103,6 +104,15 @@ type MetaDiffChange = {
relationType: RelationTypes; relationType: RelationTypes;
cstn?: string; cstn?: string;
} }
| {
type: MetaDiffType.TABLE_COLUMN_PROPS_CHANGED;
tn?: string;
model?: Model;
id?: string;
cn: string;
column: Column;
colId?: string;
}
); );
@Injectable() @Injectable()
@ -217,6 +227,21 @@ export class MetaDiffsService {
column: oldCol, column: oldCol,
}); });
} }
if (
!!oldCol.pk !== !!column.pk ||
!!oldCol.rqd !== !!column.rqd ||
!!oldCol.un !== !!column.un ||
!!oldCol.ai !== !!column.ai ||
!!oldCol.unique !== !!column.unique
) {
tableProp.detectedChanges.push({
type: MetaDiffType.TABLE_COLUMN_PROPS_CHANGED,
msg: `Column properties changed (${column.cn})`,
cn: oldCol.column_name,
id: oldMeta.id,
column: oldCol,
});
}
} }
for (const column of oldMeta.columns) { for (const column of oldMeta.columns) {
if ( if (
@ -688,6 +713,23 @@ export class MetaDiffsService {
await Column.update(change.column.id, column); await Column.update(change.column.id, column);
} }
break; break;
case MetaDiffType.TABLE_COLUMN_PROPS_CHANGED:
{
const columns = (
await sqlClient.columnList({ tn: table_name })
)?.data?.list?.map((c) => ({ ...c, column_name: c.cn }));
const colMeta = columns.find((c) => c.cn === change.cn);
if (!colMeta) break;
const { pk, ai, rqd, un, unique } = colMeta;
await Column.update(change.column.id, {
pk,
ai,
rqd,
un,
unique,
});
}
break;
case MetaDiffType.TABLE_COLUMN_REMOVE: case MetaDiffType.TABLE_COLUMN_REMOVE:
case MetaDiffType.VIEW_COLUMN_REMOVE: case MetaDiffType.VIEW_COLUMN_REMOVE:
await change.column.delete(); await change.column.delete();
@ -884,6 +926,23 @@ export class MetaDiffsService {
await Column.update(change.column.id, column); await Column.update(change.column.id, column);
} }
break; break;
case MetaDiffType.TABLE_COLUMN_PROPS_CHANGED:
{
const columns = (
await sqlClient.columnList({ tn: table_name })
)?.data?.list?.map((c) => ({ ...c, column_name: c.cn }));
const colMeta = columns.find((c) => c.cn === change.cn);
if (!colMeta) break;
const { pk, ai, rqd, un, unique } = colMeta;
await Column.update(change.column.id, {
pk,
ai,
rqd,
un,
unique,
});
}
break;
case MetaDiffType.TABLE_COLUMN_REMOVE: case MetaDiffType.TABLE_COLUMN_REMOVE:
case MetaDiffType.VIEW_COLUMN_REMOVE: case MetaDiffType.VIEW_COLUMN_REMOVE:
await change.column.delete(); await change.column.delete();

2
packages/nocodb/src/services/users/users.service.ts

@ -503,7 +503,7 @@ export class UsersService {
if (user?.id) { if (user?.id) {
await User.update(user.id, { await User.update(user.id, {
refresh_token: null, refresh_token: null,
token_version: null, token_version: randomTokenString(),
}); });
} }
return { msg: 'Signed out successfully' }; return { msg: 'Signed out successfully' };

Loading…
Cancel
Save