-
Notifications
You must be signed in to change notification settings - Fork 361
Add support for CAST
for a column
#1066
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
Comments
|
In the given case, it only receives a single argument, which is why I thought I might pull it off in my work around. :)
I cannot find the If you are thinking of the method where I can throw a raw string into it that will be passed "as-is", then my concern would be that I would lose the dialect mapping support (how names are formatted etc.). I have been trying hard to avoid ending up generating my own queries to ensure portability. :) (Context: The code base I am working on used to generate the SQL itself and we had a lot of issues with corner cases because of this.) |
The method I tried to reference is I understand your concerns. It was intended as a workaround not a as a proper solution. |
Ok. Thanks for the suggestion. :) Also many thanks for fixing the join related issues I reported. It was very much appreciated. :) |
How about adding us some convenience support here? |
Hi @mp911de Assuming the comment was for me, could you elaborate a bit on what that convenience support would look like? :) |
We have utility classes such as |
Ah. Yes, a |
Example: Functions.cast(table_user.column("name"),"VARCHAR2") Also adds a toString to AbstractSegment to avoid stack overflows. Closes #1066
CAST
a column via spring-data's API?CAST
for a column
Uh oh!
There was an error while loading. Please reload this page.
I have a case where I want to cast a column to a VARCHAR for the comparison to support a UI feature of doing substring searches. Simplified to something like
SELECT * FROM customer WHERE CAST(customerId AS VARCHAR) LIKE '%123%'
.As far as I can tell, the most portable way of doing this is to use
CAST(x AS type)
and so I thought I would abuse the following:Unfortunately, under (at least postgres) this generates the following invalid SQL:
CAST(x.VARCHAR)
Admittedly, this is abuse as
column.as
says it is for a different purpose. But I hope you can clarify how I would do a SQL type cast.The text was updated successfully, but these errors were encountered: