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

Adds basic support for queries generated by #find_by_sql #33

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Commits on Jul 11, 2024

  1. Adds basic support for queries generated by #find_by_sql

    Relates to #32
    
    Allows exporting data that was generated by [find_by_sql][]. This can be desirable when the caller is required to export a calculated field that is not stored directly on the table as demonstrated below.
    
    ```ruby
    User.find_by_sql("SELECT id, 'custom_value' AS custom_field FROM users")
    ArtVandelay::Export.new(export).csv
    ```
    
    As such, this feature does not support the `in_batches_of` option, since
    that would be the responsibility of the query.
    
    This feature also does not (yet) support the `attributes` option.
    
    [find_by_sql]: https://api.rubyonrails.org/classes/ActiveRecord/Querying.html#method-i-find_by_sql
    stevepolitodesign committed Jul 11, 2024
    Configuration menu
    Copy the full SHA
    abf6a42 View commit details
    Browse the repository at this point in the history
  2. Handle empty arrays

    The previous commit failed to account for the case where `#find_by_sql`
    returns no results.
    stevepolitodesign committed Jul 11, 2024
    Configuration menu
    Copy the full SHA
    189693b View commit details
    Browse the repository at this point in the history