Open dbackeus opened 1 day ago
I've only used this gem to perform read queries, and never to write 🤷🏻. What behavior do you expect exactly? Do you want to ignore the concept of duplicates and insert them anyway? Or do you want a best-effort to try and minimize inserting duplicates by running a SELECT query first?
What would make sense to me is to allow insert_all
but without any duplicates protection.
According to the insert_all
documentation the default behaviour is to use all "unique indexes" to avoid duplicates, but since Redshift doesn't support unique indexes the obvious outcome should be that it runs without any duplicate detection.
I also think explicitly sending unique_by
with a non empty Array should raise an ArgumentError
to make it clear that duplicate protection also can't be forced on (potentially this could be evolved to use a SELECT
statement but seems YAGNI at this point).
Attempting to use the insert_all API from ActiveRecord results in:
ArgumentError: ActiveRecord::ConnectionAdapters::RedshiftAdapter does not support skipping duplicates
Attempting to bypass the uniqueness check by passing
unique_by: []
results in:ArgumentError: ActiveRecord::ConnectionAdapters::RedshiftAdapter does not support :unique_by
It makes sense that Redshift can't support skipping duplicates. But perhaps it would be possible to bypass the duplicate check altogether.
Any thoughts or suggestions for workarounds?