@fabrika/auth-core 0.9.0-dev.6 → 0.9.0-dev.8
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/package.json +1 -1
- package/src/ops.ts +19 -7
- package/types/src/ops.d.ts +9 -4
package/package.json
CHANGED
package/src/ops.ts
CHANGED
|
@@ -586,8 +586,12 @@ export interface OpsDumpSchemaTable {
|
|
|
586
586
|
readonly name: string
|
|
587
587
|
readonly virtual: boolean
|
|
588
588
|
readonly withoutRowid: boolean
|
|
589
|
-
/**
|
|
590
|
-
|
|
589
|
+
/**
|
|
590
|
+
* Every name a `CHECK` constraint of the table's SQL reads, ASCII-lowercase and unquoted (keywords included), so a
|
|
591
|
+
* column it does not list cannot change what a `CHECK` answers. Empty for a table without one; `null` from a reader
|
|
592
|
+
* that cannot tell, which counts as naming every column.
|
|
593
|
+
*/
|
|
594
|
+
readonly checkNames: readonly string[] | null
|
|
591
595
|
readonly columns: readonly OpsDumpSchemaColumn[]
|
|
592
596
|
readonly indexes: readonly OpsDumpSchemaIndex[]
|
|
593
597
|
readonly foreignKeys: readonly OpsDumpSchemaForeignKey[]
|
|
@@ -618,8 +622,9 @@ export interface OpsDumpPlan {
|
|
|
618
622
|
* The one rule both the producer, at export `begin`, and the importer, at import `begin`, apply to a schema: the plan
|
|
619
623
|
* a dump is written and loaded by, or an `unsupported_schema` refusal naming the table. A foreign key whose parent lies
|
|
620
624
|
* in its own table's cycle (the table itself included) is loaded `NULL` and linked once every row is in, so each of its
|
|
621
|
-
* columns must take a temporary `NULL`: nullable, outside the primary key, referenced by no foreign key,
|
|
622
|
-
*
|
|
625
|
+
* columns must take a temporary `NULL`: nullable, outside the primary key, referenced by no foreign key, named by no
|
|
626
|
+
* `CHECK`, in a table without a `NOT NULL` generated column, a generated column a `CHECK` names, or a partial, expression
|
|
627
|
+
* or generated-column unique index. A `WITHOUT ROWID` or
|
|
623
628
|
* virtual table, a table without a name that reads its rowid, a foreign key to a table outside the dump or without the
|
|
624
629
|
* named key, and a foreign key checked only at commit are refused.
|
|
625
630
|
*/
|
|
@@ -1650,9 +1655,16 @@ function loadOrder(tables: readonly DescribedTable[], cycle: ReadonlyMap<string,
|
|
|
1650
1655
|
|
|
1651
1656
|
/** Whether every deferred column of `table` can hold `NULL` from its part until the link pass, with nothing to violate. */
|
|
1652
1657
|
function takesTemporaryNull(table: OpsDumpSchemaTable, deferred: readonly OpsDumpSchemaColumn[], referenced: ReadonlySet<string>): boolean {
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1658
|
+
// A `CHECK` answers the same for a `NULL` in a column it does not read; a generated column may read a deferred one.
|
|
1659
|
+
const checkReads = (column: OpsDumpSchemaColumn): boolean => table.checkNames === null || table.checkNames.includes(asciiLower(column.name))
|
|
1660
|
+
if (table.columns.some((column) => column.generated && (column.notNull || checkReads(column)))) return false
|
|
1661
|
+
// A generated column that reads a deferred one may take one value for many rows while that column is `NULL`.
|
|
1662
|
+
const generated = new Set(table.columns.filter((column) => column.generated).map((column) => asciiLower(column.name)))
|
|
1663
|
+
const indexedGenerated = (index: OpsDumpSchemaIndex): boolean => index.columns.some((name) => name !== null && generated.has(asciiLower(name)))
|
|
1664
|
+
if (table.indexes.some((index) => index.unique && (index.partial || index.columns.includes(null) || indexedGenerated(index)))) return false
|
|
1665
|
+
return deferred.every((column) =>
|
|
1666
|
+
!column.notNull && column.primaryKey === 0 && !referenced.has(columnKey(table.name, column.name)) && !checkReads(column)
|
|
1667
|
+
)
|
|
1656
1668
|
}
|
|
1657
1669
|
|
|
1658
1670
|
function columnKey(table: string, column: string): string {
|
package/types/src/ops.d.ts
CHANGED
|
@@ -336,8 +336,12 @@ export interface OpsDumpSchemaTable {
|
|
|
336
336
|
readonly name: string;
|
|
337
337
|
readonly virtual: boolean;
|
|
338
338
|
readonly withoutRowid: boolean;
|
|
339
|
-
/**
|
|
340
|
-
|
|
339
|
+
/**
|
|
340
|
+
* Every name a `CHECK` constraint of the table's SQL reads, ASCII-lowercase and unquoted (keywords included), so a
|
|
341
|
+
* column it does not list cannot change what a `CHECK` answers. Empty for a table without one; `null` from a reader
|
|
342
|
+
* that cannot tell, which counts as naming every column.
|
|
343
|
+
*/
|
|
344
|
+
readonly checkNames: readonly string[] | null;
|
|
341
345
|
readonly columns: readonly OpsDumpSchemaColumn[];
|
|
342
346
|
readonly indexes: readonly OpsDumpSchemaIndex[];
|
|
343
347
|
readonly foreignKeys: readonly OpsDumpSchemaForeignKey[];
|
|
@@ -364,8 +368,9 @@ export interface OpsDumpPlan {
|
|
|
364
368
|
* The one rule both the producer, at export `begin`, and the importer, at import `begin`, apply to a schema: the plan
|
|
365
369
|
* a dump is written and loaded by, or an `unsupported_schema` refusal naming the table. A foreign key whose parent lies
|
|
366
370
|
* in its own table's cycle (the table itself included) is loaded `NULL` and linked once every row is in, so each of its
|
|
367
|
-
* columns must take a temporary `NULL`: nullable, outside the primary key, referenced by no foreign key,
|
|
368
|
-
*
|
|
371
|
+
* columns must take a temporary `NULL`: nullable, outside the primary key, referenced by no foreign key, named by no
|
|
372
|
+
* `CHECK`, in a table without a `NOT NULL` generated column, a generated column a `CHECK` names, or a partial, expression
|
|
373
|
+
* or generated-column unique index. A `WITHOUT ROWID` or
|
|
369
374
|
* virtual table, a table without a name that reads its rowid, a foreign key to a table outside the dump or without the
|
|
370
375
|
* named key, and a foreign key checked only at commit are refused.
|
|
371
376
|
*/
|