@ronin/compiler 0.13.4 → 0.13.5
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.
- package/dist/index.d.ts +24 -17
- package/dist/index.js +6 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
@@ -147,6 +147,7 @@ interface Statement {
|
|
147
147
|
}
|
148
148
|
|
149
149
|
type ModelFieldCollation = 'BINARY' | 'NOCASE' | 'RTRIM';
|
150
|
+
type ModelFieldLinkAction = 'CASCADE' | 'RESTRICT' | 'SET NULL' | 'SET DEFAULT' | 'NO ACTION';
|
150
151
|
type ModelFieldBasics = {
|
151
152
|
/** The label that should be used when displaying the field on the RONIN dashboard. */
|
152
153
|
name?: string;
|
@@ -180,31 +181,37 @@ type ModelFieldBasics = {
|
|
180
181
|
};
|
181
182
|
/** An expression that gets evaluated every time a value is provided for the field. */
|
182
183
|
check?: Expression;
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
184
|
+
};
|
185
|
+
type ModelField = (ModelFieldBasics & {
|
186
|
+
/** The kind of value that should be stored inside the field. */
|
187
|
+
type?: 'boolean' | 'date' | 'json';
|
188
|
+
}) | (ModelFieldBasics & {
|
189
|
+
/** The kind of value that should be stored inside the field. */
|
190
|
+
type?: 'string';
|
191
|
+
/** The collation sequence to use for the field value. */
|
187
192
|
collation?: ModelFieldCollation;
|
193
|
+
}) | (ModelFieldBasics & {
|
194
|
+
/** The kind of value that should be stored inside the field. */
|
195
|
+
type?: 'number';
|
188
196
|
/**
|
189
|
-
*
|
190
|
-
* the value of the field with every new record that gets inserted.
|
197
|
+
* Automatically increments the value of the field with every new inserted record.
|
191
198
|
*/
|
192
199
|
increment?: boolean;
|
193
|
-
}
|
194
|
-
|
195
|
-
type?: '
|
196
|
-
|
197
|
-
type ModelFieldReferenceAction = 'CASCADE' | 'RESTRICT' | 'SET NULL' | 'SET DEFAULT' | 'NO ACTION';
|
198
|
-
type ModelFieldReference = ModelFieldBasics & {
|
199
|
-
type: 'link';
|
200
|
+
}) | (ModelFieldBasics & {
|
201
|
+
/** The kind of value that should be stored inside the field. */
|
202
|
+
type?: 'link';
|
203
|
+
/** The target model of the relationship that is being established. */
|
200
204
|
target: string;
|
205
|
+
/** Whether the field should be related to one record, or many records. */
|
201
206
|
kind?: 'one' | 'many';
|
207
|
+
/**
|
208
|
+
* If the target record is updated or deleted, the defined actions maybe executed.
|
209
|
+
*/
|
202
210
|
actions?: {
|
203
|
-
onDelete?:
|
204
|
-
onUpdate?:
|
211
|
+
onDelete?: ModelFieldLinkAction;
|
212
|
+
onUpdate?: ModelFieldLinkAction;
|
205
213
|
};
|
206
|
-
};
|
207
|
-
type ModelField = ModelFieldNormal | ModelFieldReference;
|
214
|
+
});
|
208
215
|
type ModelIndexField<T extends Array<ModelField> = Array<ModelField>> = {
|
209
216
|
/** The collating sequence used for text placed inside the field. */
|
210
217
|
collation?: ModelFieldCollation;
|
package/dist/index.js
CHANGED
@@ -840,8 +840,12 @@ var getFieldStatement = (models, model, field) => {
|
|
840
840
|
if (symbol) value = `(${parseFieldExpression(model, "to", symbol.value)})`;
|
841
841
|
statement += ` DEFAULT ${value}`;
|
842
842
|
}
|
843
|
-
if (field.
|
844
|
-
|
843
|
+
if (field.type === "string" && field.collation) {
|
844
|
+
statement += ` COLLATE ${field.collation}`;
|
845
|
+
}
|
846
|
+
if (field.type === "number" && field.increment === true) {
|
847
|
+
statement += " AUTOINCREMENT";
|
848
|
+
}
|
845
849
|
if (typeof field.check !== "undefined") {
|
846
850
|
const symbol = getSymbol(field.check);
|
847
851
|
statement += ` CHECK (${parseFieldExpression(model, "to", symbol?.value)})`;
|