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

HB not generate default value #810

Closed
SchweinchenFuntik opened this issue Feb 25, 2020 · 1 comment
Closed

HB not generate default value #810

SchweinchenFuntik opened this issue Feb 25, 2020 · 1 comment
Labels

Comments

@SchweinchenFuntik
Copy link
Contributor

Incorrectly generated
CODE:

object Lands : IntIdTable() {
    val number = integer("ID_NUMBER")
    val index = varchar("ID_INDEX", 5).default("")

    override val primaryKey = PrimaryKey(number, index)
}

SQL:

create table LANDS
(
	ID INT auto_increment,
	ID_NUMBER INT not null,
	ID_INDEX VARCHAR(5) not null, // must append: default ''
	constraint PK_LANDS
		primary key (ID_NUMBER, ID_INDEX),
);

Correctly generated
CODE:

object LandsTestPrimaryKey : Table() {
    val number = integer("ID_NUMBER")
    val index = varchar("ID_INDEX", 5).default("")
}

SQL:

create table LANDSTESTPRIMARYKEY
(
	ID_NUMBER INT not null,
	ID_INDEX VARCHAR(5) default '' not null,
	constraint LANDS_LANDSTESTPRIMARYKEY_ID_NUMBER_ID_INDEX_FX
		foreign key (ID_NUMBER, ID_INDEX) references LANDS (ID_NUMBER, ID_INDEX)
);

PS: I generate the foreign key myself, since it is a composite(#511)

@Tapac Tapac added the bug label Feb 26, 2020
Tapac added a commit that referenced this issue Feb 26, 2020
@Tapac
Copy link
Contributor

Tapac commented Feb 26, 2020

Fixed in master

@Tapac Tapac closed this as completed Feb 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants