Feature request?

2012-05-24
2012-09-29
  • Leo Amigood

    Leo Amigood - 2012-05-24

    Thank you for a great product!

    Now, is there a chance to be able to inject (use) my own class extending
    Coverter , instead of hardcoded:
    in com.healthmarketscience.sqlbuilder.UpdateQuery

    public UpdateQuery addCustomSetClause(Object column, Object value)
    {
    _sets.addObject(new SetClauseObject(
    Converter.toCustomColumnSqlObject(column),
    Converter.toColumnSqlObject(value)));
    return this;
    }

     
  • James Ahlborn

    James Ahlborn - 2012-05-25

    Most of the Converters leave objects alone if they are already of the correct
    final type (generally instanceof SqlObject). therefore, if the objects you
    pass are already SqlObject instances, they will be left alone. that is why
    most of the methods take Objects, to allow you to easily pass your own custom
    implementations.

     
  • James Ahlborn

    James Ahlborn - 2012-05-25

    I see from the feature request, you found the SqlObject.QUESTION_MARK helper.
    as i said in my previous comment, any SqlObject will generally be passed
    through untouched. the intent of the Converters is to make the common cases
    simple, but allow for almost any customization.

    as a very simple example of customization, pretty much any method which takes
    an Object will pass through something like 'new SqlObject("some custom
    text")'. you can put whatever you want in the custom string and it will be
    passed through to the query.

    SqlBuilder also has many helpers for common situations. you already found the
    question mark SqlObject. as a more advanced way to insert question marks, you
    should check out the QueryPreparer.

     

Log in to post a comment.