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 := `
UPDATE comments
SET state = 'approved'
SET state = 'approved'
WHERE commentHex = $1;
`

View File

@ -8,7 +8,7 @@ func commentDomainPathGet(commentHex string) (string, string, error) {
}
statement := `
SELECT domain, path
SELECT domain, path
FROM comments
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())
statement := `
SELECT score
FROM comments
WHERE commentHex = $1;
`
SELECT score
FROM comments
WHERE commentHex = $1;
`
row := db.QueryRow(statement, commentHex)
var score int

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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;
`

View File

@ -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)

View File

@ -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)