Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-model
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nicolas Dandrimont
swh-model
Commits
05b89f26
Commit
05b89f26
authored
5 years ago
by
vlorentz
Browse files
Options
Downloads
Patches
Plain Diff
Make content length mandatory.
The current postgresql model refuses NULL values.
parent
8ebbd216
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
swh/model/hypothesis_strategies.py
+1
-1
1 addition, 1 deletion
swh/model/hypothesis_strategies.py
swh/model/model.py
+3
-3
3 additions, 3 deletions
swh/model/model.py
with
4 additions
and
4 deletions
swh/model/hypothesis_strategies.py
+
1
−
1
View file @
05b89f26
...
...
@@ -153,7 +153,7 @@ def skipped_contents(draw):
return
draw
(
builds
(
SkippedContent
,
length
=
optional
(
integers
(
min_value
=
0
,
max_value
=
2
**
63
-
1
)
)
,
length
=
integers
(
min_value
=
-
1
,
max_value
=
2
**
63
-
1
),
sha1
=
optional
(
sha1
()),
sha1_git
=
optional
(
sha1_git
()),
sha256
=
optional
(
binary
(
min_size
=
32
,
max_size
=
32
)),
...
...
This diff is collapsed.
Click to expand it.
swh/model/model.py
+
3
−
3
View file @
05b89f26
...
...
@@ -406,7 +406,7 @@ class Content(BaseContent):
@length.validator
def
check_length
(
self
,
attribute
,
value
):
"""
Checks the length is positive.
"""
if
self
.
status
!=
'
absent
'
and
value
<
0
:
if
value
<
0
:
raise
ValueError
(
'
Length must be positive.
'
)
def
to_dict
(
self
):
...
...
@@ -427,7 +427,7 @@ class SkippedContent(BaseContent):
sha256
=
attr
.
ib
(
type
=
Optional
[
bytes
])
blake2s256
=
attr
.
ib
(
type
=
Optional
[
bytes
])
length
=
attr
.
ib
(
type
=
Optional
[
int
]
)
length
=
attr
.
ib
(
type
=
int
)
status
=
attr
.
ib
(
type
=
str
,
...
...
@@ -451,7 +451,7 @@ class SkippedContent(BaseContent):
@length.validator
def
check_length
(
self
,
attribute
,
value
):
"""
Checks the length is positive or -1.
"""
if
value
is
not
None
and
value
<
-
1
:
if
value
<
-
1
:
raise
ValueError
(
'
Length must be positive or -1.
'
)
def
to_dict
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment