Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NGram translates to Ngram which will cause an error #42

Closed
aprilmintacpineda opened this issue May 2, 2021 · 2 comments
Closed

NGram translates to Ngram which will cause an error #42

aprilmintacpineda opened this issue May 2, 2021 · 2 comments

Comments

@aprilmintacpineda
Copy link

aprilmintacpineda commented May 2, 2021

I have the following:

CreateIndex({
  name: 'searchUsersByName',
  terms: [
    { binding: 'search' }
  ],
  source: {
    collection: Collection('users'),
    fields: {
      search: Query(
        Lambda(
          ['row'],
          Union(
            NGram(
              LowerCase(
                Select(['data', 'firstName'], Var('row'))
              ),
              2,
              3
            ),
            NGram(
              LowerCase(
                Select(['data', 'middleName'], Var('row'))
              ),
              2,
              3
            ),
            NGram(
              LowerCase(
                Select(['data', 'surname'], Var('row'))
              ),
              2,
              3
            )
          )
        )
      )
    }
  }
});

And when I run fauna-schema-migrate generate, it generates the following:

CreateIndex({
  name: "searchUsersByName",
  terms: [{
    binding: "search"
  }],
  source: {
    collection: Collection("users"),
    fields: {
      search: Query(Lambda(["row"], Union(Ngram(LowerCase(Select(["data", "firstName"], Var("row"))), 2, 3), Ngram(LowerCase(Select(["data", "middleName"], Var("row"))), 2, 3), Ngram(LowerCase(Select(["data", "surname"], Var("row"))), 2, 3))))
    }
  }
})

Notice that NGram has been transformed into Ngram which is now incorrect. when I ran the migration, I got the following error:

Fauna Schema Migrate - 2.1.0
---------------------------------------
--- Starting subtask Retrieving current cloud migration state
--- Finished subtask Retrieved current migration state

Error in file: fauna/migrations/2021-05-02T03_43_07.746Z/create-index-searchUsersByName.fql
  Ngram is not defined

EDIT 1:

I tried manualy editing the generated migration to:

CreateIndex({
  name: "searchUsersByName",
  terms: [{
    binding: "search"
  }],
  source: {
    collection: Collection("users"),
    fields: {
      search: Query(Lambda(["row"], Union(NGram(LowerCase(Select(["data", "firstName"], Var("row"))), 2, 3), NGram(LowerCase(Select(["data", "middleName"], Var("row"))), 2, 3), NGram(LowerCase(Select(["data", "surname"], Var("row"))), 2, 3))))
    }
  }
})

I simply updated Ngram to NGram but somehow I still got the same error.

EDIT 2:

Okay, it's the same error but somehow different trails:

Fauna Schema Migrate - 2.1.0
---------------------------------------
--- Starting subtask Retrieving current cloud migration state
--- Finished subtask Retrieved current migration state
--------- Current cloud migrations----------
    2021-03-28T10:48:52.250Z
    2021-04-17T02:03:19.186Z
    2021-04-17T09:15:39.642Z
--------- Current local migrations ----------
    2021-03-28T10:48:52.250Z
    2021-04-17T02:03:19.186Z
    2021-04-17T09:15:39.642Z
    2021-05-02T03:43:07.746Z
--------- Task ----------
    apply 1 migrations


--- Starting subtask [ DB: ROOT ] Generate migration code
  Ngram is not defined
Stacktrace ReferenceError: Ngram is not defined

EDIT 3:

I have updated to version 2.1.2 but still the same error as above.

@rts-rob
Copy link
Contributor

rts-rob commented May 3, 2021

Thanks for submitting this, @aprilmintacpineda !

This appears to be coming from the JavaScript driver. Since NGram is not listed as one of the special cases, it is not converted to CamelCase correctly. We've created this issue in the JavaScript driver repo.

We'll update this issue once the JavaScript driver is updated.

@rts-rob
Copy link
Contributor

rts-rob commented May 7, 2021

Fixed in fauna/faunadb-js#487

@rts-rob rts-rob closed this as completed May 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants