Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
fix(backend): fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
burdiyan committed Nov 28, 2023
1 parent ee6bfd8 commit 1732e9f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 83 deletions.
81 changes: 0 additions & 81 deletions backend/daemon/storage/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package storage
import (
"context"
"fmt"
"log"
"testing"

"crawshaw.io/sqlite"
Expand Down Expand Up @@ -76,83 +75,3 @@ func introspectSchema(t *testing.T, conn *sqlite.Conn) {
})
require.NoError(t, err)
}

func introspectSchema2(t *testing.T, conn *sqlite.Conn) {
// This code was written with the help of ChatGPT,
// so it's not the most optimal thing in the world.

stmt := conn.Prep("SELECT name FROM sqlite_master WHERE type = 'table';")

for {
hasRow, err := stmt.Step()
if err != nil {
log.Fatal(err)
}
if !hasRow {
require.NoError(t, stmt.Finalize())
break
}

tableName := stmt.ColumnText(0)

foreignKeysStmt := conn.Prep(fmt.Sprintf("PRAGMA foreign_key_list(%s);", tableName))

for {
hasRow, err := foreignKeysStmt.Step()
if err != nil {
log.Fatal(err)
}
if !hasRow {
require.NoError(t, foreignKeysStmt.Finalize())
break
}

from := foreignKeysStmt.ColumnText(3)

indexesStmt := conn.Prep(fmt.Sprintf("PRAGMA index_list(%s);", tableName))

var found bool
for {
hasRow, err := indexesStmt.Step()
if err != nil {
log.Fatal(err)
}
if !hasRow {
require.NoError(t, indexesStmt.Finalize())
break
}

indexName := indexesStmt.ColumnText(1)

// We are only interested in the first column in case of a compound index.
indexColumnsStmt := conn.Prep(fmt.Sprintf("SELECT * FROM pragma_index_info('%s') WHERE seqno = 0;", indexName))

for {
hasRow, err := indexColumnsStmt.Step()
if err != nil {
log.Fatal(err)
}
if !hasRow {
require.NoError(t, indexColumnsStmt.Finalize())
break
}

columnName := indexColumnsStmt.ColumnText(2)
if columnName == from {
found = true
require.NoError(t, indexColumnsStmt.Finalize())
break
}
}
if found {
require.NoError(t, indexesStmt.Finalize())
break
}
}

if !found {
t.Errorf("Table %q foreign key on column %q is not covered by any index", tableName, from)
}
}
}
}
4 changes: 2 additions & 2 deletions backend/hyper/terra.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ func (kd KeyDelegation) Blob() Blob {
return hb
}

// Change for a Mintter mutable Entity.

// Actions for entity changes.
const (
ActionCreate = "Create"
ActionUpdate = "Update"
)

// Change for a Mintter mutable Entity.
type Change struct {
// Type is always the same (see constants).
Type BlobType `refmt:"@type"`
Expand Down

0 comments on commit 1732e9f

Please sign in to comment.