Skip to content

Commit

Permalink
Merge pull request #68 from opengisch/oid_madness
Browse files Browse the repository at this point in the history
Provide OID domains per layers
  • Loading branch information
signedav authored Nov 8, 2023
2 parents 10f800a + c6dc752 commit dc192f5
Show file tree
Hide file tree
Showing 4 changed files with 818 additions and 1 deletion.
14 changes: 14 additions & 0 deletions modelbaker/dataobjects/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,20 @@ def real_id(self):
else:
return None

@property
def oid_domain(self):
t_ili_tid_field = self.t_ili_tid_field
if t_ili_tid_field:
return t_ili_tid_field.oid_domain
return None

@property
def t_ili_tid_field(self):
for field in self.fields:
if field.name.lower() == "t_ili_tid":
return field
return None

def isPureLinkTable(self, project):
"""
Returns True if the layer is a pure link table in a n:m relation.
Expand Down
3 changes: 2 additions & 1 deletion modelbaker/generator/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,8 @@ def layers(self, filter_layer_list=[]):
# when there is a t_ili_tid it should be filled up when there is no OID defined in the model
if "oid_domain" not in fielddef or fielddef["oid_domain"] is None:
field.default_value_expression = "substr(uuid(), 2, 36)"

else:
field.oid_domain = fielddef["oid_domain"]
if "enum_domain" in fielddef and fielddef["enum_domain"]:
field.enum_domain = fielddef["enum_domain"]

Expand Down
Loading

0 comments on commit dc192f5

Please sign in to comment.