Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
Querybuilder
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
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
pydisk
Querybuilder
Commits
47eb7183
Commit
47eb7183
authored
1 year ago
by
Bruno Guillon
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' into features/helpers
parents
46988c56
4d940d36
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#999835
failed
1 year ago
Stage: build
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitlab-ci.yml
+1
-0
1 addition, 0 deletions
.gitlab-ci.yml
querybuilder/helpers/schema.py
+19
-17
19 additions, 17 deletions
querybuilder/helpers/schema.py
with
20 additions
and
17 deletions
.gitlab-ci.yml
+
1
−
0
View file @
47eb7183
...
@@ -32,6 +32,7 @@ type-checking:
...
@@ -32,6 +32,7 @@ type-checking:
-
medium
-
medium
image
:
"
$CI_REGISTRY_IMAGE/qbcontainer"
image
:
"
$CI_REGISTRY_IMAGE/qbcontainer"
script
:
script
:
-
find -name '__pycache__' -type d -exec rm {} +
-
python3 -m mypy --install-types --non-interactive querybuilder/
-
python3 -m mypy --install-types --non-interactive querybuilder/
test
:
test
:
...
...
This diff is collapsed.
Click to expand it.
querybuilder/helpers/schema.py
+
19
−
17
View file @
47eb7183
...
@@ -320,25 +320,26 @@ class Field:
...
@@ -320,25 +320,26 @@ class Field:
def
to_named_column
(
def
to_named_column
(
self
:
NamedColumn
|
ColumnSpec
,
self
:
NamedColumn
|
ColumnSpec
,
relation_name
:
Optional
[
str
]
=
None
,
relation_name
:
str
|
None
|
_MISSING_TYPE
=
MISSING
,
schema_name
:
Optional
[
str
]
=
None
,
schema_name
:
str
|
None
|
_MISSING_TYPE
=
MISSING
,
)
->
NamedColumn
:
)
->
NamedColumn
:
assert
self
.
name
assert
self
.
name
assert
self
.
sqltype
assert
self
.
sqltype
assert
(
if
relation_name
is
MISSING
:
not
self
.
relation_name
relation_name
=
self
.
relation_name
or
not
relation_name
elif
relation_name
is
None
:
or
self
.
relation_name
==
relation_name
schema_name
=
None
)
relation_name
=
cast
(
Optional
[
str
],
relation_name
)
assert
(
if
schema_name
is
MISSING
:
not
self
.
schema_name
or
not
schema_name
or
self
.
schema_name
==
schema_name
schema_name
=
self
.
schema_name
)
schema_name
=
cast
(
Optional
[
str
],
schema_name
)
return
NamedColumn
(
if
relation_name
:
self
.
sqltype
,
assert
not
self
.
relation_name
or
self
.
relation_name
==
relation_name
self
.
name
,
if
schema_name
:
self
.
relation_name
or
relation_name
,
assert
relation_name
self
.
schema_name
or
schema_name
,
assert
not
self
.
schema_name
or
self
.
schema_name
==
schema_name
)
return
NamedColumn
(
self
.
sqltype
,
self
.
name
,
relation_name
,
schema_name
)
@classmethod
@classmethod
def
_resolve_str_spec
(
def
_resolve_str_spec
(
...
@@ -506,7 +507,7 @@ class Field:
...
@@ -506,7 +507,7 @@ class Field:
)
->
Optional
[
qb
.
atoms
.
constraints
.
ColumnCheck
]:
)
->
Optional
[
qb
.
atoms
.
constraints
.
ColumnCheck
]:
check
:
Optional
[
str
|
Column
|
qb
.
atoms
.
constraints
.
ColumnCheck
|
tuple
|
dict
]
check
:
Optional
[
str
|
Column
|
qb
.
atoms
.
constraints
.
ColumnCheck
|
tuple
|
dict
]
if
callable
(
self
.
check
):
if
callable
(
self
.
check
):
check
=
self
.
check
(
self
.
to_named_column
(
),
relation
)
check
=
self
.
check
(
self
.
to_named_column
(
relation
_name
=
None
),
rel
)
else
:
else
:
check
=
self
.
check
check
=
self
.
check
if
check
is
None
:
if
check
is
None
:
...
@@ -540,6 +541,7 @@ class Field:
...
@@ -540,6 +541,7 @@ class Field:
qb
.
atoms
.
constraints
.
ColumnDefault
,
qb
.
atoms
.
constraints
.
ColumnDefault
,
]
]
if
callable
(
self
.
default
):
if
callable
(
self
.
default
):
# TODO: when is a callable default useful?
default
=
self
.
default
(
self
.
to_named_column
())
default
=
self
.
default
(
self
.
to_named_column
())
else
:
else
:
default
=
self
.
default
default
=
self
.
default
...
...
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