Browse Source

Changes requested by review team.

pull/6017/head
VictorMinemu 1 year ago
parent
commit
cc99ccb4fd
  1. 24
      packages/nocodb/src/db/BaseModelSqlv2.ts
  2. 2
      packages/nocodb/src/db/conditionV2.ts

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

@ -3966,17 +3966,21 @@ 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) {
//Check if the id is a UUID and the column is binary(16) //Cast the id to string.
const idAsUUID = const idAsString = ids[i] + '';
// Check if the id is a UUID and the column is binary(16)
const isUUIDBinary16 =
primaryKeys[i].ct === 'binary(16)' && primaryKeys[i].ct === 'binary(16)' &&
((ids[i] + '').length === 36 || (ids[i] + '').length === 32) (idAsString.length === 36 || idAsString.length === 32);
? (ids[i] + '').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.
? (ids[i] + '').replace( const idAsUUID = isUUIDBinary16
/(.{8})(.{4})(.{4})(.{4})(.{12})/, ? idAsString.length === 32
'$1-$2-$3-$4-$5', ? idAsString.replace(
) /(.{8})(.{4})(.{4})(.{4})(.{12})/,
: ids[i] + '' '$1-$2-$3-$4-$5',
: null; )
: idAsString
: null;
where[primaryKeys[i].column_name] = idAsUUID where[primaryKeys[i].column_name] = idAsUUID
? Buffer.from(idAsUUID.replace(/-/g, ''), 'hex') ? Buffer.from(idAsUUID.replace(/-/g, ''), 'hex')

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

@ -419,7 +419,7 @@ const parseConditionV2 = async (
].includes(column.uidt) ].includes(column.uidt)
) { ) {
qb = qb.where(field, val); qb = qb.where(field, val);
} else if (column.ct == 'timestamp') { } else if (column.ct === 'timestamp') {
qb = qb.whereRaw('DATE(??) = DATE(?)', [field, val]); 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

Loading…
Cancel
Save