@ronin/compiler 0.18.4-invalid-json-experimental-443 → 0.18.5-json-experimental-444

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.
Files changed (2) hide show
  1. package/dist/index.js +11 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1684,7 +1684,16 @@ var getFieldStatement = (models, model, field) => {
1684
1684
  const symbol = getQuerySymbol(field.defaultValue);
1685
1685
  let value = typeof field.defaultValue === "string" ? `'${field.defaultValue}'` : field.defaultValue;
1686
1686
  if (symbol) value = `(${parseFieldExpression(model, "to", symbol.value)})`;
1687
- if (field.type === "json") value = `'${JSON.stringify(field.defaultValue)}'`;
1687
+ if (field.type === "json") {
1688
+ if (!isObject(field.defaultValue)) {
1689
+ throw new RoninError({
1690
+ message: `The default value of JSON field "${field.slug}" must be an object.`,
1691
+ code: "INVALID_MODEL_VALUE",
1692
+ field: "fields"
1693
+ });
1694
+ }
1695
+ value = `'${JSON.stringify(field.defaultValue)}'`;
1696
+ }
1688
1697
  statement += ` DEFAULT ${value}`;
1689
1698
  }
1690
1699
  if (field.type === "string" && field.collation) {
@@ -2001,7 +2010,7 @@ var transformMetaQuery = (models, dependencyStatements, statementParams, query,
2001
2010
  throw new RoninError({
2002
2011
  message: `When ${actionReadable} ${PLURAL_MODEL_ENTITIES[entity]}, at least one field must be provided.`,
2003
2012
  code: "INVALID_MODEL_VALUE",
2004
- fields: ["fields"]
2013
+ field: PLURAL_MODEL_ENTITIES[entity]
2005
2014
  });
2006
2015
  }
2007
2016
  const columns = index.fields.map((field2) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ronin/compiler",
3
- "version": "0.18.4-invalid-json-experimental-443",
3
+ "version": "0.18.5-json-experimental-444",
4
4
  "type": "module",
5
5
  "description": "Compiles RONIN queries to SQL statements.",
6
6
  "publishConfig": {