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

Generated table for enumeration column type #1598

Open
SchweinchenFuntik opened this issue Sep 17, 2022 · 4 comments
Open

Generated table for enumeration column type #1598

SchweinchenFuntik opened this issue Sep 17, 2022 · 4 comments

Comments

@SchweinchenFuntik
Copy link
Contributor

SchweinchenFuntik commented Sep 17, 2022

Generate dictionary table for Enum.

Motivation: for the correctness of the scheme, especially useful for other systems that will also work with the database

enum class AccountType { DEBIT, CREDIT }

object Accounts : Table() {
    val type = enumeration("type", AccountType::class)
}

We get in the database:

CREATE TABLE ACCOUNT_TYPE(ID INT, NAME VARCHAR);

ALTER TABLE ACCOUNT ADD CONSTRAINT FX_ACCOUNT_ACCOUNT_TYPE_ID FOREIGN KEY (TYPE) REFERENCES ACCOUNT_TYPE(ID);

INSERT INTO ACCOUNT_TYPE(ID, NAME) VALUES (1, 'DEBIT');
INSERT INTO ACCOUNT_TYPE(ID, NAME) VALUES (2, 'CREDIT');

make optional

@SchweinchenFuntik
Copy link
Contributor Author

it is possible to add a similar function to SchemeUtils, who needs to call

@SchweinchenFuntik
Copy link
Contributor Author

add a special annotation @GenerateEnumTable (tentative name), which will tell SchemeUtils to generate or update the table data for this enum.

@Tapac
Copy link
Contributor

Tapac commented Nov 14, 2022

Should it be resolved/linked with columns by id/enum ordinal or by enum value?

@SchweinchenFuntik
Copy link
Contributor Author

It is hard to say. I think to use ordinal, but still give the user the opportunity to specify the values from the enum class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants