@an5/orm 1.3.0 → 1.3.1
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.
|
@@ -1243,7 +1243,9 @@ import an5.adapters.An5Adapter;
|
|
|
1243
1243
|
*
|
|
1244
1244
|
* <pre>
|
|
1245
1245
|
* try (An5DbContext db = new An5DbContext(An5Config.connectionString())) {
|
|
1246
|
-
*
|
|
1246
|
+
* An5OrmTypes.UserWhere where = new An5OrmTypes.UserWhere();
|
|
1247
|
+
* where.Name = An5OrmTypes.StringFilter.is("Ada");
|
|
1248
|
+
* User ada = db.getUser().findUnique(where.toMap());
|
|
1247
1249
|
* }
|
|
1248
1250
|
* </pre>
|
|
1249
1251
|
*/
|
|
@@ -56,7 +56,7 @@ class PythonGenerator {
|
|
|
56
56
|
}
|
|
57
57
|
generateOrmTypes(models, outputDir) {
|
|
58
58
|
let content = '# This file is auto-generated. Do not edit directly.\n';
|
|
59
|
-
content += '"""\nAN5 ORM typed filter/args dataclasses
|
|
59
|
+
content += '"""\nAN5 ORM typed filter/args dataclasses.\n\nThese describe the filter shapes the Python client accepts. The adapter reads plain\ndicts, not these dataclasses, and it quotes every key verbatim, so use the schema\nfield names (`createdAt`, not `created_at`):\n\n db.user.find_many(where={"name": {"contains": "John"}},\n order_by={"createdAt": "desc"},\n take=10)\n"""\n';
|
|
60
60
|
content += 'from __future__ import annotations\n';
|
|
61
61
|
content += 'from dataclasses import dataclass, field\n';
|
|
62
62
|
content += 'from typing import List, Optional, Any\n';
|
|
@@ -318,9 +318,11 @@ class PythonGenerator {
|
|
|
318
318
|
}
|
|
319
319
|
content += 'class An5Client:\n';
|
|
320
320
|
content += ' """AN5 Python ORM Client - type-safe database access.\n\n';
|
|
321
|
+
content += ' Query keys are schema field names, used verbatim: the SQL builder quotes a key\n';
|
|
322
|
+
content += ' as-is, so `createdAt` reaches the database and `created_at` does not.\n\n';
|
|
321
323
|
content += ' Usage:\n';
|
|
322
324
|
content += ' db = An5Client()\n';
|
|
323
|
-
content += ' users = db.user.find_many(where={"name": {"contains": "John"}}, order_by={"
|
|
325
|
+
content += ' users = db.user.find_many(where={"name": {"contains": "John"}}, order_by={"createdAt": "asc"}, take=10)\n';
|
|
324
326
|
content += ' user = db.user.find_first(where={"id": "abc"})\n';
|
|
325
327
|
content += ' new = db.user.create(data={"name": "Alice", "email": "alice@example.com"})\n';
|
|
326
328
|
content += ' """\n';
|
|
@@ -1284,7 +1284,9 @@ import an5.adapters.An5Adapter;
|
|
|
1284
1284
|
*
|
|
1285
1285
|
* <pre>
|
|
1286
1286
|
* try (An5DbContext db = new An5DbContext(An5Config.connectionString())) {
|
|
1287
|
-
*
|
|
1287
|
+
* An5OrmTypes.UserWhere where = new An5OrmTypes.UserWhere();
|
|
1288
|
+
* where.Name = An5OrmTypes.StringFilter.is("Ada");
|
|
1289
|
+
* User ada = db.getUser().findUnique(where.toMap());
|
|
1288
1290
|
* }
|
|
1289
1291
|
* </pre>
|
|
1290
1292
|
*/
|
|
@@ -64,7 +64,7 @@ export class PythonGenerator {
|
|
|
64
64
|
|
|
65
65
|
private generateOrmTypes(models: Model[], outputDir: string) {
|
|
66
66
|
let content = '# This file is auto-generated. Do not edit directly.\n';
|
|
67
|
-
content += '"""\nAN5 ORM typed filter/args dataclasses
|
|
67
|
+
content += '"""\nAN5 ORM typed filter/args dataclasses.\n\nThese describe the filter shapes the Python client accepts. The adapter reads plain\ndicts, not these dataclasses, and it quotes every key verbatim, so use the schema\nfield names (`createdAt`, not `created_at`):\n\n db.user.find_many(where={"name": {"contains": "John"}},\n order_by={"createdAt": "desc"},\n take=10)\n"""\n';
|
|
68
68
|
content += 'from __future__ import annotations\n';
|
|
69
69
|
content += 'from dataclasses import dataclass, field\n';
|
|
70
70
|
content += 'from typing import List, Optional, Any\n';
|
|
@@ -358,9 +358,11 @@ export class PythonGenerator {
|
|
|
358
358
|
|
|
359
359
|
content += 'class An5Client:\n';
|
|
360
360
|
content += ' """AN5 Python ORM Client - type-safe database access.\n\n';
|
|
361
|
+
content += ' Query keys are schema field names, used verbatim: the SQL builder quotes a key\n';
|
|
362
|
+
content += ' as-is, so `createdAt` reaches the database and `created_at` does not.\n\n';
|
|
361
363
|
content += ' Usage:\n';
|
|
362
364
|
content += ' db = An5Client()\n';
|
|
363
|
-
content += ' users = db.user.find_many(where={"name": {"contains": "John"}}, order_by={"
|
|
365
|
+
content += ' users = db.user.find_many(where={"name": {"contains": "John"}}, order_by={"createdAt": "asc"}, take=10)\n';
|
|
364
366
|
content += ' user = db.user.find_first(where={"id": "abc"})\n';
|
|
365
367
|
content += ' new = db.user.create(data={"name": "Alice", "email": "alice@example.com"})\n';
|
|
366
368
|
content += ' """\n';
|
package/package.json
CHANGED