Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mitm-tooling
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Machine Data
mitm-tooling
Commits
7cb81eb3
Commit
7cb81eb3
authored
3 weeks ago
by
Leah Tacke genannt Unterberg
Browse files
Options
Downloads
Patches
Plain Diff
allow skipping of fk generation in sql_representation.py
parent
595951a9
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mitm_tooling/representation/sql_representation.py
+7
-6
7 additions, 6 deletions
mitm_tooling/representation/sql_representation.py
with
7 additions
and
6 deletions
mitm_tooling/representation/sql_representation.py
+
7
−
6
View file @
7cb81eb3
...
...
@@ -237,7 +237,8 @@ _view_generators: tuple[MitMDBViewsGenerator, ...] = (_gen_denormalized_views,)
def
mk_sql_rep_schema
(
header
:
Header
,
view_generators
:
Iterable
[
MitMDBViewsGenerator
]
|
None
=
(
_gen_denormalized_views
,),
override_schema
:
SchemaName
|
None
=
None
)
->
SQLRepresentationSchema
:
override_schema
:
SchemaName
|
None
=
None
,
skip_fk_constraints
:
bool
=
False
)
->
SQLRepresentationSchema
:
schema_name
=
override_schema
if
override_schema
else
SQL_REPRESENTATION_DEFAULT_SCHEMA
mitm_def
=
get_mitm_def
(
header
.
mitm
)
meta
=
sa
.
MetaData
(
schema
=
schema_name
)
...
...
@@ -246,6 +247,7 @@ def mk_sql_rep_schema(header: Header,
type_tables
:
ConceptTypeTablesDict
=
{}
views
:
dict
[
str
,
sa
.
Table
]
=
{}
base_schema_item_generators
=
(
_gen_unique_constraint
,
_gen_pk_constraint
,
_gen_index
,)
for
concept
in
mitm_def
.
main_concepts
:
concept_properties
,
concept_relations
=
mitm_def
.
get
(
concept
)
...
...
@@ -264,10 +266,11 @@ def mk_sql_rep_schema(header: Header,
'
foreign
'
:
lambda
:
[(
name
,
sa
.
Column
(
name
,
dt
.
sa_sql_type
))
for
_
,
resolved_fk
in
mitm_def
.
resolve_foreign_types
(
concept
).
items
()
for
name
,
dt
in
resolved_fk
.
items
()]
},
additional_column_generators
=
(
_gen_within_concept_id_col
,),
schema_item_generators
=
(
_gen_unique_constraint
,
_gen_pk_constraint
,
_gen_index
,),
override_schema
=
schema_name
)
},
additional_column_generators
=
(
_gen_within_concept_id_col
,),
schema_item_generators
=
base_schema_item_generators
,
override_schema
=
schema_name
)
concept_tables
[
concept
]
=
t
type_table_schema_item_generators
=
base_schema_item_generators
+
(
_gen_foreign_key_constraints
,)
if
not
skip_fk_constraints
else
base_schema_item_generators
for
he
in
header
.
header_entries
:
he_concept
=
he
.
concept
if
has_type_tables
(
header
.
mitm
,
he_concept
):
...
...
@@ -291,9 +294,7 @@ def mk_sql_rep_schema(header: Header,
'
attributes
'
:
lambda
:
[(
name
,
sa
.
Column
(
name
,
dt
.
sa_sql_type
))
for
name
,
dt
in
zip
(
he
.
attributes
,
he
.
attribute_dtypes
)],
},
additional_column_generators
=
(
_gen_within_concept_id_col
,),
schema_item_generators
=
(
_gen_unique_constraint
,
_gen_pk_constraint
,
_gen_index
,
_gen_foreign_key_constraints
),
schema_item_generators
=
type_table_schema_item_generators
,
override_schema
=
schema_name
)
if
he_concept
not
in
type_tables
:
...
...
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