fauna-labs / serverless-fauna

MIT No Attribution
18 stars 3 forks source link

Index Unique field issues #9

Closed rachaelmcq closed 3 years ago

rachaelmcq commented 3 years ago

Something's up with the unique field on indexes. The first time I tried to create an index like this:

fauna:
  indexes:
    accounts_by_phone_number:
      name: accounts_by_phone_number
      unique: true
      source:
        collection: accounts
      terms:
        fields:
          - data.phone_number
      values:
        fields:
          - path: data.phone_number

I got an unrecognized property warning:

] serverless fauna deploy
Serverless: Configuration warning:
Serverless:   at 'fauna.indexes.accounts_by_phone_number': unrecognized property 'unique'

But the index did create successfully, with the unique field set to true. The strange thing is that now, when I make changes or create new indexes with that field, I no longer get the warning. It only happened once.

Additionally, that field doesn't get picked up as a change when it's removed- i.e. create an index with unique: true, deploy, remove the unique line, and deploy again -> index still has the unique field set to true.

github-actions[bot] commented 3 years ago

Internal ticket number is LABS-37

rts-rob commented 3 years ago

Thanks for reporting, @rachaelmcq - I've reproduced and assigned internally.

For updates, setting it to unique: false and redeploying (then back to unique: true, etc.) does work, so it may be a missing check. From the docs, agree with your expectation that not defining unique should set it to false, which is not the current behavior.

rachaelmcq commented 3 years ago

A little poking around the repo suggests that unique and serialized are probably just missing from schemaProps/index.js.