|
| 1 | +/** |
| 2 | + * Copyright 2016-2018 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package org.mybatis.dynamic.sql.where; |
| 17 | + |
| 18 | +import static org.assertj.core.api.Assertions.assertThat; |
| 19 | +import static org.mybatis.dynamic.sql.SqlBuilder.*; |
| 20 | + |
| 21 | +import java.sql.JDBCType; |
| 22 | + |
| 23 | +import org.junit.jupiter.api.Test; |
| 24 | +import org.junit.platform.runner.JUnitPlatform; |
| 25 | +import org.junit.runner.RunWith; |
| 26 | +import org.mybatis.dynamic.sql.SqlColumn; |
| 27 | +import org.mybatis.dynamic.sql.SqlTable; |
| 28 | +import org.mybatis.dynamic.sql.render.RenderingStrategy; |
| 29 | +import org.mybatis.dynamic.sql.where.render.WhereClauseProvider; |
| 30 | + |
| 31 | +@RunWith(JUnitPlatform.class) |
| 32 | +public class WhereModelTest { |
| 33 | + |
| 34 | + @Test |
| 35 | + public void testThatParameterNameCarriesToSubCriteria() { |
| 36 | + SqlTable table = SqlTable.of("foo"); |
| 37 | + SqlColumn<Integer> id = table.column("id", JDBCType.INTEGER); |
| 38 | + |
| 39 | + WhereClauseProvider wc = where(id, isEqualTo(3), or(id, isEqualTo(4))) |
| 40 | + .build() |
| 41 | + .render(RenderingStrategy.MYBATIS3, "myName"); |
| 42 | + |
| 43 | + assertThat(wc.getWhereClause()).isEqualTo("where (id = #{myName.parameters.p1,jdbcType=INTEGER} or id = #{myName.parameters.p2,jdbcType=INTEGER})"); |
| 44 | + } |
| 45 | +} |
0 commit comments