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

WIP Fix concat function definition for SybaseSQLAnywhere10Dialect #2982

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

hazzik
Copy link
Member

@hazzik hazzik commented Jan 12, 2022

No description provided.

@bahusoid
Copy link
Member

bahusoid commented Jan 12, 2022

From #2966 (comment):

  • behaves differently than || and requires explicit conversion to string first. It should be ||, but then definition becomes the same as in base dialect. So I just removed the overload.

Yes it behaves differently, but why you think it's incorrect behavior.

From what I see in docs https://www.sqlines.com/sybase-asa/functions/string.
With ||

NULL value in any parameter is treated as '' (empty string):

And with +

If any value is NULL, the result is NULL

Maybe + was used for more consistent behavior across dialects as most of them return NULL if any param value is NULL

@hazzik
Copy link
Member Author

hazzik commented Jan 12, 2022

From what I see in docs

The behavior of || is consistent and expected to what we need.

but why you think it's incorrect behavior.

Because of this: SELECT '1' + '2' + 3 would be 15.000000. Wait... What?

And SELECT '1' || '2' || 3 would be '123', and this is exactly how concat should behave.

So, basically, to make + work we need to cast all it's arguments to strings, and convert NULLs to '' (the cast does this).

@hazzik
Copy link
Member Author

hazzik commented Jan 12, 2022

and this is exactly how concat should behave.

Or maybe not... Let's see. I've added test to check with other DBs.

@hazzik
Copy link
Member Author

hazzik commented Jan 12, 2022

That's kind-of unexpected really.

@hazzik hazzik changed the title Fix concat function definition for SybaseSQLAnywhere10Dialect WIP Fix concat function definition for SybaseSQLAnywhere10Dialect Jan 14, 2022
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.

None yet

2 participants