Skip to content

Commit

Permalink
fix(database): db schema validation not working for JSONB type (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-Vol authored Aug 24, 2022
1 parent 598a8e5 commit 973cac2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions modules/database/src/adapters/utils/validateSchemas.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ConduitError, ConduitSchema } from '@conduitplatform/grpc-sdk';
import { cloneDeep, isArray, isEmpty, isObject, isString, merge } from 'lodash';
import { Fields } from '../../interfaces';
import { DataTypes } from 'sequelize';

const deepdash = require('deepdash/standalone');

Expand Down Expand Up @@ -63,6 +64,7 @@ function validateSchemaFields(oldSchemaFields: any, newSchemaFields: any) {
const newType =
newSchemaFields[key] && newSchemaFields.type ? newSchemaFields[key].type : null;
if (!newType) return;
if (oldType === DataTypes.JSONB && newType === 'JSON') return;
if (isArray(oldType) && isArray(newType)) {
if (JSON.stringify(oldType[0]) !== JSON.stringify(newType[0]))
throw ConduitError.forbidden('Invalid schema types');
Expand Down

0 comments on commit 973cac2

Please sign in to comment.