Skip to content

NH-3630 - Add bitwise operation support for dialects using internal/external functions #280

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

Merged
merged 6 commits into from
Feb 25, 2015

Conversation

amroel
Copy link
Contributor

@amroel amroel commented Jul 5, 2014

https://nhibernate.jira.com/browse/NH-3630
Changes to SqlGenerator and Dialect to allow injection of vendor specific bitwise functions
+
Bitwise functions for firebird

RegisterFunction("bor", new BitwiseNativeOperation("|"));
RegisterFunction("bxor", new BitwiseNativeOperation("^"));
RegisterFunction("bnot", new BitwiseNativeOperation("~"));

Copy link
Member

Choose a reason for hiding this comment

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

In HQL you can write anyRandomFunctionName(x,y) and if the HQL parser doesn't recognize it, the call will be copied directly into the SQL. Have you verified that no supported database directly supports the band, bor, bxor and bnot as function names? If any does, this may cause a regression.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it won't. It will get passed to sql just as did before.
The Intention is that " & ", " | ", " ^ " and " ~ " will be identified by the SQLGenerator class as Bitwise operations.
For the SqlGenerator to call the proper function on the dialect it searches internally for functions named band, bor, bxor and bnot.
Hence if the HQL code does directly call band, bor etc. they won't be recognized at all and thus will get passed directly to SQL.

@hazzik
Copy link
Member

hazzik commented Nov 15, 2014

@amroel can you please clean-up this pull request (rebase on top of master) and add some other dialects?

@hazzik
Copy link
Member

hazzik commented Nov 15, 2014

Also, I would like have grammar unchanged and instead change linq to hql generator to use functions instead of operators (like this has been done with concat)

@amroel
Copy link
Contributor Author

amroel commented Nov 15, 2014

@hazzik What is the reasoning behind leaving the grammer unchanged?
Your proposal will work for Linq but would still fail for HQL would'nt it?

@hazzik
Copy link
Member

hazzik commented Nov 15, 2014

I think it is better to be explicit rather than make some tricky changes

@amroel
Copy link
Contributor Author

amroel commented Nov 15, 2014

Sorry @hazzik, but I still don't get it :)
Changing Linq would still leave existing HQL tests with Bitwise operations failing!
Or am I missing something?

@hazzik hazzik changed the title NH 3630 NH-3630 - Add bitwise operation support for dialects using internal/external functions Nov 18, 2014
@amroel amroel force-pushed the NH-3630 branch 2 times, most recently from e1f4b5b to 552b3a7 Compare February 23, 2015 13:32
@hazzik
Copy link
Member

hazzik commented Feb 24, 2015

@amroel can you please rebase this on top of master? This will require grammar regeneration as well.

@amroel
Copy link
Contributor Author

amroel commented Feb 24, 2015

@hazzik Done.

hazzik added a commit that referenced this pull request Feb 25, 2015
NH-3630 - Add bitwise operation support for dialects using internal/external functions
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