Skip to content

Commit 89ba68c

Browse files
committed
chore: rename "condition" field to "cond" to make it work on all databases and unbreak integration tests.
I tried to use double quotes but it doesn't work on MySQL by default. We can activate it by setting sql_mode to ANSI_QUOTES but I decided to give up on adding more workaround and just rename the fields. See for details: - https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sqlmode_ansi_quotes - https://stackoverflow.com/questions/11321491/when-to-use-single-quotes-double-quotes-and-backticks-in-mysql - https://stackoverflow.com/questions/58727070/how-to-dynamic-setting-sql-mode-for-mysql-in-springboot-program Revert 74734a8 commit. Correction for 28eab06 commit. Relate to #1326
1 parent 87df2df commit 89ba68c

File tree

5 files changed

+52
-3
lines changed

5 files changed

+52
-3
lines changed

src/main/java/ru/mystamps/web/feature/series/RowMappers.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private RowMappers() {
100100
Currency secondCurrency = JdbcUtils.getCurrency(rs, "second_currency");
101101

102102
// LATER: consider extracting this into a helper method
103-
String conditionField = rs.getString("condition");
103+
String conditionField = rs.getString("cond");
104104
SeriesCondition condition = rs.wasNull() ? null : SeriesCondition.valueOf(conditionField);
105105

106106
return new PurchaseAndSaleDto(

src/main/resources/liquibase/version/0.4.4.xml

+1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
<include file="0.4.4/2020-05-02--hidden_series_images.xml" relativeToChangelogFile="true" />
99
<include file="0.4.4/2020-05-04--series_sale_condition.xml" relativeToChangelogFile="true" />
1010
<include file="0.4.4/2020-05-04--collections_series_condition.xml" relativeToChangelogFile="true" />
11+
<include file="0.4.4/2020-05-23--modify_condition_field.xml" relativeToChangelogFile="true" />
1112

1213
</databaseChangeLog>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<databaseChangeLog
3+
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
6+
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
7+
8+
<changeSet id="modify-collections_series-condition-field" author="php-coder" context="scheme">
9+
10+
<renameColumn
11+
tableName="collections_series"
12+
oldColumnName="condition"
13+
newColumnName="cond"
14+
columnDataType="VARCHAR(4)" />
15+
16+
<modifyDataType
17+
tableName="collections_series"
18+
columnName="cond"
19+
newDataType="VARCHAR(9)" />
20+
21+
<setColumnRemarks
22+
tableName="collections_series"
23+
columnName="cond"
24+
remarks="Example: MNH, CANCELLED" />
25+
26+
</changeSet>
27+
28+
<changeSet id="modify-series_sales-condition-field" author="php-coder" context="scheme">
29+
30+
<renameColumn
31+
tableName="series_sales"
32+
oldColumnName="condition"
33+
newColumnName="cond"
34+
columnDataType="VARCHAR(4)" />
35+
36+
<modifyDataType
37+
tableName="series_sales"
38+
columnName="cond"
39+
newDataType="VARCHAR(9)" />
40+
41+
<setColumnRemarks
42+
tableName="series_sales"
43+
columnName="cond"
44+
remarks="Example: MNH, CANCELLED" />
45+
46+
</changeSet>
47+
48+
</databaseChangeLog>

src/main/resources/sql/series_dao_queries.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ series.find_purchases_and_sales_by_series_id = \
183183
, first_currency \
184184
, second_price \
185185
, second_currency \
186-
, "condition" \
186+
, cond \
187187
FROM series_sales ss \
188188
JOIN transaction_participants seller \
189189
ON seller.id = ss.seller_id \

src/main/resources/sql/series_sales_dao_queries.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ INSERT \
1010
, second_price \
1111
, second_currency \
1212
, buyer_id \
13-
, "condition" \
13+
, cond \
1414
, created_at \
1515
, created_by \
1616
) \

0 commit comments

Comments
 (0)