Skip to content

Throw exception on case-insensitive duplicate IDs#49

Merged
eldadfux merged 10 commits into
mainfrom
feat-attribute-case-insensitivity
Aug 14, 2021
Merged

Throw exception on case-insensitive duplicate IDs#49
eldadfux merged 10 commits into
mainfrom
feat-attribute-case-insensitivity

Conversation

@kodumbeats

@kodumbeats kodumbeats commented Aug 5, 2021

Copy link
Copy Markdown
Contributor

MongoDB document keys are case sensitive, but MariaDB column names are not.

This PR adds a case-insensitive check when creating attributes/indexes or adding one to the queue, and will throw Utopia\Database\Exception\Duplicate if a match is found.

This PR also changes the default index on _uid for the MongoDB adapter to be case-insensitive.

Testing
Tests have been added to catch these exceptions.

Unanswered questions

  • When adding attributes to a collection, the attribute document is appended to $attribute->getAttribute('attributes'), and when fetched, returns Document[] $attributes. However, when adding all attributes at once via createCollection, I receive just a plain array, not a Document. I had to hack around this problem, and I would like to not have to do this:

Comment thread src/Database/Database.php Outdated
Comment thread src/Database/Database.php Outdated
@eldadfux

Copy link
Copy Markdown
Member

I think we need the same implementation for indexes as well if we don't have it yet.

@kodumbeats kodumbeats changed the title Throw exception on case-insensitive duplicate attributes Throw exception on case-insensitive duplicate IDs Aug 10, 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

Successfully merging this pull request may close these issues.

2 participants