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

Atlas does not raise an error if an input filename is not unique #84

Open
grdw opened this issue Jan 18, 2017 · 5 comments
Open

Atlas does not raise an error if an input filename is not unique #84

grdw opened this issue Jan 18, 2017 · 5 comments

Comments

@grdw
Copy link
Contributor

grdw commented Jan 18, 2017

Related discussion: quintel/etmodel#2324 (comment)


It would be great if Atlas were to know if all the filenames of inputs are unique.

@antw
Copy link
Contributor

antw commented Jan 18, 2017

Atlas does not raise an error if an input filename is not unique

It should do.

Atlas::Input.new(key: 'unique', query: '0.0').save
# => true

Atlas::Input.new(key: 'unique', query: '0.0').save
# => Atlas::DuplicateKeyError: Duplicate key found: unique
# => from atlas/lib/atlas/active_document/manager.rb:95:in `write'

@grdw
Copy link
Contributor Author

grdw commented Jan 18, 2017

That's odd. I can reproduce the error with the code you provided but ETEngine never throws an error once you use two inputs with the same name. I'll investigate this further when I've a bit more time.

@ploh
Copy link

ploh commented Jan 18, 2017

Atlas does not raise an error if an input filename is not unique

It should do.

But that only checks the uniqueness when writing, not when reading. And since etsource files are often written by hand, this seems to not be enough.

What about adding raising an exception if a key occurs twice here?

@antw
Copy link
Contributor

antw commented Jan 18, 2017

But that only checks the uniqueness when writing, not when reading. And since etsource files are often written by hand, this seems to not be enough.

I'm not sure checking that is really Atlas' responsibility; as far as it is concerned, you create documents by calling new then save. I have mixed feeling about adding a check to Atlas, since it's not possible to create a duplicate document using Atlas alone.

I think my view is:

What I would support is being able to do something validates :key, uniqueness: true so that a duplicate document would still be caught when calling save (and automatically by the ETSource validate_documents_spec.rb tests).

This isn't very high-priority IMO.

@ploh
Copy link

ploh commented Jan 18, 2017

If the error cannot occur through Atlas, then the test should exist in the ETSource specs, so that the user can be warned before commiting their (hand-made) changes.

What I would support is being able to do something validates :key, uniqueness: true so that a duplicate document would still be caught when calling save (and automatically by the ETSource validate_documents_spec.rb tests).

👍

@grdw grdw assigned antw and unassigned grdw May 16, 2018
@antw antw removed their assignment Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants