Skip to content

Commit

Permalink
revert & allow convertion from actual type to alias
Browse files Browse the repository at this point in the history
  • Loading branch information
aljazerzen committed Mar 1, 2024
1 parent 96b2c1e commit 7e839d3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
12 changes: 10 additions & 2 deletions edb/schema/expraliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,16 @@ def _create_begin(

# generated types might conflict with existing types
if other_obj := schema.get(alias_name, default=None):
vn = other_obj.get_verbosename(schema, with_parent=True)
raise errors.SchemaError(f'{vn} already exists')
# special case:
# conversion from an actual type into an alias is allowed
allowed = (
isinstance(other_obj, s_types.Type) and
not other_obj.get_from_alias(schema)
)

if not allowed:
vn = other_obj.get_verbosename(schema, with_parent=True)
raise errors.SchemaError(f'{vn} already exists')

type_cmd, type_shell, expr, created_types = self._handle_alias_op(
expr=self.get_attribute_value('expr'),
Expand Down
5 changes: 1 addition & 4 deletions edb/schema/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,7 @@ class Type(
# schema without revealing weird internals.
from_alias = so.SchemaField(
bool,
default=False,
# cannot alter type from being produced by an alias into an actual type
compcoef=0.0
)
default=False, compcoef=1.0)

# True when from a global. The purpose of this is to ensure that
# the types from globals and aliases can't be migrated between
Expand Down

0 comments on commit 7e839d3

Please sign in to comment.