Socket
Socket
Sign inDemoInstall

relational-schema

Package Overview
Dependencies
332
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.5.0 to 0.5.1

5

build/src/introspection/table-schema-builder.d.ts

@@ -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 @@ */

31

build/src/introspection/table-schema-builder.js

@@ -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 @@

2

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc