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

raise on non-symbolic and non-lowercase :id #740

Merged

Conversation

Vagab
Copy link
Contributor

@Vagab Vagab commented Jul 2, 2024

resolves #695

@@ -396,6 +396,10 @@ def __attributes__(attributes, buffer = +"")
raise ArgumentError.new("Unsafe attribute name detected: #{k}.")
end

if lower_name.to_sym == :id && k != :id
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it might be slightly faster to have a set of invalid IDs that we check for inclusion in, e.g.:

INVALID_IDS = Set[:iD, :Id, :ID, "id", "iD", "Id", "ID"].freeze

Might be worth benchmarking sometime.

@joeldrapper joeldrapper merged commit d5fb7ea into phlex-ruby:main Jul 2, 2024
1 of 11 checks passed
joeldrapper added a commit that referenced this pull request Jul 2, 2024
@Vagab Vagab deleted the raise-on-non-lowercase-symbol-id branch July 2, 2024 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Disallow setting an id attribute as a string or uppercase symbol
2 participants