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

Added Avram::Join::Raw. #1050

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

zw963
Copy link
Contributor

@zw963 zw963 commented Jun 22, 2024

Fix #1048

self
end

def joins : Array(Avram::Join::Raw)
Copy link
Member

Choose a reason for hiding this comment

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

this method would override the methods on 318 of the same name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this method would override the methods on 318 of the same name

I thought override is not so accurately, because the return value of both method is different, the issue is, when joins_sql invoke joins metrhod, it can't distinguish the difference between the two method.

I have no idea about how to fix this, could you please give me a little clue?

Copy link
Contributor

Choose a reason for hiding this comment

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

Crystal does not factor in return type when determining a method's signature, at least for overrides. There is no way during method call to determine which of the variants to dispatch to if they only differ in return types. So in this case, yes, the second method will override the first.

How about renaming the method to #raw_joins?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Crystal does not factor in return type when determining a method's signature, at least for overrides. There is no way during method call to determine which of the variants to dispatch to if they only differ in return types.

I guess it's can?

	def hello : String
	  "hello"
	end

	def hello : Int32
	  100
	end

	def say_hello : Int32
	  hello
	end

	p! say_hello # => 100

How about renaming the method to #raw_joins?

I remember i tried it like this, but that #raw_joins method never by invoked some where, there are some(probably macro?) magic happen some where, i didn't found it.

@jwoertink
Copy link
Member

It's a good start! Thanks for taking this on. You're definitely going to need to add a bunch of specs for this. I would suggest to start working through some of those specs to make sure all of the SQL being generated is correct. That may help get through these CI errors.

@zw963
Copy link
Contributor Author

zw963 commented Jun 23, 2024

I would suggest to start working through some of those specs to make sure all of the SQL being generated is correct.

Yes, I am trying to see if it is possible to add this new feature but without need change the existing spec. (only add more)

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.

Support write LEFT JOIN which include more than one condition use AND?
3 participants