Skip to content

Commit

Permalink
WIP: fix for #65
Browse files Browse the repository at this point in the history
  • Loading branch information
rts-rob committed Sep 10, 2021
1 parent ee007db commit 26e01a5
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 23 deletions.
114 changes: 92 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"eslint-plugin-ava": "^11.0.0",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-react": "^7.22.0",
"faunadb": "^4.1.1",
"faunadb": "^4.4.1",
"install-peers-cli": "^2.2.0",
"prettier": "^2.2.1",
"sinon": "^9.2.2",
Expand Down
15 changes: 15 additions & 0 deletions src/fql/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ const sameStructure = (obj1: any, obj2: any): any => {
}

const sameStructureIter = (obj1: any, obj2: any): any => {
// Need a type check for strings per https://github.com/fauna-labs/fauna-schema-migrate/issues/65
// See also https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/in_operator_no_object
// If both are strings, return whether they are equal
if (typeof obj1 === 'string' && typeof obj2 === 'string') {
if (obj1 === obj2) {
return true
} else {
throw new Error('notequal')
}
}
// If only one is a string, throw an error
if (typeof obj1 !== 'object' || typeof obj2 !== 'object')
throw new Error('notequal')

// If neither is a string, keep the original for block
for (const key in obj1) {
if (key !== 'isFaunaExpr') {
if (!(key in obj2)) {
Expand Down

0 comments on commit 26e01a5

Please sign in to comment.