prostgles-server 3.0.136 → 3.0.138

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -45,7 +45,7 @@ const getColumnDefinitionQuery = async ({ colConf: colConfRaw, column, db, table
45
45
  ...(jsonbSchema.jsonbSchemaType ? { type: jsonbSchema.jsonbSchemaType } : jsonbSchema.jsonbSchema)
46
46
  }) + "::TEXT";
47
47
  /** Validate default value against jsonbSchema */
48
- const q = `SELECT ${validate_jsonb_schema_sql_1.VALIDATE_SCHEMA_FUNCNAME}(${jsonbSchemaStr}, ${(0, PubSubManager_1.asValue)(colConf.defaultValue) + "::JSONB"}, ARRAY[${(0, PubSubManager_1.asValue)(column)}]) as v`;
48
+ const q = `SELECT ${validate_jsonb_schema_sql_1.VALIDATE_SCHEMA_FUNCNAME}(${jsonbSchemaStr}, ${(0, PubSubManager_1.asValue)(colConf.defaultValue) + "::JSONB"}, ${(0, PubSubManager_1.asValue)({ table, column })}) as v`;
49
49
  if (colConf.defaultValue) {
50
50
  const failedDefault = (err) => {
51
51
  return { msg: `Default value (${colConf.defaultValue}) for ${table}.${column} does not satisfy the jsonb constraint check: ${q}`, err };
@@ -68,7 +68,7 @@ const getColumnDefinitionQuery = async ({ colConf: colConfRaw, column, db, table
68
68
  for await (const oldCons of existingNonMatchingConstraints) {
69
69
  await db.any(`ALTER TABLE ${(0, prostgles_types_1.asName)(table)} DROP CONSTRAINT ${(0, prostgles_types_1.asName)(oldCons.name)};`);
70
70
  }
71
- return ` ${colNameEsc} ${getColTypeDef(colConf, "JSONB")}, CONSTRAINT ${(0, prostgles_types_1.asName)(constraintName)} CHECK(${validate_jsonb_schema_sql_1.VALIDATE_SCHEMA_FUNCNAME}(${jsonbSchemaStr}, ${colNameEsc}, ARRAY[${(0, PubSubManager_1.asValue)(column)}]))`;
71
+ return ` ${colNameEsc} ${getColTypeDef(colConf, "JSONB")}, CONSTRAINT ${(0, prostgles_types_1.asName)(constraintName)} CHECK(${validate_jsonb_schema_sql_1.VALIDATE_SCHEMA_FUNCNAME}(${jsonbSchemaStr}, ${colNameEsc}, ${(0, PubSubManager_1.asValue)({ table, column })} ))`;
72
72
  }
73
73
  else if ("enum" in colConf) {
74
74
  if (!colConf.enum?.length)
@@ -61,7 +61,7 @@ export const getColumnDefinitionQuery = async ({ colConf: colConfRaw, column, db
61
61
  }) + "::TEXT";
62
62
 
63
63
  /** Validate default value against jsonbSchema */
64
- const q = `SELECT ${VALIDATE_SCHEMA_FUNCNAME}(${jsonbSchemaStr}, ${asValue(colConf.defaultValue) + "::JSONB"}, ARRAY[${asValue(column)}]) as v`;
64
+ const q = `SELECT ${VALIDATE_SCHEMA_FUNCNAME}(${jsonbSchemaStr}, ${asValue(colConf.defaultValue) + "::JSONB"}, ${asValue({ table, column })}) as v`;
65
65
  if (colConf.defaultValue) {
66
66
 
67
67
  const failedDefault = (err?: any) => {
@@ -85,7 +85,7 @@ export const getColumnDefinitionQuery = async ({ colConf: colConfRaw, column, db
85
85
  await db.any(`ALTER TABLE ${asName(table)} DROP CONSTRAINT ${asName(oldCons.name)};`);
86
86
  }
87
87
 
88
- return ` ${colNameEsc} ${getColTypeDef(colConf, "JSONB")}, CONSTRAINT ${asName(constraintName)} CHECK(${VALIDATE_SCHEMA_FUNCNAME}(${jsonbSchemaStr}, ${colNameEsc}, ARRAY[${asValue(column)}]))`;
88
+ return ` ${colNameEsc} ${getColTypeDef(colConf, "JSONB")}, CONSTRAINT ${asName(constraintName)} CHECK(${VALIDATE_SCHEMA_FUNCNAME}(${jsonbSchemaStr}, ${colNameEsc}, ${asValue({ table, column })} ))`;
89
89
 
90
90
  } else if ("enum" in colConf) {
91
91
  if (!colConf.enum?.length) throw new Error("colConf.enum Must not be empty");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prostgles-server",
3
- "version": "3.0.136",
3
+ "version": "3.0.138",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1 +1 @@
1
- 18339
1
+ 12208
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "../..": {
23
23
  "name": "prostgles-server",
24
- "version": "3.0.135",
24
+ "version": "3.0.137",
25
25
  "license": "MIT",
26
26
  "dependencies": {
27
27
  "@aws-sdk/client-s3": "^3.272.0",