mirror of
https://github.com/nocodb/nocodb.git
synced 2026-02-01 22:08:33 +00:00
fix: truncate long text in query level
This commit is contained in:
@@ -16,7 +16,8 @@ if (!NC_REFRESH_TOKEN_EXP_IN_DAYS || NC_REFRESH_TOKEN_EXP_IN_DAYS <= 0) {
|
||||
throw new Error('NC_REFRESH_TOKEN_EXP_IN_DAYS must be a positive number');
|
||||
}
|
||||
|
||||
export const NC_MAX_TEXT_LENGTH = 100000;
|
||||
export const NC_MAX_TEXT_LENGTH =
|
||||
+process.env['NC_MAX_TEXT_LENGTH'] || 100000;
|
||||
|
||||
export const NC_EMAIL_ASSETS_BASE_URL = 'https://cdn.nocodb.com/emails/v2';
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
shouldSkipField,
|
||||
} from '~/helpers/dbHelpers';
|
||||
import { sanitize } from '~/helpers/sqlSanitize';
|
||||
import { NC_MAX_TEXT_LENGTH } from '~/constants';
|
||||
|
||||
export const selectObject = (baseModel: IBaseModelSqlV2, logger: Logger) => {
|
||||
return async ({
|
||||
@@ -433,6 +434,38 @@ export const selectObject = (baseModel: IBaseModelSqlV2, logger: Logger) => {
|
||||
]);
|
||||
break;
|
||||
}
|
||||
case UITypes.LongText: {
|
||||
const colPath = sanitize(
|
||||
`${alias || baseModel.tnPath}.${column.column_name}`,
|
||||
);
|
||||
if (baseModel.isPg) {
|
||||
res[sanitize(getAs(column) || column.column_name)] =
|
||||
baseModel.dbDriver.raw(`SUBSTR(??::TEXT, 1, ?)`, [
|
||||
colPath,
|
||||
NC_MAX_TEXT_LENGTH,
|
||||
]);
|
||||
} else if (baseModel.isMySQL) {
|
||||
res[sanitize(getAs(column) || column.column_name)] =
|
||||
baseModel.dbDriver.raw(`SUBSTR(??, 1, ?)`, [
|
||||
colPath,
|
||||
NC_MAX_TEXT_LENGTH,
|
||||
]);
|
||||
} else if (baseModel.isSqlite) {
|
||||
res[sanitize(getAs(column) || column.column_name)] =
|
||||
baseModel.dbDriver.raw(`SUBSTR(??, 1, ?)`, [
|
||||
colPath,
|
||||
NC_MAX_TEXT_LENGTH,
|
||||
]);
|
||||
} else {
|
||||
// SQL Server / other databases - use LEFT function
|
||||
res[sanitize(getAs(column) || column.column_name)] =
|
||||
baseModel.dbDriver.raw(`LEFT(??, ?)`, [
|
||||
colPath,
|
||||
NC_MAX_TEXT_LENGTH,
|
||||
]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
if (baseModel.isPg) {
|
||||
if (column.dt === 'bytea') {
|
||||
|
||||
Reference in New Issue
Block a user