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

How to register new function differently implemented in supported dialects? #15

Open
floresek opened this issue Oct 8, 2015 · 5 comments

Comments

@floresek
Copy link

floresek commented Oct 8, 2015

Hi,

I want to add new function which implementation differs in supported dialects.

F.e. I want to execute query:

select instr(column1, '.') from table1
-- oracle dialect
select position('.' in column1) from table1
-- postgres dialect
--etc

on all supported DB
Function instr is not in sql* standard so each DB can implement it differently (function name and parameters).

I can see that polydb has dialog support.
Could you explain how to add function:

int position(String columnName, String textToFind)

to be supported in many DB, please?

Cheers
Mariusz

@floresek floresek changed the title How to register new function different in supported dialects? How to register new function differently implemented in supported dialects? Oct 8, 2015
@adamdubiel
Copy link
Member

Hm, it supports dialects at keyword level, but i never thought of adding support for functions. Probably you would need to extend SelectQuery, but this might get a bit sloppy. Other possibility would be to add bit more generic functions support, but it would need some more thought.

@floresek
Copy link
Author

floresek commented Oct 8, 2015

The simpler the better ;)

Could you suggest the simplest way?

@floresek
Copy link
Author

floresek commented Oct 8, 2015

BTW - I want to change current way of resolving max CommitId in javers.

Current query (basing on max pk commit id) from time to time crashes (because max px commit id is not max)

So I need to use functions to convert string commit id to number (to select max from DB query)

@bartoszwalacik
Copy link
Contributor

why you think that max(to_number(commit_id)) would be more max than simply max(commit_pk)?

@floresek
Copy link
Author

floresek commented Oct 9, 2015

Thanks for suggestion. Finally I tried to use:

max(cast(commit_id as decimal(15,2)))

but in Oralce casting is nls_numeric_characters sensitive and when set nls to ',' exception is thrown - invalid number ;(

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

No branches or pull requests

3 participants