Skip to content

Commit

Permalink
rector: updated max length of test field
Browse files Browse the repository at this point in the history
  • Loading branch information
MXPOL committed Nov 28, 2023
1 parent af90b3c commit 67399e5
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion libs/external-db-mssql/src/sql_schema_translator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('Sql Schema Column Translator', () => {

describe('string fields', () => {
test('string', () => {
expect( env.schemaTranslator.columnToDbColumnSql({ name: ctx.fieldName, type: 'text', subtype: 'string' }) ).toEqual(`${escapeId(ctx.fieldName)} VARCHAR(4096)`)
expect( env.schemaTranslator.columnToDbColumnSql({ name: ctx.fieldName, type: 'text', subtype: 'string' }) ).toEqual(`${escapeId(ctx.fieldName)} VARCHAR(65535)`)
})

test('string with length', () => {
Expand Down
4 changes: 2 additions & 2 deletions libs/external-db-mssql/src/sql_schema_translator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ export default class SchemaColumnTranslator {
try {
const parsed = parseInt(length as string)
if (isNaN(parsed) || parsed <= 0) {
return '(4096)'
return '(65535)'
}
return `(${parsed})`
} catch (e) {
return '(4096)'
return '(65535)'
}
}

Expand Down
2 changes: 1 addition & 1 deletion libs/external-db-mysql/src/sql_schema_translator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('Sql Schema Column Translator', () => {

describe('string fields', () => {
test('string', () => {
expect( env.schemaTranslator.columnToDbColumnSql({ name: ctx.fieldName, type: 'text', subtype: 'string' }) ).toEqual(`${escapeId(ctx.fieldName)} VARCHAR(4096)`)
expect( env.schemaTranslator.columnToDbColumnSql({ name: ctx.fieldName, type: 'text', subtype: 'string' }) ).toEqual(`${escapeId(ctx.fieldName)} VARCHAR(65535)`)
})

test('string with length', () => {
Expand Down
4 changes: 2 additions & 2 deletions libs/external-db-mysql/src/sql_schema_translator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ export default class SchemaColumnTranslato {
try {
const parsed = parseInt(length)
if (isNaN(parsed) || parsed <= 0) {
return '(4096)'
return '(65535)'
}
return `(${parsed})`
} catch (e) {
return '(4096)'
return '(65535)'
}
}

Expand Down
4 changes: 2 additions & 2 deletions libs/external-db-spanner/src/sql_schema_translator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('Sql Schema Column Translator', () => {

describe('string fields', () => {
test('string', () => {
expect( env.schemaTranslator.columnToDbColumnSql({ name: ctx.fieldName, type: 'text', subtype: 'string' }) ).toEqual(`${escapeId(ctx.fieldName)} STRING(2048)`)
expect( env.schemaTranslator.columnToDbColumnSql({ name: ctx.fieldName, type: 'text', subtype: 'string' }) ).toEqual(`${escapeId(ctx.fieldName)} STRING(65535)`)
})

test('string with length', () => {
Expand All @@ -76,7 +76,7 @@ describe('Sql Schema Column Translator', () => {
})

test('text language', () => {
expect( env.schemaTranslator.columnToDbColumnSql({ name: ctx.fieldName, type: 'text', subtype: 'language' }) ).toEqual(`${escapeId(ctx.fieldName)} STRING(2048)`)
expect( env.schemaTranslator.columnToDbColumnSql({ name: ctx.fieldName, type: 'text', subtype: 'language' }) ).toEqual(`${escapeId(ctx.fieldName)} STRING(65535)`)
})
})

Expand Down
4 changes: 2 additions & 2 deletions libs/external-db-spanner/src/sql_schema_translator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ export default class SchemaColumnTranslator implements ISpannerSchemaColumnTrans
try {
const parsed = parseInt(length as string)
if (isNaN(parsed) || parsed <= 0) {
return '(2048)'
return '(65535)'
}
return `(${parsed})`
} catch (e) {
return '(2048)'
return '(65535)'
}
}

Expand Down
6 changes: 3 additions & 3 deletions libs/velo-external-db-core/src/utils/schema_utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ describe('Schema utils functions', () => {
})

describe('Precision for columns', () => {
test.each(FieldsWithPrecision)('%s column should have a precision of 50', (columnName,) => {
expect(fieldKeyToPrecision(columnName)).toEqual(50)
test.each(FieldsWithPrecision)('%s column should have a precision of 255', (columnName,) => {
expect(fieldKeyToPrecision(columnName)).toEqual(255)
})
test('other column should not have a precision', () => { expect(fieldKeyToPrecision(ctx.column.name)).toBeUndefined() })
})
Expand All @@ -126,7 +126,7 @@ describe('Schema utils functions', () => {
name: columnName,
type: 'text',
subtype: 'string',
precision: 50,
precision: 255,
})
})

Expand Down
2 changes: 1 addition & 1 deletion libs/velo-external-db-core/src/utils/schema_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export const responseFieldToWixFormat = (fields: ResponseField[]): collectionSpi
}

export const fieldKeyToPrecision = (fieldKey: string): number | undefined => {
return FieldsWithPrecision.includes(fieldKey) ? 50 : undefined
return FieldsWithPrecision.includes(fieldKey) ? 255 : undefined
}

export const wixFormatFieldToInputFields = (field: collectionSpi.Field): InputField => ({
Expand Down

0 comments on commit 67399e5

Please sign in to comment.