@apso/cli 0.47.5 → 0.48.0
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/commands/generate.js +6 -0
- package/dist/lib/apsorc-parser.d.ts +12 -1
- package/dist/lib/apsorc-parser.js +25 -2
- package/dist/lib/ddl/change.js +2 -0
- package/dist/lib/ddl/index.d.ts +11 -1
- package/dist/lib/ddl/index.js +30 -16
- package/dist/lib/ddl/sync.d.ts +25 -0
- package/dist/lib/ddl/sync.js +78 -0
- package/dist/lib/generators/go.d.ts +12 -6
- package/dist/lib/generators/go.js +223 -97
- package/dist/lib/generators/python.d.ts +6 -0
- package/dist/lib/generators/python.js +234 -23
- package/dist/lib/generators/typescript.js +12 -2
- package/dist/lib/templates/entities/entity-col-array.eta +1 -1
- package/dist/lib/templates/go/dto/dto-col-array.eta +2 -2
- package/dist/lib/templates/go/dto/dto-col-date.eta +1 -1
- package/dist/lib/templates/go/dto/dto-col-decimal.eta +1 -1
- package/dist/lib/templates/go/dto/dto-col-enum.eta +1 -1
- package/dist/lib/templates/go/dto/dto-col-float.eta +1 -1
- package/dist/lib/templates/go/dto/dto-col-integer.eta +3 -3
- package/dist/lib/templates/go/dto/dto-col-numeric.eta +1 -1
- package/dist/lib/templates/go/dto/dto-col-string.eta +1 -1
- package/dist/lib/templates/go/dto/dto-col-text.eta +1 -1
- package/dist/lib/templates/go/dto/dto-col-timestamp.eta +1 -1
- package/dist/lib/templates/go/dto/dto-col-timestamptz.eta +1 -1
- package/dist/lib/templates/go/dto/dto-col-uuid.eta +1 -1
- package/dist/lib/templates/go/dto/dto-col-varchar.eta +1 -1
- package/dist/lib/templates/go/dto/dto.eta +17 -18
- package/dist/lib/templates/go/handlers/handler.eta +2 -0
- package/dist/lib/templates/go/index-module.eta +3 -1
- package/dist/lib/templates/go/middleware/auth.eta +1 -1
- package/dist/lib/templates/go/models/model.eta +22 -19
- package/dist/lib/templates/go/models/schema.eta +72 -0
- package/dist/lib/templates/go/services/service.eta +49 -21
- package/dist/lib/templates/go/utils/query.eta +32 -6
- package/dist/lib/templates/python/models/init.eta +24 -0
- package/dist/lib/templates/python/models/model.eta +24 -56
- package/dist/lib/templates/python/schemas/schema-col-array.eta +1 -1
- package/dist/lib/templates/python/schemas/schema.eta +9 -9
- package/dist/lib/utils/field.d.ts +12 -0
- package/dist/lib/utils/field.js +18 -2
- package/npm-shrinkwrap.json +6 -6
- package/oclif.manifest.json +1 -1
- package/package.json +2 -2
- package/dist/lib/templates/go/models/model-col-array.eta +0 -1
- package/dist/lib/templates/go/models/model-col-boolean.eta +0 -1
- package/dist/lib/templates/go/models/model-col-date.eta +0 -1
- package/dist/lib/templates/go/models/model-col-decimal.eta +0 -1
- package/dist/lib/templates/go/models/model-col-enum.eta +0 -2
- package/dist/lib/templates/go/models/model-col-float.eta +0 -1
- package/dist/lib/templates/go/models/model-col-integer.eta +0 -1
- package/dist/lib/templates/go/models/model-col-json.eta +0 -1
- package/dist/lib/templates/go/models/model-col-jsonb.eta +0 -1
- package/dist/lib/templates/go/models/model-col-numeric.eta +0 -1
- package/dist/lib/templates/go/models/model-col-string.eta +0 -1
- package/dist/lib/templates/go/models/model-col-text.eta +0 -1
- package/dist/lib/templates/go/models/model-col-timestamp.eta +0 -1
- package/dist/lib/templates/go/models/model-col-timestamptz.eta +0 -1
- package/dist/lib/templates/go/models/model-col-uuid.eta +0 -1
- package/dist/lib/templates/go/models/model-col-varchar.eta +0 -1
- package/dist/lib/templates/python/models/model-col-array.eta +0 -4
- package/dist/lib/templates/python/models/model-col-boolean.eta +0 -6
- package/dist/lib/templates/python/models/model-col-date.eta +0 -4
- package/dist/lib/templates/python/models/model-col-datetime.eta +0 -5
- package/dist/lib/templates/python/models/model-col-decimal.eta +0 -4
- package/dist/lib/templates/python/models/model-col-enum.eta +0 -16
- package/dist/lib/templates/python/models/model-col-float.eta +0 -6
- package/dist/lib/templates/python/models/model-col-integer.eta +0 -6
- package/dist/lib/templates/python/models/model-col-json.eta +0 -4
- package/dist/lib/templates/python/models/model-col-jsonb.eta +0 -4
- package/dist/lib/templates/python/models/model-col-numeric.eta +0 -4
- package/dist/lib/templates/python/models/model-col-string.eta +0 -6
- package/dist/lib/templates/python/models/model-col-text.eta +0 -6
- package/dist/lib/templates/python/models/model-col-timestamp.eta +0 -11
- package/dist/lib/templates/python/models/model-col-timestamptz.eta +0 -11
- package/dist/lib/templates/python/models/model-col-uuid.eta +0 -5
- package/dist/lib/templates/python/models/model-col-varchar.eta +0 -6
package/dist/lib/utils/field.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateDecimalField = exports.typeExistsInEntity = exports.fieldToEnumType = exports.getFieldForTemplate = exports.getDefaultValueForField = exports.getJsTypeFromFieldType = exports.normalizeFieldType = exports.fieldTypeToColumnType = void 0;
|
|
3
|
+
exports.validateDecimalField = exports.typeExistsInEntity = exports.fieldToEnumType = exports.getFieldForTemplate = exports.getDefaultValueForField = exports.arrayElementType = exports.getJsTypeFromFieldType = exports.normalizeFieldType = exports.fieldTypeToColumnType = void 0;
|
|
4
4
|
const casing_1 = require("./casing");
|
|
5
5
|
/**
|
|
6
6
|
* Canonical mapping from .apsorc field types to Postgres column types.
|
|
@@ -83,6 +83,8 @@ const typeToJsType = {
|
|
|
83
83
|
array: "string[]",
|
|
84
84
|
boolean: "boolean",
|
|
85
85
|
integer: "number",
|
|
86
|
+
int: "number",
|
|
87
|
+
float8: "number",
|
|
86
88
|
float: "number",
|
|
87
89
|
real: "number",
|
|
88
90
|
double: "number",
|
|
@@ -128,6 +130,16 @@ const typeToJsType = {
|
|
|
128
130
|
};
|
|
129
131
|
const getJsTypeFromFieldType = (type) => { var _a; return (_a = typeToJsType[type]) !== null && _a !== void 0 ? _a : "string"; };
|
|
130
132
|
exports.getJsTypeFromFieldType = getJsTypeFromFieldType;
|
|
133
|
+
/**
|
|
134
|
+
* Postgres element type of an "array" field, as the DDL writer reads it.
|
|
135
|
+
* Python read `arrayType` and Go `arrayItemType` before `elementType`; both
|
|
136
|
+
* still work so older schemas generate the same code.
|
|
137
|
+
*
|
|
138
|
+
* @param {Field} field - An "array" field from .apsorc.
|
|
139
|
+
* @returns {string} The element type, "text" when none is set.
|
|
140
|
+
*/
|
|
141
|
+
const arrayElementType = (field) => field.elementType || field.arrayType || field.arrayItemType || "text";
|
|
142
|
+
exports.arrayElementType = arrayElementType;
|
|
131
143
|
const getDefaultValueForField = (field) => {
|
|
132
144
|
var _a, _b;
|
|
133
145
|
switch (field.type) {
|
|
@@ -167,10 +179,14 @@ const getFieldForTemplate = (fields, entityName) => fields.map((field) => {
|
|
|
167
179
|
...field,
|
|
168
180
|
// Use normalized type for template lookup
|
|
169
181
|
type: normalizedType,
|
|
182
|
+
// Resolved here so every template and the DDL writer read one key.
|
|
183
|
+
...(field.type === "array" && { elementType: (0, exports.arrayElementType)(field) }),
|
|
170
184
|
default: (0, exports.getDefaultValueForField)(field),
|
|
171
185
|
dataType: field.type === "enum"
|
|
172
186
|
? (0, exports.fieldToEnumType)(field.name, entityName)
|
|
173
|
-
:
|
|
187
|
+
: field.type === "array"
|
|
188
|
+
? `${(0, exports.getJsTypeFromFieldType)((0, exports.arrayElementType)(field))}[]`
|
|
189
|
+
: (0, exports.getJsTypeFromFieldType)(field.type),
|
|
174
190
|
};
|
|
175
191
|
});
|
|
176
192
|
exports.getFieldForTemplate = getFieldForTemplate;
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apso/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.48.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@apso/cli",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.48.0",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@apso/schema-tools": "^0.2.
|
|
12
|
+
"@apso/schema-tools": "^0.2.2",
|
|
13
13
|
"@biomejs/biome": "^1.9.4",
|
|
14
14
|
"@electric-sql/pglite": "^0.2.17",
|
|
15
15
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
@@ -149,9 +149,9 @@
|
|
|
149
149
|
"license": "MIT"
|
|
150
150
|
},
|
|
151
151
|
"node_modules/@apso/schema-tools": {
|
|
152
|
-
"version": "0.2.
|
|
153
|
-
"resolved": "https://registry.npmjs.org/@apso/schema-tools/-/schema-tools-0.2.
|
|
154
|
-
"integrity": "sha512-
|
|
152
|
+
"version": "0.2.2",
|
|
153
|
+
"resolved": "https://registry.npmjs.org/@apso/schema-tools/-/schema-tools-0.2.2.tgz",
|
|
154
|
+
"integrity": "sha512-qLz49EyG6hwWMzjzwxp9L0+Ou7EAi7lu6TaxrJixqPm7/J8EMWzBePssmjTE6eotw9qMZNnh1dZ/ky8a9to1rw==",
|
|
155
155
|
"license": "Apache-2.0",
|
|
156
156
|
"dependencies": {
|
|
157
157
|
"pluralize": "^8.0.0"
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apso/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.48.0",
|
|
4
4
|
"mcpName": "io.github.apsoai/apso",
|
|
5
5
|
"description": "Apso CLI",
|
|
6
6
|
"author": "Apso by Mavric - @mavric",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"/oclif.manifest.json"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@apso/schema-tools": "^0.2.
|
|
27
|
+
"@apso/schema-tools": "^0.2.2",
|
|
28
28
|
"@biomejs/biome": "^1.9.4",
|
|
29
29
|
"@electric-sql/pglite": "^0.2.17",
|
|
30
30
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<%= it.column.pascalName %> []<%= it.column.arrayItemType || 'string' %> `gorm:"type:<%= it.column.arrayItemType || 'text' %>[];serializer:json<% if (!it.column.required) { %>;default:null<% } %>" json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>bool `gorm:"type:boolean<% if (!it.column.required) { %>;default:null<% } else if (it.column.default !== undefined) { %>;default:<%= it.column.default %><% } %>" json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>time.Time `gorm:"type:date<% if (!it.column.required) { %>;default:null<% } %>" json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>float64 `gorm:"type:decimal(<%= it.column.precision || 10 %>,<%= it.column.scale || 2 %>)<% if (!it.column.required) { %>;default:null<% } %>" json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
<% const enumTypeName = it.column.enumType || (it.column.pascalName + 'Enum'); %>
|
|
2
|
-
<%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>enums.<%= enumTypeName %> `gorm:"type:varchar(50)<% if (!it.column.required) { %>;default:null<% } %>" json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>float64 `gorm:"type:float<% if (!it.column.required) { %>;default:null<% } %>" json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>int <% if (it.column.primary) { %>`gorm:"primaryKey;autoIncrement" json:"<%= it.column.name %>"`<% } else { %>`gorm:"type:integer<% if (!it.column.required) { %>;default:null<% } %>" json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`<% } %>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>map[string]interface{} `gorm:"type:json<% if (!it.column.required) { %>;default:null<% } %>;serializer:json" json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>map[string]interface{} `gorm:"type:jsonb<% if (!it.column.required) { %>;default:null<% } %>;serializer:json" json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>float64 `gorm:"type:numeric(<%= it.column.precision || 10 %>,<%= it.column.scale || 2 %>)<% if (!it.column.required) { %>;default:null<% } %>" json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>string `gorm:"type:varchar(<%= it.column.length || 255 %>)<% if (!it.column.required) { %>;default:null<% } %>" json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>string `gorm:"type:text<% if (!it.column.required) { %>;default:null<% } %>" json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>time.Time `gorm:"type:timestamp<% if (!it.column.required) { %>;default:null<% } %>" json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>time.Time `gorm:"type:timestamptz<% if (!it.column.required) { %>;default:null<% } %>" json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>string <% if (it.column.primary) { %>`gorm:"type:uuid;primaryKey;default:gen_random_uuid()" json:"<%= it.column.name %>"`<% } else { %>`gorm:"type:uuid<% if (!it.column.required) { %>;default:null<% } %>" json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`<% } %>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>string `gorm:"type:varchar(<%= it.column.length || 255 %>)<% if (!it.column.required) { %>;default:null<% } %>" json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
<%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[bool]<% } else { %>bool<% } %>] = mapped_column(
|
|
2
|
-
Boolean,
|
|
3
|
-
nullable=<%= it.field.nullable === false ? 'False' : 'True' %><% if (it.field.unique) { %>,
|
|
4
|
-
unique=True<% } %><% if (it.field.default !== undefined && it.field.default !== null) { %>,
|
|
5
|
-
default=<%= (it.field.default === true || it.field.default === 'true') ? 'True' : 'False' %><% } %>
|
|
6
|
-
)
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
<%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[datetime]<% } else { %>datetime<% } %>] = mapped_column(
|
|
2
|
-
DateTime,
|
|
3
|
-
nullable=<%= it.field.nullable === false ? 'False' : 'True' %><% if (it.field.default !== undefined && it.field.default !== null) { %>,
|
|
4
|
-
default=<%= it.field.default === null ? 'None' : `"${it.field.default}"` %><% } %>
|
|
5
|
-
)
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
<%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[Decimal]<% } else { %>Decimal<% } %>] = mapped_column(
|
|
2
|
-
Numeric(precision=<%= it.field.precision || 10 %>, scale=<%= it.field.scale || 2 %>),
|
|
3
|
-
nullable=<%= it.field.nullable === false ? 'False' : 'True' %>
|
|
4
|
-
)
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
<%
|
|
2
|
-
// Generate the enum type name: EntityName + FieldNamePascal + Enum
|
|
3
|
-
const fieldNamePascal = it.field.name.charAt(0).toUpperCase() + it.field.name.slice(1);
|
|
4
|
-
const enumTypeName = it.field.enumType || `${it.entityName}${fieldNamePascal}Enum`;
|
|
5
|
-
// Generate the PostgreSQL enum type name (snake_case version)
|
|
6
|
-
const pgEnumName = (it.entityName + '_' + it.field.name + '_enum').toLowerCase().replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase();
|
|
7
|
-
-%>
|
|
8
|
-
<%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[enums.<%= enumTypeName %>]<% } else { %>enums.<%= enumTypeName %><% } %>] = mapped_column(
|
|
9
|
-
SAEnum(
|
|
10
|
-
enums.<%= enumTypeName %>,
|
|
11
|
-
name="<%= pgEnumName %>",
|
|
12
|
-
values_callable=lambda x: [e.value for e in x],
|
|
13
|
-
create_type=True
|
|
14
|
-
),
|
|
15
|
-
nullable=<%= it.field.nullable === false ? 'False' : 'True' %>
|
|
16
|
-
)
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
<%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[float]<% } else { %>float<% } %>] = mapped_column(
|
|
2
|
-
Float,
|
|
3
|
-
nullable=<%= it.field.nullable === false ? 'False' : 'True' %><% if (it.field.unique) { %>,
|
|
4
|
-
unique=True<% } %><% if (it.field.default !== undefined && it.field.default !== null) { %>,
|
|
5
|
-
default=<%= it.field.default %><% } %>
|
|
6
|
-
)
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
<%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[int]<% } else { %>int<% } %>] = mapped_column(
|
|
2
|
-
Integer,
|
|
3
|
-
nullable=<%= it.field.nullable === false ? 'False' : 'True' %><% if (it.field.unique) { %>,
|
|
4
|
-
unique=True<% } %><% if (it.field.default !== undefined && it.field.default !== null) { %>,
|
|
5
|
-
default=<%= it.field.default %><% } %>
|
|
6
|
-
)
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
<%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[Decimal]<% } else { %>Decimal<% } %>] = mapped_column(
|
|
2
|
-
Numeric(precision=<%= it.field.precision || 10 %>, scale=<%= it.field.scale || 2 %>),
|
|
3
|
-
nullable=<%= it.field.nullable === false ? 'False' : 'True' %>
|
|
4
|
-
)
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
<%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[str]<% } else { %>str<% } %>] = mapped_column(
|
|
2
|
-
String(<%= it.field.length || 255 %>),
|
|
3
|
-
nullable=<%= it.field.nullable === false ? 'False' : 'True' %><% if (it.field.unique) { %>,
|
|
4
|
-
unique=True<% } %><% if (it.field.default !== undefined && it.field.default !== null) { %>,
|
|
5
|
-
default="<%= it.field.default %>"<% } %>
|
|
6
|
-
)
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
<%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[str]<% } else { %>str<% } %>] = mapped_column(
|
|
2
|
-
Text,
|
|
3
|
-
nullable=<%= it.field.nullable === false ? 'False' : 'True' %><% if (it.field.unique) { %>,
|
|
4
|
-
unique=True<% } %><% if (it.field.default !== undefined && it.field.default !== null) { %>,
|
|
5
|
-
default="<%= it.field.default %>"<% } %>
|
|
6
|
-
)
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
<%
|
|
2
|
-
const isCreatedAt = ['createdAt', 'created_at'].includes(it.field.name);
|
|
3
|
-
const isUpdatedAt = ['updatedAt', 'updated_at'].includes(it.field.name);
|
|
4
|
-
-%>
|
|
5
|
-
<%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[datetime]<% } else { %>datetime<% } %>] = mapped_column(
|
|
6
|
-
DateTime,
|
|
7
|
-
nullable=<%= it.field.nullable === false ? 'False' : 'True' %><% if (isCreatedAt) { %>,
|
|
8
|
-
server_default=func.now()<% } %><% if (isUpdatedAt) { %>,
|
|
9
|
-
server_default=func.now(),
|
|
10
|
-
onupdate=func.now()<% } %>
|
|
11
|
-
)
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
<%
|
|
2
|
-
const isCreatedAt = ['createdAt', 'created_at'].includes(it.field.name);
|
|
3
|
-
const isUpdatedAt = ['updatedAt', 'updated_at'].includes(it.field.name);
|
|
4
|
-
-%>
|
|
5
|
-
<%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[datetime]<% } else { %>datetime<% } %>] = mapped_column(
|
|
6
|
-
DateTime(timezone=True),
|
|
7
|
-
nullable=<%= it.field.nullable === false ? 'False' : 'True' %><% if (isCreatedAt) { %>,
|
|
8
|
-
server_default=func.now()<% } %><% if (isUpdatedAt) { %>,
|
|
9
|
-
server_default=func.now(),
|
|
10
|
-
onupdate=func.now()<% } %>
|
|
11
|
-
)
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
<%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[str]<% } else { %>str<% } %>] = mapped_column(
|
|
2
|
-
String(<%= it.field.length || 255 %>),
|
|
3
|
-
nullable=<%= it.field.nullable === false ? 'False' : 'True' %><% if (it.field.unique) { %>,
|
|
4
|
-
unique=True<% } %><% if (it.field.default !== undefined && it.field.default !== null) { %>,
|
|
5
|
-
default="<%= it.field.default %>"<% } %>
|
|
6
|
-
)
|