Browse files

implement LIKE

  • Loading branch information...
1 parent 19594a9 commit a5faa2849b8d9bd7f6e6d0eceb452bf6f152fdbb @kazuho committed Jul 9, 2014
Showing with 4 additions and 1 deletion.
  1. +1 −1 net/examp1e/picoorm/types/AbstractType.java
  2. +3 −0 net/examp1e/picoorm/types/StringType.java
View
2 net/examp1e/picoorm/types/AbstractType.java
@@ -76,7 +76,7 @@ public ThisType init(TableDefinition<Row> tableDefinition, String fieldName) {
public Condition<Row> between(ValueType x, ValueType y) {
return new Condition<Row>(this.tableDefinition, this.fieldName + " BETWEEN ? AND ?", createParameter(x), createParameter(y));
}
- private Condition<Row> _buildBinaryOp(String op, ValueType value) {
+ protected Condition<Row> _buildBinaryOp(String op, ValueType value) {
return new Condition<Row>(this.tableDefinition, this.fieldName + op + "?", createParameter(value));
}
protected abstract Parameter<ValueType> createParameter(ValueType x);
View
3 net/examp1e/picoorm/types/StringType.java
@@ -24,6 +24,9 @@ public void bind(PreparedStatement ps, int parameterIndex, String value) throws
}
public static class Predicate<Row extends AbstractRow> extends AbstractType.Predicate<Predicate<Row>, Row, String> {
+ public Condition<Row> like(String x) {
+ return _buildBinaryOp(" LIKE ", x);
+ }
@Override
protected Parameter<String> createParameter(String value) {
return new Parameter<String>(value) {

0 comments on commit a5faa28

Please sign in to comment.