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

Add a DataType.identity() flag to specify that a data type is meant to be used as a SERIAL / IDENTITY type #5709

Closed
lukaseder opened this issue Dec 16, 2016 · 1 comment

Comments

@lukaseder
Copy link
Member

lukaseder commented Dec 16, 2016

This is a prerequisite for #5062.

Currently, the only place where a Table's IDENTITY flag is stored is the Table itself, and the Identity reference contains a reference to the Field.

This doesn't reflect well what we do in DDL statements, when we specify for a column to be an Identity column. We do that as a type modifier, similar to NOT NULL (which is a type constraint directly placed on the type, at least syntactically).

In order to be able to implement #5062, it would be great if we could say something like:

create().createTable("t")
        .column(field(name("t", "i"), Integer.class), SQLDataType.INTEGER.identity(true))
        .column("n", DECIMAL(3, 1).nullable(true))
        .column(field(name("s"), VARCHAR(5).nullable(false)))
        .execute();

Some databases support additional sequence flags, including START WITH or STEP. We'll always generate the default values for those databases, as most databases don't support these flags.

@lukaseder
Copy link
Member Author

lukaseder commented Dec 16, 2016

Setting the identity flag should unset the defaultValue() and the nullable() flag and vice versa

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

No branches or pull requests

1 participant