git-csv-diff
Advanced tools
Comparing version 1.1.2 to 1.1.3
{ | ||
"name": "git-csv-diff", | ||
"author": "Valor-Software", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"license": "GPL-3.0", | ||
@@ -6,0 +6,0 @@ "description": "Library generate difference between csv-files based on Git commit hash", |
@@ -57,4 +57,2 @@ 'use strict'; | ||
// set FileName | ||
setMetaDataFile(modelDiff.metadata.file, metaData); | ||
@@ -64,2 +62,5 @@ setMetaDataType(modelDiff.metadata); | ||
const primaryKeys = getPrimaryKeys(modelDiff.metadata); | ||
const primaryKey = _.first(primaryKeys); | ||
/* Slice Groupd of Changes */ | ||
@@ -116,5 +117,7 @@ | ||
let diffResultGidField; | ||
let indexGid = 0; | ||
if (diffResultColumns[0] == "@@") { | ||
diffResultColumns.shift(); | ||
diffResultGidField = diffResultColumns[0]; | ||
indexGid = diffResultColumns.indexOf(primaryKey); | ||
diffResultGidField = diffResultColumns[indexGid]; | ||
} | ||
@@ -172,3 +175,3 @@ | ||
dataRowRemoved['gid'] = diffResultGidField; | ||
dataRowRemoved[diffResultGidField] = value[0]; | ||
dataRowRemoved[diffResultGidField] = value[indexGid]; | ||
} | ||
@@ -198,3 +201,3 @@ | ||
dataRowUpdated["gid"] = diffResultGidField; | ||
dataRowUpdated[diffResultGidField] = value[0]; | ||
dataRowUpdated[diffResultGidField] = value[indexGid]; | ||
dataRowUpdated["data-update"] = dataRow; | ||
@@ -289,3 +292,3 @@ | ||
dataRowChanged["gid"] = diffResultGidField; | ||
dataRowChanged[diffResultGidField] = value[0]; | ||
dataRowChanged[diffResultGidField] = value[indexGid]; | ||
dataRowChanged["data-update"] = dataRow; | ||
@@ -337,3 +340,3 @@ | ||
dataRowChanged["gid"] = diffResultGidField; | ||
dataRowChanged[diffResultGidField] = value[0]; | ||
dataRowChanged[diffResultGidField] = value[indexGid]; | ||
dataRowChanged["data-update"] = dataRow; | ||
@@ -387,12 +390,8 @@ | ||
function setMetaDataType(metadata) { | ||
// detect schema from `old` file if it was removed and not exists in `new` | ||
const schemaSource = metadata.file.new ? metadata.file.new : metadata.file.old; | ||
const primaryKeys = getPrimaryKeys(metadata); | ||
const primaryKeyRaw = _.clone(schemaSource.schema.primaryKey); | ||
const primaryKey = _.isString(primaryKeyRaw) ? [primaryKeyRaw] : primaryKeyRaw; | ||
if (primaryKey.length > 1) | ||
if (primaryKeys.length > 1) | ||
return metadata.type = constants.DATAPOINTS; | ||
if (_.includes(constants.CONCEPTS, _.first(primaryKey))) | ||
if (_.includes(constants.CONCEPTS, _.first(primaryKeys))) | ||
return metadata.type = constants.CONCEPTS; | ||
@@ -403,2 +402,10 @@ | ||
function getPrimaryKeys(metadata) { | ||
// detect schema from `old` file if it was removed and not exists in `new` | ||
const schemaSource = metadata.file.new ? metadata.file.new : metadata.file.old; | ||
const primaryKeyRaw = _.clone(schemaSource.schema.primaryKey); | ||
return _.isString(primaryKeyRaw) ? [primaryKeyRaw] : primaryKeyRaw; | ||
} | ||
function writeToStream(stream, model) { | ||
@@ -405,0 +412,0 @@ let modelString = JSON.stringify(model); |
@@ -17,4 +17,4 @@ 'use strict'; | ||
let MockDatapackageOld = {"name":"ddf--ws-testing","title":"ddf--ws-testing","description":"","version":"0.0.1","language":{"id":"en","name":"English"},"translations":[{"id":"nl-nl","name":"Dutch"}],"license":"","author":"","resources":[{"path":"ddf--concepts.csv","name":"ddf--concepts","schema":{"fields":[{"name":"concept"},{"name":"concept_type"},{"name":"domain"},{"name":"additional_column"}],"primaryKey":"concept"}},{"path":"ddf--entities--region.csv","name":"ddf--entities--region","schema":{"fields":[{"name":"region"},{"name":"full_name_changed"}],"primaryKey":"region"}}]}; | ||
let MockDatapackageNew = {"name":"ddf--ws-testing","title":"ddf--ws-testing","description":"","version":"0.0.1","language":{"id":"en","name":"English"},"translations":[{"id":"nl-nl","name":"Dutch"}],"license":"","author":"","resources":[{"path":"ddf--entities--region.csv","name":"ddf--entities--region","schema":{"fields":[{"name":"region"},{"name":"full_name_changed"}],"primaryKey":"region"}},{"path":"ddf--concepts.csv","name":"ddf--concepts","schema":{"fields":[{"name":"concept"},{"name":"concept_type"},{"name":"domain"},{"name":"additional_column"}],"primaryKey":"concept"}},{"path":"ddf--entities--region.csv","name":"ddf--entities--region","schema":{"fields":[{"name":"region"},{"name":"full_name_changed"}],"primaryKey":"region"}}]}; | ||
let MockDatapackageOld = {"name":"ddf--ws-testing","title":"ddf--ws-testing","description":"","version":"0.0.1","language":{"id":"en","name":"English"},"translations":[{"id":"nl-nl","name":"Dutch"}],"license":"","author":"","resources":[{"path":"ddf--concepts.csv","name":"ddf--concepts","schema":{"fields":[{"name":"concept"},{"name":"concept_type"},{"name":"domain"},{"name":"additional_column"}],"primaryKey":"concept"}},{"path":"ddf--entities--region.csv","name":"ddf--entities--region","schema":{"fields":[{"name":"region"},{"name":"full_name_changed"}],"primaryKey":"company"}}]}; | ||
let MockDatapackageNew = {"name":"ddf--ws-testing","title":"ddf--ws-testing","description":"","version":"0.0.1","language":{"id":"en","name":"English"},"translations":[{"id":"nl-nl","name":"Dutch"}],"license":"","author":"","resources":[{"path":"ddf--entities--region.csv","name":"ddf--entities--region","schema":{"fields":[{"name":"company"},{"name":"full_name_changed"}],"primaryKey":"company"}},{"path":"ddf--concepts.csv","name":"ddf--concepts","schema":{"fields":[{"name":"concept"},{"name":"concept_type"},{"name":"domain"},{"name":"additional_column"}],"primaryKey":"company"}},{"path":"ddf--entities--region.csv","name":"ddf--entities--region","schema":{"fields":[{"name":"region"},{"name":"full_name_changed"}],"primaryKey":"company"}}]}; | ||
@@ -21,0 +21,0 @@ /* params */ |
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
70226
858