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 UnknownAttributeError if .where is given invalid attribute names #80

Conversation

rferg
Copy link
Contributor

@rferg rferg commented Jan 9, 2024

Closes #26

@rferg rferg linked an issue Jan 9, 2024 that may be closed by this pull request
@rferg rferg changed the title Include "invalid" attribute keys in query generated with .where Raise UnknownAttributeError if .where is given invalid attribute names Jan 9, 2024
raise ArgumentError, 'field is required' if field.blank?
raise ArgumentError, "field '#{field}' does not exist on #{sobject}" unless mappings.key?(field.to_sym)
raise UnknownFieldError.new(sobject, field) unless mappings.key?(field.to_sym)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seemed appropriate to change this as well, since it's basically the same thing.

@@ -1,12 +1,17 @@
require 'spec_helper'

class TestSObject < ActiveForce::SObject
def self.decorate(records)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There was a spec failing below when I changed sobject to a class_double because ActiveForce::SObject does not implement .decorate. I see that this method is supposed to be something that the consumer would implement in their subclass. This seems like a weird pattern to use with class methods. In any case, this seemed like the least intrusive workaround so that we can get a class_double here that validates that this mock matches real methods.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, I never fully understood why the original authors of this library did something like that but I guess we're stuck with it for now. 🤷

Copy link
Collaborator

@asedge asedge left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! Will leave it open for a bit to see if anyone else chimes in.

@asedge asedge merged commit 0ae240b into main Jan 10, 2024
5 checks passed
@asedge asedge deleted the 26-bug-invalid-keys-in-where-are-silently-omitted-from-the-generated-query branch January 10, 2024 15:03
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.

[BUG] Invalid keys in .where are silently omitted from the generated query
2 participants