Skip to content

Commit 96f5fb9

Browse files
committed
try addFieldIfNotExists 4th
1 parent 96e4da4 commit 96f5fb9

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/Adapters/Storage/Postgres/PostgresStorageAdapter.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -810,8 +810,8 @@ export class PostgresStorageAdapter implements StorageAdapter {
810810
this._client = client;
811811
this._onchange = () => {};
812812
this._pgp = pgp;
813+
this._uuid = uuidv4();
813814
this.canSortOnJoinTables = false;
814-
this.uuid = uuidv4();
815815
}
816816

817817
watch(callback: () => void): void {
@@ -843,7 +843,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
843843
this._stream = await this._client.connect({ direct: true });
844844
this._stream.client.on('notification', data => {
845845
const payload = JSON.parse(data.payload);
846-
if (payload.senderId !== this.uuid) {
846+
if (payload.senderId !== this._uuid) {
847847
this._onchange();
848848
}
849849
});
@@ -854,7 +854,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
854854
_notifySchemaChange() {
855855
if (this._stream) {
856856
this._stream
857-
.none('NOTIFY $1~, $2', ['schema.change', { senderId: this.uuid }])
857+
.none('NOTIFY $1~, $2', ['schema.change', { senderId: this._uuid }])
858858
.catch(error => {
859859
console.log('Failed to Notify:', error); // unlikely to ever happen
860860
});

src/Controllers/SchemaController.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,15 +1245,15 @@ export default class SchemaController {
12451245
}
12461246
const results = await Promise.all(promises);
12471247
const enforceFields = results.filter(result => !!result);
1248-
this.ensureFields(enforceFields);
12491248

1250-
if (enforceFields.length !== 0) {
1249+
if (enforceFields.length !== 0 && !volatileClasses.includes(className)) {
12511250
const cached = SchemaCache.get(className);
12521251
enforceFields.forEach(({ fieldName, type }) => {
12531252
cached.fields[fieldName] = type;
12541253
});
12551254
await this.reloadData();
12561255
}
1256+
this.ensureFields(enforceFields);
12571257

12581258
const promise = Promise.resolve(schema);
12591259
return thenValidateRequiredColumns(promise, className, object, query);

0 commit comments

Comments
 (0)