π₯ π₯ π₯ A Free & Self-hostable Airtable Alternative
TypeScript airtableairtable-alternativeautomatic-apihacktoberfestlow-codeno-codeno-code-databaseno-code-platformpostgresqlrest-apirestful-apispreadsheetsqliteswagger
fix: truncate long text in query level
DarkPhoenix2704f05f9db15ebc
diff --git a/packages/nocodb/src/constants/index.ts b/packages/nocodb/src/constants/index.tsindex 507a429916..1d343b077e 100644--- a/packages/nocodb/src/constants/index.ts+++ b/packages/nocodb/src/constants/index.ts@@ -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';diff --git a/packages/nocodb/src/db/BaseModelSqlv2/select-object.ts b/packages/nocodb/src/db/BaseModelSqlv2/select-object.tsindex 4fad05bce6..c07a92eda2 100644--- a/packages/nocodb/src/db/BaseModelSqlv2/select-object.ts+++ b/packages/nocodb/src/db/BaseModelSqlv2/select-object.ts@@ -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') {