Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: populate version in assets_versions for 1st entry #221

Merged
merged 1 commit into from
Apr 4, 2023

Conversation

Chief-Rishab
Copy link
Member

@Chief-Rishab Chief-Rishab commented Apr 3, 2023

  • Set version to 0.1 while inserting the first version of asset into
    assets_versions table.
  • Update all rows in assets_versions to have 0.1 as the version if the
    column was not populated.

Closes: #215

@coveralls
Copy link

coveralls commented Apr 3, 2023

Pull Request Test Coverage Report for Build 4593350100

Warning: This coverage report may be inaccurate.

We've detected an issue with your CI configuration that might affect the accuracy of this pull request's coverage report.
To ensure accuracy in future PRs, please see these guidelines.
A quick fix for this PR: rebase it; your next report should be accurate.

  • 8 of 12 (66.67%) changed or added relevant lines in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.003%) to 84.143%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/store/postgres/asset_repository.go 8 12 66.67%
Files with Coverage Reduction New Missed Lines %
internal/store/postgres/asset_repository.go 1 76.66%
Totals Coverage Status
Change from base Build 4560380896: 0.003%
Covered Lines: 5476
Relevant Lines: 6508

💛 - Coveralls

@@ -0,0 +1 @@
UPDATE assets_versions SET version = '0.1' WHERE version = '';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of modifying the db for it, can we handle it in go? Like if no version, assume 0.1?

Copy link
Member Author

@Chief-Rishab Chief-Rishab Apr 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How will we query the database for an asset's first version? Currently we're unable to do so.

Copy link
Member Author

@Chief-Rishab Chief-Rishab Apr 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, instead of running migrations for version 0.1, I can add an extra case to query depending on the version number 0.1 like this:

+      if version == "0.1" {
+      ast, err := r.getByVersion(ctx, id, version, r.GetByID, sq.And{
+      sq.Eq{"a.urn": urn},
+      sq.IsNull{"a.version"},
+      } 
+       else{
	ast, err := r.getByVersion(ctx, id, version, r.GetByID, sq.Eq{
		"a.asset_id": id,
		"a.version":  version,
	})
+	}

Should we proceed with this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay make sense, then I think it's better we put the db migration call.

@kushsharma kushsharma self-requested a review April 4, 2023 13:32
@kushsharma kushsharma merged commit 17e4c76 into main Apr 4, 2023
@kushsharma kushsharma deleted the fix-version-0.1 branch April 4, 2023 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Getting asset's first version return no record for the asset error
3 participants