You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Refactoring method `addFieldIfNotExists`
* Using ES6 Generators syntax
* Passing in the context into method `createClass`, to reuse the connection
* Extending method `createClass` to reuse connections
* Update PostgresStorageAdapter.js
forgot: extending method `createClass` to reuse the connection.
* Update PostgresStorageAdapter.js
fixing the re-throw logic.
// Column already exists, created by other request. Carry on to see if it's the right type.
767
+
};
767
768
}else{
768
-
promise=t.none('CREATE TABLE IF NOT EXISTS $<joinTable:name> ("relatedId" varChar(120), "owningId" varChar(120), PRIMARY KEY("relatedId", "owningId") )',{joinTable: `_Join:${fieldName}:${className}`})
769
+
yieldt.none('CREATE TABLE IF NOT EXISTS $<joinTable:name> ("relatedId" varChar(120), "owningId" varChar(120), PRIMARY KEY("relatedId", "owningId") )',{joinTable: `_Join:${fieldName}:${className}`});
770
+
}
771
+
772
+
constresult=yieldt.any('SELECT "schema" FROM "_SCHEMA" WHERE "className" = $<className> and ("schema"::json->\'fields\'->$<fieldName>) is not null',{className, fieldName});
773
+
774
+
if(result[0]){
775
+
throw'Attempted to add a field that already exists';
776
+
}else{
777
+
constpath=`{fields,${fieldName}}`;
778
+
yieldt.none('UPDATE "_SCHEMA" SET "schema"=jsonb_set("schema", $<path>, $<type>) WHERE "className"=$<className>',{path, type, className});
769
779
}
770
-
returnpromise.then(()=>{
771
-
returnt.any('SELECT "schema" FROM "_SCHEMA" WHERE "className" = $<className> and ("schema"::json->\'fields\'->$<fieldName>) is not null',{className, fieldName});
772
-
}).then(result=>{
773
-
if(result[0]){
774
-
throw"Attempted to add a field that already exists";
775
-
}else{
776
-
constpath=`{fields,${fieldName}}`;
777
-
returnt.none(
778
-
'UPDATE "_SCHEMA" SET "schema"=jsonb_set("schema", $<path>, $<type>) WHERE "className"=$<className>',
0 commit comments