Skip to content

Conversation

@mirakui
Copy link
Collaborator

@mirakui mirakui commented Jan 5, 2025

The upgrade from v0 to v1 via #32 was not compatible with the behavior of the proxy, and did not cover the use cases of Arproxy as before.

In this PR, I have given up on backward compatibility in the proxy interface and changed the policy so that existing use cases can be covered.

In order to make users aware of this change, I have changed the base class of the proxy from Arproxy::Base to Arproxy::Proxy and made it so that an exception is thrown when using the former.

References

@mirakui mirakui requested a review from nekketsuuu January 5, 2025 08:53

def use(proxy_class, *options)
if proxy_class.is_a?(Class) && proxy_class.ancestors.include?(Arproxy::Base)
# TODO: Add a migration guide URL
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: How about creating a new file, say UPGRADING.md, and moving this guide there? Then we can add an URL before merging, without including a commit hash in the URL

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea. Added UPGRADING.md 31d8af1

@nekketsuuu nekketsuuu requested a review from a team January 6, 2025 02:06
Copy link
Contributor

@nekketsuuu nekketsuuu left a comment

Choose a reason for hiding this comment

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

Looks almost good to me -- just leaving some comments for confirmation


def use(proxy_class, *options)
if proxy_class.is_a?(Class) && proxy_class.ancestors.include?(Arproxy::Base)
# TODO: Add a migration guide URL
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: How about creating a new file, say UPGRADING.md, and moving this guide there? Then we can add an URL before merging, without including a commit hash in the URL

Copy link
Member

@coord-e coord-e left a comment

Choose a reason for hiding this comment

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

mostly LGTM

end

def with_binds?
!!@with_binds
Copy link
Member

Choose a reason for hiding this comment

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

imo: How about defining #with_binds? as !!@binds and set binds: nil in the initializer for non-bind executions? Currently QueryContext#binds is meaningless when !with_binds? and it is less intuitive for users I think

Copy link
Contributor

@nekketsuuu nekketsuuu Jan 20, 2025

Choose a reason for hiding this comment

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

I also considered the same thing, but I wonder if some adapter might use binds: nil for something in the future.

Copy link
Member

Choose a reason for hiding this comment

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

hmm right

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@nekketsuuu is correct. @with_binds is used to identify whether the target method has binds as an argument. This value needs to be managed separately from whether it is nil or not.

e.g. An execute method without binds:

https://github.com/rails/rails/blob/v7.1.0/activerecord/lib/active_record/connection_adapters/mysql2/database_statements.rb#L96

with binds:

https://github.com/rails/rails/blob/main/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb#L552

Copy link
Contributor

@nekketsuuu nekketsuuu left a comment

Choose a reason for hiding this comment

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

Thank you!

@mirakui mirakui merged commit 16ac031 into cookpad:main Jan 23, 2025
10 checks passed
@mirakui mirakui deleted the naruta/20250105_v2_plus branch January 23, 2025 09:57
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.

3 participants