Skip to content

Commit c39be52

Browse files
committed
fix: Fix code formatting
Signed-off-by: Sun Yuhan <[email protected]>
1 parent f7ea0bd commit c39be52

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

memory/spring-ai-model-chat-memory-jdbc/src/main/java/org/springframework/ai/chat/memory/jdbc/JdbcChatMemoryRepository.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,22 +59,25 @@ public class JdbcChatMemoryRepository implements ChatMemoryRepository {
5959
private final JdbcTemplate jdbcTemplate;
6060

6161
public final static String DEFAULT_TABLE_NAME = "ai_chat_memory";
62+
6263
public final static String DEFAULT_CONVERSION_ID_FIELD_NAME = "conversation_id";
64+
6365
public final static String DEFAULT_CONTENT_FIELD_NAME = "content";
66+
6467
public final static String DEFAULT_TYPE_FIELD_NAME = "type";
68+
6569
public final static String DEFAULT_TIMESTAMP_FIELD_NAME = "\"timestamp\"";
6670

6771
public final static String DEFAULT_GET_IDS_QUERY = "SELECT DISTINCT %s FROM %s";
72+
6873
public final static String DEFAULT_ADD_QUERY = "INSERT INTO %s (%s, %s, %s, %s) VALUES (?, ?, ?, ?)";
74+
6975
public final static String DEFAULT_GET_QUERY = "SELECT %s, %s FROM %s WHERE %s = ? ORDER BY %s";
76+
7077
public final static String DEFAULT_CLEAR_QUERY = "DELETE FROM %s WHERE %s = ?";
7178

72-
private JdbcChatMemoryRepository(JdbcTemplate jdbcTemplate,
73-
String tableName,
74-
String conversionIdFiledName,
75-
String contentFiledName,
76-
String typeFiledName,
77-
String timestampFiledName) {
79+
private JdbcChatMemoryRepository(JdbcTemplate jdbcTemplate, String tableName, String conversionIdFiledName,
80+
String contentFiledName, String typeFiledName, String timestampFiledName) {
7881
Assert.notNull(jdbcTemplate, "jdbcTemplate cannot be null");
7982
Assert.notNull(tableName, "tableName cannot be null");
8083
Assert.notNull(conversionIdFiledName, "conversionIdFiledName cannot be null");
@@ -83,10 +86,10 @@ private JdbcChatMemoryRepository(JdbcTemplate jdbcTemplate,
8386
Assert.notNull(timestampFiledName, "timestampFiledName cannot be null");
8487
this.jdbcTemplate = jdbcTemplate;
8588
this.queryGetIds = DEFAULT_GET_IDS_QUERY.formatted(conversionIdFiledName, tableName);
86-
this.queryAdd = DEFAULT_ADD_QUERY.formatted(
87-
tableName, conversionIdFiledName, contentFiledName, typeFiledName, timestampFiledName);
88-
this.queryGet = DEFAULT_GET_QUERY.formatted(contentFiledName, typeFiledName,
89-
tableName, conversionIdFiledName, timestampFiledName);
89+
this.queryAdd = DEFAULT_ADD_QUERY.formatted(tableName, conversionIdFiledName, contentFiledName, typeFiledName,
90+
timestampFiledName);
91+
this.queryGet = DEFAULT_GET_QUERY.formatted(contentFiledName, typeFiledName, tableName, conversionIdFiledName,
92+
timestampFiledName);
9093
this.queryClear = DEFAULT_CLEAR_QUERY.formatted(tableName, conversionIdFiledName);
9194
}
9295

@@ -176,9 +179,13 @@ public static class Builder {
176179
private JdbcTemplate jdbcTemplate;
177180

178181
private String tableName = DEFAULT_TABLE_NAME;
182+
179183
private String conversionIdFiledName = DEFAULT_CONVERSION_ID_FIELD_NAME;
184+
180185
private String contentFiledName = DEFAULT_CONTENT_FIELD_NAME;
186+
181187
private String typeFiledName = DEFAULT_TYPE_FIELD_NAME;
188+
182189
private String timestampFiledName = DEFAULT_TIMESTAMP_FIELD_NAME;
183190

184191
private Builder() {

memory/spring-ai-model-chat-memory-jdbc/src/test/java/org/springframework/ai/chat/memory/jdbc/JdbcChatMemoryRepositoryPostgresqlIT.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,13 @@ static class TestConfiguration {
162162
@Bean
163163
ChatMemoryRepository chatMemoryRepository(JdbcTemplate jdbcTemplate) {
164164
return JdbcChatMemoryRepository.builder()
165-
.jdbcTemplate(jdbcTemplate)
166-
.tableName(DEFAULT_TABLE_NAME)
167-
.conversionIdFiledName(DEFAULT_CONVERSION_ID_FIELD_NAME)
168-
.contentFiledName(DEFAULT_CONTENT_FIELD_NAME)
169-
.typeFiledName(DEFAULT_TYPE_FIELD_NAME)
170-
.timestampFiledName(DEFAULT_TIMESTAMP_FIELD_NAME)
171-
.build();
165+
.jdbcTemplate(jdbcTemplate)
166+
.tableName(DEFAULT_TABLE_NAME)
167+
.conversionIdFiledName(DEFAULT_CONVERSION_ID_FIELD_NAME)
168+
.contentFiledName(DEFAULT_CONTENT_FIELD_NAME)
169+
.typeFiledName(DEFAULT_TYPE_FIELD_NAME)
170+
.timestampFiledName(DEFAULT_TIMESTAMP_FIELD_NAME)
171+
.build();
172172
}
173173

174174
}

0 commit comments

Comments
 (0)