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

Move definition of search_joins attribute from records to search action #511

Merged
merged 1 commit into from Jan 21, 2022

Conversation

cgunther
Copy link
Contributor

Previously it was up to each record to define this attribute, if it
offered the search action. This created scenarios where a record like Bin
offered the search action, but didn't define the search_joins
attribute and therefore searching bins would error:

undefined method `search_joins=' for #<NetSuite::Records::Bin:0x00007f8f32948bf8 @internal_id="1044", @external_id=nil, @attributes={:bin_number=>"WIP-Fabric"}> (NoMethodError)

due to SearchResult assuming the record had such an attribute:

result_wrapper.search_joins = record

Now adding the search action to a record automatically adds the
necessary search_joins attribute.

The attribute was previously defined on AssemblyComponent,
SerializedInventoryItemLocation, and WorkOrderItem, however none of
those support actions at all, let alone the search action. They're all
records for sublist items. I suspect the attribute was erroneously
introduced in the first place as a result of copy/pasting to create the
record.

…tion

Previously it was up to each record to define this attribute, if it
offered the search action. This created scenarios where a record like [`Bin`](https://github.com/NetSweet/netsuite/blob/9f1000535d62045e1fcb6220192840c943eaba57/lib/netsuite/records/bin.rb)
offered the `search` action, but didn't define the `search_joins`
attribute and therefore searching bins would error:

```
undefined method `search_joins=' for #<NetSuite::Records::Bin:0x00007f8f32948bf8 @internal_id="1044", @external_id=nil, @attributes={:bin_number=>"WIP-Fabric"}> (NoMethodError)
```

Due to `SearchResult` assuming the record had such an attribute:
https://github.com/NetSweet/netsuite/blob/9f1000535d62045e1fcb6220192840c943eaba57/lib/netsuite/support/search_result.rb#L112

Now adding the `search` action to a record automatically adds the
necessary `search_joins` attribute.

The attribute was previously defined on `AssemblyComponent`,
`SerializedInventoryItemLocation`, and `WorkOrderItem`, however none of
those support actions at all, let alone the `search` action. They're all
records for sublist items. I suspect the attribute was erroneously
introduced in the first place as a result of copy/pasting to create the
record.
@cgunther
Copy link
Contributor Author

This has been added piecemeal, record-by-record, in the past (#164, #280, #295, #334, #342, #349, #350, #412), but hopefully this now solves it once-and-for-all across all records, now and into the future.

Copy link
Member

@iloveitaly iloveitaly left a comment

Choose a reason for hiding this comment

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

Much cleaner! Nice change.

@iloveitaly iloveitaly merged commit 60a8d6b into NetSweet:master Jan 21, 2022
@cgunther cgunther deleted the search-joins-attr branch January 21, 2022 15:04
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.

None yet

2 participants