Skip to content

Commit

Permalink
Renamed tags.repo_id to tags.repo, closes #44
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Jul 18, 2020
1 parent 05238b1 commit 7b84390
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
8 changes: 4 additions & 4 deletions github_to_sqlite/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,14 +468,14 @@ def save_contributors(db, contributors, repo_id):
def save_tags(db, tags, repo_id):
if not db["tags"].exists():
db["tags"].create(
{"repo_id": int, "name": str, "sha": str,},
pk=("repo_id", "name"),
foreign_keys=[("repo_id", "repos", "id")],
{"repo": int, "name": str, "sha": str,},
pk=("repo", "name"),
foreign_keys=[("repo", "repos", "id")],
)

db["tags"].insert_all(
(
{"repo_id": repo_id, "name": tag["name"], "sha": tag["commit"]["sha"],}
{"repo": repo_id, "name": tag["name"], "sha": tag["commit"]["sha"],}
for tag in tags
),
replace=True,
Expand Down
8 changes: 3 additions & 5 deletions tests/test_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,20 @@ def db(tags, repo):
def test_tables(db):
assert {"users", "tags", "licenses", "repos"} == set(db.table_names())
assert {
ForeignKey(
table="tags", column="repo_id", other_table="repos", other_column="id"
)
ForeignKey(table="tags", column="repo", other_table="repos", other_column="id")
} == set(db["tags"].foreign_keys)


def test_tags(db):
tags_rows = list(db["tags"].rows)
assert [
{
"repo_id": 207052882,
"repo": 207052882,
"name": "2.3",
"sha": "7090e43d804724ef3b31ae5ca9efd6ac05f76cbc",
},
{
"repo_id": 207052882,
"repo": 207052882,
"name": "2.2",
"sha": "4fe69783b55465e7692a807d3a02a710f69c9c42",
},
Expand Down

0 comments on commit 7b84390

Please sign in to comment.