diff --git a/api/comment_approve.go b/api/comment_approve.go index 31c2641..4920779 100644 --- a/api/comment_approve.go +++ b/api/comment_approve.go @@ -11,7 +11,7 @@ func commentApprove(commentHex string) error { statement := ` UPDATE comments - SET state = 'approved' + SET state = 'approved' WHERE commentHex = $1; ` diff --git a/api/comment_domain_path_get.go b/api/comment_domain_path_get.go index 3f06d27..4c395fb 100644 --- a/api/comment_domain_path_get.go +++ b/api/comment_domain_path_get.go @@ -8,7 +8,7 @@ func commentDomainPathGet(commentHex string) (string, string, error) { } statement := ` - SELECT domain, path + SELECT domain, path FROM comments WHERE commentHex = $1; ` diff --git a/api/comment_new_test.go b/api/comment_new_test.go index 16b1293..1e061d7 100644 --- a/api/comment_new_test.go +++ b/api/comment_new_test.go @@ -39,10 +39,10 @@ func TestCommentNewUpvoted(t *testing.T) { commentHex, _ := commentNew("temp-commenter-hex", "example.com", "/path.html", "root", "**foo**", "approved", time.Now().UTC()) statement := ` - SELECT score - FROM comments - WHERE commentHex = $1; - ` + SELECT score + FROM comments + WHERE commentHex = $1; + ` row := db.QueryRow(statement, commentHex) var score int diff --git a/api/commenter_session_update.go b/api/commenter_session_update.go index f480d46..1d149cb 100644 --- a/api/commenter_session_update.go +++ b/api/commenter_session_update.go @@ -8,10 +8,10 @@ func commenterSessionUpdate(commenterToken string, commenterHex string) error { } statement := ` - UPDATE commenterSessions - SET commenterHex = $2 - WHERE commenterToken = $1; - ` + UPDATE commenterSessions + SET commenterHex = $2 + WHERE commenterToken = $1; + ` _, err := db.Exec(statement, commenterToken, commenterHex) if err != nil { logger.Errorf("error updating commenterHex: %v", err) diff --git a/api/database_connect.go b/api/database_connect.go index 69d8a4d..f2441d0 100644 --- a/api/database_connect.go +++ b/api/database_connect.go @@ -32,10 +32,10 @@ func dbConnect(retriesLeft int) error { } statement := ` - CREATE TABLE IF NOT EXISTS migrations ( - filename TEXT NOT NULL UNIQUE - ); - ` + CREATE TABLE IF NOT EXISTS migrations ( + filename TEXT NOT NULL UNIQUE + ); + ` _, err = db.Exec(statement) if err != nil { logger.Errorf("cannot create migrations table: %v", err) diff --git a/api/database_migrate.go b/api/database_migrate.go index c76f70b..d1b1593 100644 --- a/api/database_migrate.go +++ b/api/database_migrate.go @@ -22,9 +22,9 @@ func migrateFromDir(dir string) error { } statement := ` - SELECT filename - FROM migrations; - ` + SELECT filename + FROM migrations; + ` rows, err := db.Query(statement) if err != nil { logger.Errorf("cannot query migrations: %v", err) @@ -63,10 +63,10 @@ func migrateFromDir(dir string) error { } statement = ` - INSERT INTO - migrations (filename) - VALUES ($1 ); - ` + INSERT INTO + migrations (filename) + VALUES ($1 ); + ` _, err = db.Exec(statement, file.Name()) if err != nil { logger.Errorf("cannot insert filename into the migrations table: %v", err) diff --git a/api/owner_confirm_hex_test.go b/api/owner_confirm_hex_test.go index ed926e9..00b477e 100644 --- a/api/owner_confirm_hex_test.go +++ b/api/owner_confirm_hex_test.go @@ -11,9 +11,9 @@ func TestOwnerConfirmHexBasics(t *testing.T) { ownerHex, _ := ownerNew("test@example.com", "Test", "hunter2") statement := ` - UPDATE owners - SET confirmedEmail=false; - ` + UPDATE owners + SET confirmedEmail=false; + ` _, err := db.Exec(statement) if err != nil { t.Errorf("unexpected error when setting confirmedEmail=false: %v", err) @@ -23,10 +23,10 @@ func TestOwnerConfirmHexBasics(t *testing.T) { confirmHex, _ := randomHex(32) statement = ` - INSERT INTO - ownerConfirmHexes (confirmHex, ownerHex, sendDate) - VALUES ($1, $2, $3 ); - ` + INSERT INTO + ownerConfirmHexes (confirmHex, ownerHex, sendDate) + VALUES ($1, $2, $3 ); + ` _, err = db.Exec(statement, confirmHex, ownerHex, time.Now().UTC()) if err != nil { t.Errorf("unexpected error creating inserting confirmHex: %v\n", err) @@ -39,10 +39,10 @@ func TestOwnerConfirmHexBasics(t *testing.T) { } statement = ` - SELECT confirmedEmail - FROM owners - WHERE ownerHex=$1; - ` + SELECT confirmedEmail + FROM owners + WHERE ownerHex=$1; + ` row := db.QueryRow(statement, ownerHex) var confirmedHex bool diff --git a/api/owner_get.go b/api/owner_get.go index 5a30965..cec5732 100644 --- a/api/owner_get.go +++ b/api/owner_get.go @@ -8,10 +8,10 @@ func ownerGetByEmail(email string) (owner, error) { } statement := ` - SELECT ownerHex, email, name, confirmedEmail, joinDate - FROM owners - WHERE email=$1; - ` + SELECT ownerHex, email, name, confirmedEmail, joinDate + FROM owners + WHERE email=$1; + ` row := db.QueryRow(statement, email) var o owner @@ -29,7 +29,7 @@ func ownerGetByOwnerToken(ownerToken string) (owner, error) { } statement := ` - SELECT ownerHex, email, name, confirmedEmail, joinDate + SELECT ownerHex, email, name, confirmedEmail, joinDate FROM owners WHERE ownerHex IN ( SELECT ownerHex FROM ownerSessions @@ -53,7 +53,7 @@ func ownerGetByOwnerHex(ownerHex string) (owner, error) { } statement := ` - SELECT ownerHex, email, name, confirmedEmail, joinDate + SELECT ownerHex, email, name, confirmedEmail, joinDate FROM owners WHERE ownerHex = $1; ` diff --git a/api/owner_new.go b/api/owner_new.go index 874e67f..82c417d 100644 --- a/api/owner_new.go +++ b/api/owner_new.go @@ -56,10 +56,10 @@ func ownerNew(email string, name string, password string) (string, error) { } statement = ` - INSERT INTO - ownerConfirmHexes (confirmHex, ownerHex, sendDate) - VALUES ($1, $2, $3 ); - ` + INSERT INTO + ownerConfirmHexes (confirmHex, ownerHex, sendDate) + VALUES ($1, $2, $3 ); + ` _, err = db.Exec(statement, confirmHex, ownerHex, time.Now().UTC()) if err != nil { logger.Errorf("cannot insert confirmHex: %v\n", err) diff --git a/api/testing.go b/api/testing.go index 6dc94a3..96c0ecf 100644 --- a/api/testing.go +++ b/api/testing.go @@ -15,10 +15,10 @@ func failTestOnError(t *testing.T, err error) { func getPublicTables() ([]string, error) { statement := ` - SELECT tablename - FROM pg_tables - WHERE schemaname='public'; - ` + SELECT tablename + FROM pg_tables + WHERE schemaname='public'; + ` rows, err := db.Query(statement) if err != nil { fmt.Fprintf(os.Stderr, "cannot query public tables: %v", err)