diff --git a/libs/external-db-bigquery/src/sql_schema_translator.spec.ts b/libs/external-db-bigquery/src/sql_schema_translator.spec.ts index 29075f444..8c2aed29b 100644 --- a/libs/external-db-bigquery/src/sql_schema_translator.spec.ts +++ b/libs/external-db-bigquery/src/sql_schema_translator.spec.ts @@ -70,9 +70,17 @@ describe('Sql Schema Column Translator', () => { }) describe('string fields', () => { - test('string', () => { - expect( env.schemaTranslator.columnToDbColumnSql({ name: ctx.fieldName, type: 'text', subtype: 'string' }) ).toEqual({ mode: '', name: escapeId(ctx.fieldName), type: 'STRING' }) - }) + test.each([ + 'string', + 'richcontent', + 'image', + 'video', + 'audio', + 'document', + 'language', + ])('%s', (subtype) => { + expect( env.schemaTranslator.columnToDbColumnSql({ name: ctx.fieldName, type: 'text', subtype }) ).toEqual({ mode: '', name: escapeId(ctx.fieldName), type: 'STRING' }) + }) test('string with length', () => { expect( env.schemaTranslator.columnToDbColumnSql({ name: ctx.fieldName, type: 'text', subtype: 'string', precision: '50' }) ).toEqual({ mode: '', name: escapeId(ctx.fieldName), type: 'STRING(50)' }) @@ -108,20 +116,15 @@ describe('Sql Schema Column Translator', () => { describe('JSON fields', () => { test.each([ - ['object'], - ['image'], - ['document'], - ['video'], - ['audio'], - ['any'], - ['mediaGallery'], - ['address'], - ['pageLink'], - ['reference'], - ['multiReference'], - ['arrayString'], - ['arrayDocument'], - ['richContent'], + 'object', + 'any', + 'mediaGallery', + 'address', + 'pageLink', + 'reference', + 'multiReference', + 'arrayDocument', + 'arrayString', ])('%s', (subtype) => { expect(env.schemaTranslator.columnToDbColumnSql({ name: ctx.fieldName, type: 'object', subtype })).toEqual({ mode: '', name: escapeId(ctx.fieldName), type: 'JSON' }) }) @@ -154,10 +157,17 @@ describe('Sql Schema Column Translator', () => { }) describe('date time fields', () => { + + test.each(['DATETIME', 'TIMESTAMP'])('%t', (t) => { + expect( env.schemaTranslator.translateType(t) ).toEqual('datetime') + }) + + test('time', () => { + expect( env.schemaTranslator.translateType('TIME') ).toEqual('time') + }) + test('date', () => { - ['DATE', 'DATETIME', 'TIME', 'TIMESTAMP'].forEach(t => { - expect( env.schemaTranslator.translateType(t) ).toEqual('datetime') - }) + expect( env.schemaTranslator.translateType('DATE') ).toEqual('date') }) }) diff --git a/libs/external-db-bigquery/src/sql_schema_translator.ts b/libs/external-db-bigquery/src/sql_schema_translator.ts index a5204c60a..23efd25d6 100644 --- a/libs/external-db-bigquery/src/sql_schema_translator.ts +++ b/libs/external-db-bigquery/src/sql_schema_translator.ts @@ -20,10 +20,13 @@ export default class SchemaColumnTranslator { case 'bigdecimal': return 'number' - case 'timestamp': - case 'datetime': case 'time': + return 'time' case 'date': + return 'date' + + case 'timestamp': + case 'datetime': return 'datetime' case 'string': @@ -90,6 +93,11 @@ export default class SchemaColumnTranslator { case 'text_medium': case 'text_large': case 'text_language': + case 'text_richcontent': + case 'text_image': + case 'text_video': + case 'text_audio': + case 'text_document': return 'STRING' case 'boolean_': @@ -98,11 +106,7 @@ export default class SchemaColumnTranslator { case 'object_': case 'object_object': - case 'object_image': - case 'object_document': - case 'object_video': case 'object_any': - case 'object_audio': case 'object_mediagallery': case 'object_address': case 'object_pagelink': @@ -110,7 +114,7 @@ export default class SchemaColumnTranslator { case 'object_multireference': case 'object_arraystring': case 'object_arraydocument': - case 'object_richcontent': + case 'object_array': return 'JSON' default: