-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Allow to specify a default value on placeholder #852
Comments
For prototype see 241ba45. In this changes, I does not take to consider backward compatibility yet. |
I've updated the prototype via cbc6fe0. In this version, backward compatibility has been taken to consider. By default this feature is disabled . <properties>
<property name="org.apache.ibatis.parsing.PropertyParser.enable-default-value" value="true"/>
</properties> |
I like the feature @kazuki43zoo +1 |
Thanks for your reaction !! I will submit a PR after adding some improvements. |
I've improved the prototype via 0f057c2. In this change, support to customize a separator characters. <properties>
<property name="org.apache.ibatis.parsing.PropertyParser.enable-default-value" value="true"/>
<property name="org.apache.ibatis.parsing.PropertyParser.default-value-separator" value="?:"/> <!-- ### Adding ### -->
</properties> If <dataSource type="POOLED">
<property name="username" value="${db:username?:postgres}"/>
<property name="password" value="${db:password?:Postgres}"/>
</dataSource> and If ternary operator has been used using OGNL in your sql already, this mechanism is effective as follow: @Select("SELECT * FROM ${db:schema?:prod}.${tableName == null ? 'global_constants' : tableName}" ORDER BY ${orderByColumns})
List<SysConstant> findAll(@Param("tableName") String tableName, @Param("orderByColumns") String orderByColumns); Note that : A default value can not specify to the parameter replacement variable (above example: |
Looks like a handy feature. Thank you :) |
Hi guys, I've fixed via gh-853. If my fix has problems, please reopen this issue. |
I want to support that allow to specify a default value on properties placeholder as follow:
This solution has been supported by the Spring Framework , Logback, etc...
Note that : We should take to consider the
:
character has been used as placeholder key or used ternary operator(such ascondition ? value_if_true : value_if_false
) using OGNL. (for backward compatibility)What do you think this enhancement ?
The text was updated successfully, but these errors were encountered: