Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved Enum support #154

Open
amorenoz opened this issue Jun 10, 2021 · 4 comments
Open

Improved Enum support #154

amorenoz opened this issue Jun 10, 2021 · 4 comments
Labels

Comments

@amorenoz
Copy link
Collaborator

Currently strong enum typing is not supported. #147 added type alias (e.g: type Alias = string) but, as discussed in that PR, that does not really enforce strong typing limitations.
For that to work we would need to to modify the ovsdb.bindings and mapper layers to cope with named-types.

Once core functionality is added, apart from nice enum validation, we can change replace the type alias with named-types in the generator and should be transparent to clients

@amorenoz amorenoz changed the title Add proper Enum support Add strong Enum support Jun 10, 2021
@dave-tucker dave-tucker changed the title Add strong Enum support Improved Enum support Jul 12, 2021
@dave-tucker
Copy link
Collaborator

In addition, we should also adjust generation for Enum Sets so:

  • In cases where min = 0 && max = 1 we should use a pointer to an Enum Type
  • In cases where min = 1 && max = 1 we should use the Enum Type directly (note: I'm not sure if that will give us any compile time safety to ensure the value is not nil)

@amorenoz
Copy link
Collaborator Author

amorenoz commented Jul 13, 2021

* In cases where `min = 0 && max = 1` we should use a pointer to an Enum Type

Maybe that idea can be applied to all sub-types (i.e: not only Enum)?
Lots of other columns also use this "pattern". e.g:


    "Logical_Router": {
      "columns": {
        "enabled": {
          "type": {
            "key": "boolean",
            "min": 0
          }
        },
...

In cases where min = 1 && max = 1 we should use the Enum Type directly (note: I'm not sure if that will give us any compile time safety to ensure the value is not nil)

I'd say this is already de behavior, isn't it?

@dave-tucker
Copy link
Collaborator

dave-tucker commented Jul 13, 2021 via email

@amorenoz
Copy link
Collaborator Author

#191

dave-tucker added a commit to dave-tucker/libovsdb that referenced this issue Jul 14, 2021
This commit:
1. Adjusts the mapper to handle stronger enum types
2. Adjusts modelgen to produce these types

Fixes: ovn-org#154

Signed-off-by: Dave Tucker <[email protected]>
dave-tucker added a commit to dave-tucker/libovsdb that referenced this issue Jul 15, 2021
This commit:
1. Adjusts the mapper to handle stronger enum types
2. Adjusts modelgen to produce these types

Fixes: ovn-org#154

Signed-off-by: Dave Tucker <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants