Skip to content

Commit b803f8a

Browse files
committed
Changes in SQLiteColumnQueryBuilder, JavaDoc
1 parent 36aa6e0 commit b803f8a

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

core/src/main/java/me/zort/sqllib/model/column/SQLColumnQueryBuilder.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,25 @@
44

55
import java.util.List;
66

7+
/**
8+
* This interface is used to build queries for column actions that are
9+
* used while synchronizing models.
10+
*
11+
* @author ZorTik
12+
*/
713
public interface SQLColumnQueryBuilder {
814

15+
/**
16+
* This method should return queries that result in modifying the 'to' column
17+
* to the 'from'. In simple terms, 'to' should be changed to 'from' definition
18+
* using the returned queries.
19+
*
20+
* @param action The column action
21+
* @param table Table name
22+
* @param from The new column definition
23+
* @param to The old column definition
24+
* @return List of SQL queries
25+
*/
926
List<String> buildActionQuery(ColumnAction action, String table, ColumnDefinition from, ColumnDefinition to);
1027

1128
enum ColumnAction {

core/src/main/java/me/zort/sqllib/model/column/SQLiteColumnQueryBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ public class SQLiteColumnQueryBuilder extends InnoColumnQueryBuilder {
1313
private final SQLiteDatabaseConnection connection;
1414
@Override
1515
public List<String> buildActionQuery(ColumnAction action, String table, ColumnDefinition from, ColumnDefinition to) {
16-
if (action.equals(ColumnAction.MODIFY)) {
16+
if (action.equals(ColumnAction.MODIFY) || action.equals(ColumnAction.RENAME)) {
1717
TableSchema schema = connection.getSchemaBuilder(table).buildTableSchema();
1818
String[] newDefinitions = new String[schema.size()];
1919
for (int i = 0; i < schema.size(); i++) {
20-
if (schema.getDefinitionName(i).equals(from.getName())) {
20+
if (schema.getDefinitionName(i).equals(to.getName())) {
2121
newDefinitions[i] = from.getName() + " " + from.getType();
2222
} else {
2323
newDefinitions[i] = schema.getDefinition(i);

0 commit comments

Comments
 (0)