@ronin/compiler 0.11.0-leo-ron-1083-experimental-228 → 0.11.1-default-value-experimental-230
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.js +7 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -20,6 +20,7 @@ var RONIN_MODEL_FIELD_REGEX = new RegExp(
|
|
20
20
|
`${QUERY_SYMBOLS.FIELD}[_a-zA-Z0-9.]+`,
|
21
21
|
"g"
|
22
22
|
);
|
23
|
+
var RAW_FIELD_TYPES = ["string", "number", "boolean"];
|
23
24
|
var composeIncludedTableAlias = (fieldSlug) => `including_${fieldSlug}`;
|
24
25
|
var MODEL_ENTITY_ERROR_CODES = {
|
25
26
|
field: "FIELD_NOT_FOUND",
|
@@ -642,7 +643,7 @@ var getFieldStatement = (models, model, field) => {
|
|
642
643
|
if (field.unique === true) statement += " UNIQUE";
|
643
644
|
if (field.required === true) statement += " NOT NULL";
|
644
645
|
if (typeof field.defaultValue !== "undefined")
|
645
|
-
statement += ` DEFAULT ${field.defaultValue}`;
|
646
|
+
statement += ` DEFAULT ${typeof field.defaultValue === "string" ? `'${field.defaultValue}'` : field.defaultValue}`;
|
646
647
|
if (field.collation) statement += ` COLLATE ${field.collation}`;
|
647
648
|
if (field.increment === true) statement += " AUTOINCREMENT";
|
648
649
|
if (typeof field.check !== "undefined") {
|
@@ -1152,9 +1153,6 @@ var handleIncluding = (models, model, statementParams, instruction) => {
|
|
1152
1153
|
statement += `${joinType} JOIN ${relatedTableSelector} as ${tableAlias}`;
|
1153
1154
|
model.tableAlias = model.tableAlias || model.table;
|
1154
1155
|
if (joinType === "LEFT") {
|
1155
|
-
if (!single) {
|
1156
|
-
tableSubQuery = `SELECT * FROM "${model.table}" LIMIT 1`;
|
1157
|
-
}
|
1158
1156
|
const subStatement = composeConditions(
|
1159
1157
|
models,
|
1160
1158
|
{ ...relatedModel, tableAlias },
|
@@ -1167,6 +1165,7 @@ var handleIncluding = (models, model, statementParams, instruction) => {
|
|
1167
1165
|
);
|
1168
1166
|
statement += ` ON (${subStatement})`;
|
1169
1167
|
}
|
1168
|
+
if (!single) tableSubQuery = `SELECT * FROM "${model.table}" LIMIT 1`;
|
1170
1169
|
}
|
1171
1170
|
return { statement, tableSubQuery };
|
1172
1171
|
};
|
@@ -1249,6 +1248,10 @@ var handleSelecting = (models, model, statementParams, instructions, options) =>
|
|
1249
1248
|
newValue = prepareStatementValue(statementParams, value);
|
1250
1249
|
}
|
1251
1250
|
instructions.including[key] = newValue;
|
1251
|
+
loadedFields.push({
|
1252
|
+
slug: key,
|
1253
|
+
type: RAW_FIELD_TYPES.includes(typeof value) ? typeof value : "string"
|
1254
|
+
});
|
1252
1255
|
}
|
1253
1256
|
}
|
1254
1257
|
const expandColumns = isJoining && options?.expandColumns;
|
package/package.json
CHANGED