@stacksjs/orm 0.72.75 → 0.72.76
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/generate-database-schema.d.ts +18 -0
- package/dist/index.js +15 -15
- package/package.json +4 -4
|
@@ -15,6 +15,7 @@ export declare interface GenerateSchemaOptions {
|
|
|
15
15
|
outFile?: string
|
|
16
16
|
dryRun?: boolean
|
|
17
17
|
target?: SchemaTarget
|
|
18
|
+
dialect?: 'sqlite' | 'mysql' | 'postgres'
|
|
18
19
|
}
|
|
19
20
|
export declare interface GenerateSchemaResult {
|
|
20
21
|
outFile: string
|
|
@@ -22,6 +23,23 @@ export declare interface GenerateSchemaResult {
|
|
|
22
23
|
errors: Array<{ file: string, error: string }>
|
|
23
24
|
content: string
|
|
24
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* What a boolean column reads back as, per dialect.
|
|
28
|
+
*
|
|
29
|
+
* `DatabaseSchema` types the RAW query builder - `db.selectFrom('events')` -
|
|
30
|
+
* and a raw row is whatever the driver hands back, not what the model meant.
|
|
31
|
+
* SQLite has no boolean type and stores 0/1 in an INTEGER; MySQL's BOOLEAN is
|
|
32
|
+
* a TINYINT(1) and reads back the same way. Only Postgres answers a real
|
|
33
|
+
* boolean.
|
|
34
|
+
*
|
|
35
|
+
* Emitting `boolean` everywhere made every flag column *almost* right: it
|
|
36
|
+
* typechecks, and then `row.all_day === true` is false on a row whose flag is
|
|
37
|
+
* set, which is the failure this exists to prevent.
|
|
38
|
+
*
|
|
39
|
+
* The ORM is unaffected - a model row goes through the attribute casts, so
|
|
40
|
+
* `ModelRow<typeof Event>` keeps its `boolean`.
|
|
41
|
+
*/
|
|
42
|
+
declare type Dialect = 'sqlite' | 'mysql' | 'postgres';
|
|
25
43
|
/**
|
|
26
44
|
* The two shapes this generator can write.
|
|
27
45
|
*
|