Skip to content

Commit

Permalink
Fix column type (#481)
Browse files Browse the repository at this point in the history
* Fix column type in SQL schema translator

* Fix column type in postgres schema translator
  • Loading branch information
MXPOL authored Dec 5, 2023
1 parent 41767c0 commit fc6ba95
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
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(2048)`)
expect( env.schemaTranslator.columnToDbColumnSql({ name: ctx.fieldName, type: 'text', subtype: 'string' }) ).toEqual(`${escapeId(ctx.fieldName)} TEXT`)
})

test('string with length', () => {
Expand Down
2 changes: 1 addition & 1 deletion libs/external-db-mysql/src/sql_schema_translator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default class SchemaColumnTranslato {
return 'TIMESTAMP DEFAULT CURRENT_TIMESTAMP'

case 'text_string':
return `VARCHAR${this.parseLength(precision)}`
return precision ? `VARCHAR${this.parseLength(precision)}` : 'TEXT'

case 'text_small':
case 'text_language':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('Sql Schema Column Translator', () => {

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

test('string with length', () => {
Expand Down
2 changes: 1 addition & 1 deletion libs/external-db-postgres/src/sql_schema_translator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default class SchemaColumnTranslator {
return 'timestamp'

case 'text_string':
return `varchar${this.parseLength(precision)}`
return precision ? `varchar${this.parseLength(precision)}` : 'text'

case 'text_small':
case 'text_medium':
Expand Down

0 comments on commit fc6ba95

Please sign in to comment.