relational-schema
Advanced tools
Comparing version 0.5.0 to 0.5.1
@@ -54,2 +54,7 @@ import { ConstraintDefinition, EnumDefinitions, RelationDefinition, TableColumnsDefinition, TableMap, TableSchemaDefinition } from '../types'; | ||
/** | ||
* Uses v8 chronological ordering to create a stable ordering based on lexical sort of keys | ||
* @param data | ||
*/ | ||
private stableOrderedMap; | ||
/** | ||
* Get the schema definition for a table | ||
@@ -56,0 +61,0 @@ */ |
@@ -26,2 +26,3 @@ "use strict"; | ||
const pluralize = __importStar(require("pluralize")); | ||
const lodash_1 = require("lodash"); | ||
/** | ||
@@ -186,2 +187,18 @@ * Build a js schema that describes the table and relationships | ||
/** | ||
* Uses v8 chronological ordering to create a stable ordering based on lexical sort of keys | ||
* @param data | ||
*/ | ||
stableOrderedMap(data) { | ||
if (!data) { | ||
return data; | ||
} | ||
const stable = {}; | ||
Object.keys(data) | ||
.sort() | ||
.forEach((each) => { | ||
stable[each] = data[each]; | ||
}); | ||
return stable; | ||
} | ||
/** | ||
* Get the schema definition for a table | ||
@@ -209,8 +226,12 @@ */ | ||
primaryKey: cardinality_resolver_1.CardinalityResolver.primaryKey(tableConstraints), | ||
keys: tableConstraints, | ||
uniqueKeyCombinations, | ||
relations: [...forwardRels, ...backwardRels, ...tableTransitiveRelations], | ||
columns: tableColumns, | ||
keys: lodash_1.sortBy(tableConstraints, (c) => c.constraintName), | ||
uniqueKeyCombinations: lodash_1.sortBy(uniqueKeyCombinations, (u) => u.join(':')), | ||
relations: [ | ||
...lodash_1.sortBy(forwardRels, (r) => r.constraintName), | ||
...lodash_1.sortBy(backwardRels, (r) => r.constraintName), | ||
...lodash_1.sortBy(tableTransitiveRelations, (r) => r.alias), | ||
], | ||
columns: this.stableOrderedMap(tableColumns), | ||
softDelete, | ||
enums: tableEnums, | ||
enums: this.stableOrderedMap(tableEnums), | ||
}; | ||
@@ -217,0 +238,0 @@ } |
@@ -0,1 +1,8 @@ | ||
## [0.5.1](https://github.com/MattGson/relational-schema/compare/v0.5.0...v0.5.1) (2021-10-25) | ||
### Bug Fixes | ||
* **introspect:** fixes ordering of tables, columns etc to be stable ([09acd99](https://github.com/MattGson/relational-schema/commit/09acd99deaa1a502998aae47f69170f0d704e6ed)), closes [#25](https://github.com/MattGson/relational-schema/issues/25) | ||
# [0.5.0](https://github.com/MattGson/relational-schema/compare/v0.4.4...v0.5.0) (2021-10-11) | ||
@@ -2,0 +9,0 @@ |
{ | ||
"name": "relational-schema", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "Generate a js schema for a relational database", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
154421
1909