Code Monkey home page Code Monkey logo

Comments (6)

nakamura-to avatar nakamura-to commented on June 3, 2024 1

Thank you for your proposal.

Could you tell me which RDBMS you are using and what kind of SQL you would like to execute?

Some RDBMS provide a feature called collation, which might meet your needs.
https://learn.microsoft.com/en-us/sql/relational-databases/collations/collation-and-unicode-support?view=sql-server-ver16

from doma.

nakamura-to avatar nakamura-to commented on June 3, 2024 1

Thank you for sharing the information.

I think creating a custom function would be suitable in your case.

  1. Create a class that inherits from OracleExpressionFunctions and write a method that generates the string to be passed to the pattern argument of the REGEXP_LIKE function.
package example:

public class MyFunctions extends OracleExpressionFunctions {
  public String insensitive(String text) {
    return ...;
  }
}
  1. Pass an instance of the above MyFunctions to the constructor of OracleDialect.
OracleDialect dialect = new OracleDialect(new MyFunctions());
  1. Specify the fully qualified name of the above MyFunctions in the options for annotation processing (the following example is when writing in build.gradle.kts).
tasks {
    compileJava {
        options.compilerArgs.addAll(listOf("-Adoma.expr.functions=example.MyFunctions"))
    }
}
  1. Call the method defined in MyFunctions from the SQL template.
SELECT * FROM users
WHERE REGEXP_LIKE ( users.name, /* @insensitive(name) */'[[=t=]][[=a=]][[=r=]][[=o=]]')

See also https://doma.readthedocs.io/en/latest/expression/#using-custom-functions.

from doma.

nakamura-to avatar nakamura-to commented on June 3, 2024 1

No, there are no plans to do so at this time.
There are two reasons for this:

  1. As you mentioned, it is challenging to accommodate different RDBMS.
  2. Even if we focused on a specific RDBMS, we believe it would be difficult to write a generic logic that meets the needs of many users.

If you try out a custom function and it works well, I would be happy if you could share that function with us. If many users agree with that function, we might consider incorporating it into Doma.

from doma.

yamashita-ki avatar yamashita-ki commented on June 3, 2024

Thank you for your response and for considering my feature request.

Could you tell me which RDBMS you are using and what kind of SQL you would like to execute?

I am currently using Oracle.
Here's an example of the kind of SQL I would like to execute:

SELECT * FROM users
WHERE REGEXP_LIKE ( users.name, '[[=t=]][[=a=]][[=r=]][[=o=]]')

from doma.

yamashita-ki avatar yamashita-ki commented on June 3, 2024

@nakamura-to
Thank you for your response, despite it being a day off.

Is there any plan to include a custom function named @insensitive in the next update? I understand it might be challenging given the need to accommodate different RDBMS.

from doma.

yamashita-ki avatar yamashita-ki commented on June 3, 2024

Understood.
Since this issue has been resolved, I will go ahead and close it.
Thank you very much for your assistance.

from doma.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.