|
| 1 | +/* |
| 2 | + * Copyright 2020 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 | + * https://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.springframework.data.r2dbc.repository.query; |
| 17 | + |
| 18 | +import static org.assertj.core.api.Assertions.*; |
| 19 | + |
| 20 | +import org.junit.Test; |
| 21 | + |
| 22 | +/** |
| 23 | + * Unit tests for {@link ExpressionQuery}. |
| 24 | + * |
| 25 | + * @author Mark Paluch |
| 26 | + */ |
| 27 | +public class ExpressionQueryUnitTests { |
| 28 | + |
| 29 | + @Test // gh-373 |
| 30 | + public void bindsMultipleSpelParametersCorrectly() { |
| 31 | + |
| 32 | + ExpressionQuery query = ExpressionQuery |
| 33 | + .create("INSERT IGNORE INTO table (x, y) VALUES (:#{#point.x}, :#{#point.y})"); |
| 34 | + |
| 35 | + assertThat(query.getQuery()) |
| 36 | + .isEqualTo("INSERT IGNORE INTO table (x, y) VALUES (:__synthetic_0__, :__synthetic_1__)"); |
| 37 | + |
| 38 | + assertThat(query.getBindings()).hasSize(2); |
| 39 | + assertThat(query.getBindings().get(0).getExpression()).isEqualTo("#point.x"); |
| 40 | + assertThat(query.getBindings().get(0).getParameterName()).isEqualTo("__synthetic_0__"); |
| 41 | + assertThat(query.getBindings().get(1).getExpression()).isEqualTo("#point.y"); |
| 42 | + assertThat(query.getBindings().get(1).getParameterName()).isEqualTo("__synthetic_1__"); |
| 43 | + } |
| 44 | +} |
0 commit comments