Skip to content

Commit 926707a

Browse files
authored
Merge pull request #163 from jfontan/fix/source-in-schema
Set Source in table schemas
2 parents 953f0f4 + bda6a78 commit 926707a

12 files changed

+54
-24
lines changed

blobs.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ func (blobsTable) Name() string {
2424

2525
func (blobsTable) Schema() sql.Schema {
2626
return sql.Schema{
27-
{Name: "hash", Type: sql.Text, Nullable: false},
28-
{Name: "size", Type: sql.Int64, Nullable: false},
27+
{Name: "hash", Type: sql.Text, Nullable: false, Source: blobsTableName},
28+
{Name: "size", Type: sql.Int64, Nullable: false, Source: blobsTableName},
2929
}
3030
}
3131

blobs_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ func TestBlobsTable_Name(t *testing.T) {
1616
f := fixtures.Basic().One()
1717
table := getTable(require, f, blobsTableName)
1818
require.Equal(blobsTableName, table.Name())
19+
20+
// Check that each column source is the same as table name
21+
for _, c := range table.Schema() {
22+
require.Equal(blobsTableName, c.Source)
23+
}
1924
}
2025

2126
func TestBlobsTable_Children(t *testing.T) {

commits.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ func (commitsTable) Name() string {
2424

2525
func (commitsTable) Schema() sql.Schema {
2626
return sql.Schema{
27-
{Name: "hash", Type: sql.Text, Nullable: false},
28-
{Name: "author_name", Type: sql.Text, Nullable: false},
29-
{Name: "author_email", Type: sql.Text, Nullable: false},
30-
{Name: "author_when", Type: sql.Timestamp, Nullable: false},
31-
{Name: "committer_name", Type: sql.Text, Nullable: false},
32-
{Name: "committer_email", Type: sql.Text, Nullable: false},
33-
{Name: "committer_when", Type: sql.Timestamp, Nullable: false},
34-
{Name: "message", Type: sql.Text, Nullable: false},
27+
{Name: "hash", Type: sql.Text, Nullable: false, Source: commitsTableName},
28+
{Name: "author_name", Type: sql.Text, Nullable: false, Source: commitsTableName},
29+
{Name: "author_email", Type: sql.Text, Nullable: false, Source: commitsTableName},
30+
{Name: "author_when", Type: sql.Timestamp, Nullable: false, Source: commitsTableName},
31+
{Name: "committer_name", Type: sql.Text, Nullable: false, Source: commitsTableName},
32+
{Name: "committer_email", Type: sql.Text, Nullable: false, Source: commitsTableName},
33+
{Name: "committer_when", Type: sql.Timestamp, Nullable: false, Source: commitsTableName},
34+
{Name: "message", Type: sql.Text, Nullable: false, Source: commitsTableName},
3535
}
3636
}
3737

commits_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ func TestCommitsTable_Name(t *testing.T) {
1616
f := fixtures.Basic().One()
1717
table := getTable(require, f, commitsTableName)
1818
require.Equal(commitsTableName, table.Name())
19+
20+
// Check that each column source is the same as table name
21+
for _, c := range table.Schema() {
22+
require.Equal(commitsTableName, c.Source)
23+
}
1924
}
2025

2126
func TestCommitsTable_Children(t *testing.T) {

references.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ func (referencesTable) Name() string {
2525

2626
func (referencesTable) Schema() sql.Schema {
2727
return sql.Schema{
28-
{Name: "repository_id", Type: sql.Text, Nullable: false},
29-
{Name: "name", Type: sql.Text, Nullable: false},
30-
{Name: "hash", Type: sql.Text, Nullable: false},
28+
{Name: "repository_id", Type: sql.Text, Nullable: false, Source: referencesTableName},
29+
{Name: "name", Type: sql.Text, Nullable: false, Source: referencesTableName},
30+
{Name: "hash", Type: sql.Text, Nullable: false, Source: referencesTableName},
3131
}
3232
}
3333

references_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ func TestReferencesTable_Name(t *testing.T) {
1818
f := fixtures.Basic().One()
1919
table := getTable(require, f, referencesTableName)
2020
require.Equal(referencesTableName, table.Name())
21+
22+
// Check that each column source is the same as table name
23+
for _, c := range table.Schema() {
24+
require.Equal(referencesTableName, c.Source)
25+
}
2126
}
2227

2328
func TestReferencesTable_Children(t *testing.T) {

remotes.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ func (remotesTable) Name() string {
2626

2727
func (remotesTable) Schema() sql.Schema {
2828
return sql.Schema{
29-
{Name: "repository_id", Type: sql.Text, Nullable: false},
30-
{Name: "name", Type: sql.Text, Nullable: false},
31-
{Name: "push_url", Type: sql.Text, Nullable: false},
32-
{Name: "fetch_url", Type: sql.Text, Nullable: false},
33-
{Name: "push_refspec", Type: sql.Text, Nullable: false},
34-
{Name: "fetch_refspec", Type: sql.Text, Nullable: false},
29+
{Name: "repository_id", Type: sql.Text, Nullable: false, Source: remotesTableName},
30+
{Name: "name", Type: sql.Text, Nullable: false, Source: remotesTableName},
31+
{Name: "push_url", Type: sql.Text, Nullable: false, Source: remotesTableName},
32+
{Name: "fetch_url", Type: sql.Text, Nullable: false, Source: remotesTableName},
33+
{Name: "push_refspec", Type: sql.Text, Nullable: false, Source: remotesTableName},
34+
{Name: "fetch_refspec", Type: sql.Text, Nullable: false, Source: remotesTableName},
3535
}
3636
}
3737

remotes_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ func TestRemotesTable_Name(t *testing.T) {
1818
f := fixtures.Basic().One()
1919
table := getTable(require, f, remotesTableName)
2020
require.Equal(remotesTableName, table.Name())
21+
22+
// Check that each column source is the same as table name
23+
for _, c := range table.Schema() {
24+
require.Equal(remotesTableName, c.Source)
25+
}
2126
}
2227

2328
func TestRemotesTable_Children(t *testing.T) {

repositories.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func (repositoriesTable) Name() string {
2424

2525
func (repositoriesTable) Schema() sql.Schema {
2626
return sql.Schema{
27-
{Name: "id", Type: sql.Text, Nullable: false},
27+
{Name: "id", Type: sql.Text, Nullable: false, Source: repositoriesTableName},
2828
}
2929
}
3030

repositories_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ func TestRepositoriesTable_Name(t *testing.T) {
1515
f := fixtures.Basic().One()
1616
table := getTable(require, f, repositoriesTableName)
1717
require.Equal(repositoriesTableName, table.Name())
18+
19+
// Check that each column source is the same as table name
20+
for _, c := range table.Schema() {
21+
require.Equal(repositoriesTableName, c.Source)
22+
}
1823
}
1924

2025
func TestRepositoriesTable_Children(t *testing.T) {

0 commit comments

Comments
 (0)