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

Not possible to use "insert_all" #39

Open
dbackeus opened this issue Sep 23, 2024 · 2 comments
Open

Not possible to use "insert_all" #39

dbackeus opened this issue Sep 23, 2024 · 2 comments

Comments

@dbackeus
Copy link

dbackeus commented Sep 23, 2024

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?

@quentindemetz
Copy link

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?

@dbackeus
Copy link
Author

dbackeus commented Sep 24, 2024

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).

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

No branches or pull requests

2 participants