Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit b236ad0

Browse files
committed
common: apply "goimports -w" on the Go source files
This automatically formats Go files with the standard Go format.
1 parent 4362f60 commit b236ad0

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

common/diff.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ type DataDiff struct {
2929
}
3030

3131
type DiffObjectChangeset struct {
32-
ObjectName string `json:"object_name"`
33-
ObjectType string `json:"object_type"`
34-
Schema SchemaDiff `json:"schema"`
35-
Data []DataDiff `json:"data"`
32+
ObjectName string `json:"object_name"`
33+
ObjectType string `json:"object_type"`
34+
Schema SchemaDiff `json:"schema"`
35+
Data []DataDiff `json:"data"`
3636
}
3737

3838
type Diffs struct {
39-
Diff []DiffObjectChangeset `json:"diff"`
39+
Diff []DiffObjectChangeset `json:"diff"`
4040
// TODO Add PRAGMAs here
4141
}
4242

@@ -111,9 +111,9 @@ func dbDiff(dbA string, dbB string) (Diffs, error) {
111111
// Get list of all objects in both databases, excluding virtual tables because they tend to be unpredictable
112112
var stmt *sqlite.Stmt
113113
stmt, err = sdb.Prepare("SELECT name, type FROM main.sqlite_master WHERE name NOT LIKE 'sqlite_%' AND (type != 'table' OR (type = 'table' AND sql NOT LIKE 'CREATE VIRTUAL%%'))\n" +
114-
" UNION\n" +
115-
"SELECT name, type FROM aux.sqlite_master WHERE name NOT LIKE 'sqlite_%' AND (type != 'table' OR (type = 'table' AND sql NOT LIKE 'CREATE VIRTUAL%%'))\n" +
116-
" ORDER BY name")
114+
" UNION\n" +
115+
"SELECT name, type FROM aux.sqlite_master WHERE name NOT LIKE 'sqlite_%' AND (type != 'table' OR (type = 'table' AND sql NOT LIKE 'CREATE VIRTUAL%%'))\n" +
116+
" ORDER BY name")
117117
if err != nil {
118118
log.Printf("Error when preparing statement for object list in dbDiff(): %s\n", err)
119119
return Diffs{}, err
@@ -153,18 +153,18 @@ func diffSingleObject(sdb *sqlite.Conn, objectName string, objectType string) (b
153153
// Check for object's existence in both databases
154154
var sqlInMain, sqlInAux string
155155
err := sdb.OneValue("SELECT sql FROM main.sqlite_master WHERE name = ? AND type = ?", &sqlInMain, objectName, objectType)
156-
if err != nil && err != io.EOF { // io.EOF is okay. It is returned when the object does not exist in the main database
156+
if err != nil && err != io.EOF { // io.EOF is okay. It is returned when the object does not exist in the main database
157157
return false, DiffObjectChangeset{}, err
158158
}
159159
err = sdb.OneValue("SELECT sql FROM aux.sqlite_master WHERE name = ? AND type = ?", &sqlInAux, objectName, objectType)
160-
if err != nil && err != io.EOF { // io.EOF is okay. It is returned when the object does not exist in the aux database
160+
if err != nil && err != io.EOF { // io.EOF is okay. It is returned when the object does not exist in the aux database
161161
return false, DiffObjectChangeset{}, err
162162
}
163163

164164
// Check for dropped object
165165
if sqlInMain != "" && sqlInAux == "" {
166166
diff.Schema.ActionType = ACTION_DELETE
167-
diff.Schema.Sql = "DROP " + strings.ToUpper(objectType) + " " + EscapeId(objectName) + ";"
167+
diff.Schema.Sql = "DROP " + strings.ToUpper(objectType) + " " + EscapeId(objectName) + ";"
168168

169169
// If this is a table, also add all the deleted data to the diff
170170
if objectType == "table" {
@@ -176,7 +176,7 @@ func diffSingleObject(sdb *sqlite.Conn, objectName string, objectType string) (b
176176
}
177177

178178
// No further changes for dropped objects. So we can return here
179-
return true, diff, nil
179+
return true, diff, nil
180180
}
181181

182182
// Check for added object
@@ -199,7 +199,7 @@ func diffSingleObject(sdb *sqlite.Conn, objectName string, objectType string) (b
199199
// Check for modified object
200200
if sqlInMain != "" && sqlInAux != "" && sqlInMain != sqlInAux {
201201
diff.Schema.ActionType = ACTION_MODIFY
202-
diff.Schema.Sql = "DROP " + strings.ToUpper(objectType) + " " + EscapeId(objectName) + ";" + sqlInAux + ";"
202+
diff.Schema.Sql = "DROP " + strings.ToUpper(objectType) + " " + EscapeId(objectName) + ";" + sqlInAux + ";"
203203

204204
// TODO If this is a table, be more clever and try to get away with ALTER TABLE instead of DROP and CREATE
205205

@@ -279,7 +279,7 @@ func dataDiffForAllTableRows(sdb *sqlite.Conn, schemaName string, tableName stri
279279
// If we want to include a SQL statement for deleting data and this is still
280280
// part of the primary key, add this to the prepared DELETE statement
281281
if includeSql && action == ACTION_DELETE && i < len(pk) {
282-
d.Sql += pk_escaped[i];
282+
d.Sql += pk_escaped[i]
283283
if row[i].Type == Null {
284284
d.Sql += " IS NULL"
285285
} else {

0 commit comments

Comments
 (0)