api: sql statements: replace spaces with tabs

This commit is contained in:
Adhityaa Chandrasekar 2019-12-27 17:31:27 -08:00
parent e7a5e01379
commit d6e7507b2c
10 changed files with 46 additions and 46 deletions

View File

@ -11,7 +11,7 @@ func commentApprove(commentHex string) error {
statement := ` statement := `
UPDATE comments UPDATE comments
SET state = 'approved' SET state = 'approved'
WHERE commentHex = $1; WHERE commentHex = $1;
` `

View File

@ -8,7 +8,7 @@ func commentDomainPathGet(commentHex string) (string, string, error) {
} }
statement := ` statement := `
SELECT domain, path SELECT domain, path
FROM comments FROM comments
WHERE commentHex = $1; WHERE commentHex = $1;
` `

View File

@ -39,10 +39,10 @@ func TestCommentNewUpvoted(t *testing.T) {
commentHex, _ := commentNew("temp-commenter-hex", "example.com", "/path.html", "root", "**foo**", "approved", time.Now().UTC()) commentHex, _ := commentNew("temp-commenter-hex", "example.com", "/path.html", "root", "**foo**", "approved", time.Now().UTC())
statement := ` statement := `
SELECT score SELECT score
FROM comments FROM comments
WHERE commentHex = $1; WHERE commentHex = $1;
` `
row := db.QueryRow(statement, commentHex) row := db.QueryRow(statement, commentHex)
var score int var score int

View File

@ -8,10 +8,10 @@ func commenterSessionUpdate(commenterToken string, commenterHex string) error {
} }
statement := ` statement := `
UPDATE commenterSessions UPDATE commenterSessions
SET commenterHex = $2 SET commenterHex = $2
WHERE commenterToken = $1; WHERE commenterToken = $1;
` `
_, err := db.Exec(statement, commenterToken, commenterHex) _, err := db.Exec(statement, commenterToken, commenterHex)
if err != nil { if err != nil {
logger.Errorf("error updating commenterHex: %v", err) logger.Errorf("error updating commenterHex: %v", err)

View File

@ -32,10 +32,10 @@ func dbConnect(retriesLeft int) error {
} }
statement := ` statement := `
CREATE TABLE IF NOT EXISTS migrations ( CREATE TABLE IF NOT EXISTS migrations (
filename TEXT NOT NULL UNIQUE filename TEXT NOT NULL UNIQUE
); );
` `
_, err = db.Exec(statement) _, err = db.Exec(statement)
if err != nil { if err != nil {
logger.Errorf("cannot create migrations table: %v", err) logger.Errorf("cannot create migrations table: %v", err)

View File

@ -22,9 +22,9 @@ func migrateFromDir(dir string) error {
} }
statement := ` statement := `
SELECT filename SELECT filename
FROM migrations; FROM migrations;
` `
rows, err := db.Query(statement) rows, err := db.Query(statement)
if err != nil { if err != nil {
logger.Errorf("cannot query migrations: %v", err) logger.Errorf("cannot query migrations: %v", err)
@ -63,10 +63,10 @@ func migrateFromDir(dir string) error {
} }
statement = ` statement = `
INSERT INTO INSERT INTO
migrations (filename) migrations (filename)
VALUES ($1 ); VALUES ($1 );
` `
_, err = db.Exec(statement, file.Name()) _, err = db.Exec(statement, file.Name())
if err != nil { if err != nil {
logger.Errorf("cannot insert filename into the migrations table: %v", err) logger.Errorf("cannot insert filename into the migrations table: %v", err)

View File

@ -11,9 +11,9 @@ func TestOwnerConfirmHexBasics(t *testing.T) {
ownerHex, _ := ownerNew("test@example.com", "Test", "hunter2") ownerHex, _ := ownerNew("test@example.com", "Test", "hunter2")
statement := ` statement := `
UPDATE owners UPDATE owners
SET confirmedEmail=false; SET confirmedEmail=false;
` `
_, err := db.Exec(statement) _, err := db.Exec(statement)
if err != nil { if err != nil {
t.Errorf("unexpected error when setting confirmedEmail=false: %v", err) t.Errorf("unexpected error when setting confirmedEmail=false: %v", err)
@ -23,10 +23,10 @@ func TestOwnerConfirmHexBasics(t *testing.T) {
confirmHex, _ := randomHex(32) confirmHex, _ := randomHex(32)
statement = ` statement = `
INSERT INTO INSERT INTO
ownerConfirmHexes (confirmHex, ownerHex, sendDate) ownerConfirmHexes (confirmHex, ownerHex, sendDate)
VALUES ($1, $2, $3 ); VALUES ($1, $2, $3 );
` `
_, err = db.Exec(statement, confirmHex, ownerHex, time.Now().UTC()) _, err = db.Exec(statement, confirmHex, ownerHex, time.Now().UTC())
if err != nil { if err != nil {
t.Errorf("unexpected error creating inserting confirmHex: %v\n", err) t.Errorf("unexpected error creating inserting confirmHex: %v\n", err)
@ -39,10 +39,10 @@ func TestOwnerConfirmHexBasics(t *testing.T) {
} }
statement = ` statement = `
SELECT confirmedEmail SELECT confirmedEmail
FROM owners FROM owners
WHERE ownerHex=$1; WHERE ownerHex=$1;
` `
row := db.QueryRow(statement, ownerHex) row := db.QueryRow(statement, ownerHex)
var confirmedHex bool var confirmedHex bool

View File

@ -8,10 +8,10 @@ func ownerGetByEmail(email string) (owner, error) {
} }
statement := ` statement := `
SELECT ownerHex, email, name, confirmedEmail, joinDate SELECT ownerHex, email, name, confirmedEmail, joinDate
FROM owners FROM owners
WHERE email=$1; WHERE email=$1;
` `
row := db.QueryRow(statement, email) row := db.QueryRow(statement, email)
var o owner var o owner
@ -29,7 +29,7 @@ func ownerGetByOwnerToken(ownerToken string) (owner, error) {
} }
statement := ` statement := `
SELECT ownerHex, email, name, confirmedEmail, joinDate SELECT ownerHex, email, name, confirmedEmail, joinDate
FROM owners FROM owners
WHERE ownerHex IN ( WHERE ownerHex IN (
SELECT ownerHex FROM ownerSessions SELECT ownerHex FROM ownerSessions
@ -53,7 +53,7 @@ func ownerGetByOwnerHex(ownerHex string) (owner, error) {
} }
statement := ` statement := `
SELECT ownerHex, email, name, confirmedEmail, joinDate SELECT ownerHex, email, name, confirmedEmail, joinDate
FROM owners FROM owners
WHERE ownerHex = $1; WHERE ownerHex = $1;
` `

View File

@ -56,10 +56,10 @@ func ownerNew(email string, name string, password string) (string, error) {
} }
statement = ` statement = `
INSERT INTO INSERT INTO
ownerConfirmHexes (confirmHex, ownerHex, sendDate) ownerConfirmHexes (confirmHex, ownerHex, sendDate)
VALUES ($1, $2, $3 ); VALUES ($1, $2, $3 );
` `
_, err = db.Exec(statement, confirmHex, ownerHex, time.Now().UTC()) _, err = db.Exec(statement, confirmHex, ownerHex, time.Now().UTC())
if err != nil { if err != nil {
logger.Errorf("cannot insert confirmHex: %v\n", err) logger.Errorf("cannot insert confirmHex: %v\n", err)

View File

@ -15,10 +15,10 @@ func failTestOnError(t *testing.T, err error) {
func getPublicTables() ([]string, error) { func getPublicTables() ([]string, error) {
statement := ` statement := `
SELECT tablename SELECT tablename
FROM pg_tables FROM pg_tables
WHERE schemaname='public'; WHERE schemaname='public';
` `
rows, err := db.Query(statement) rows, err := db.Query(statement)
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, "cannot query public tables: %v", err) fmt.Fprintf(os.Stderr, "cannot query public tables: %v", err)