JetBrains / JetBrains/Exposed

Support seqName in IdTable

Open
#2,438 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
9.3k
Forks
798
Avg merge
4d 2h
Merged PRs (30d)
26

Description

I am using the oracle Table Sequence and declaring IdTable to use BatchUpdateStatement. To use BatchUpdateStatement, a table declared with IdTable is required.

```kotlin
ex) object TestTable: IntIdTable(
) {

}

BatchUpdateStatement(TestTable).xxx
```

**Threr are two questions.**

**Question 1. I cannot input sequenceName in IdTable. Therefore, I am using it as shown below. Is it okay to use it this way?**

```kotlin
// The existing source
open class IntIdTable(name: String = "", columnName: String = "id") : IdTable(name) {
/** The identity column of this [IntIdTable], for storing 4-byte integers wrapped as [EntityID] instances. */
final override val id: Column> = integer(columnName).autoIncrement().entityId()
final override val primaryKey = PrimaryKey(id)
}

// The source I developed (idSeqName has been added to the source)
open class IntIdTableWithAutoIncrementSequence(name: String = "", columnName: String = "id", idSeqName: String? = null) : IdTable(name) {
/** The identity column of this [IntIdTableWithAutoIncrementSequence], for storing 4-byte integers wrapped as [EntityID] instances. */
final override val id: Column> = integer(columnName).autoIncrement(idSeqName).entityId()
final override val primaryKey = PrimaryKey(id)
}
```

**Question 2. Is it okay to propose a PR for the following content? (idSeqName has been added to the source)**
```kotlin
// The existing source
open class LongIdTable(name: String = "", columnName: String = "id") : IdTable(name) {
/** The identity column of this [LongIdTable], for storing 8-byte integers wrapped as [EntityID] instances. */
final override val id: Column> = long(columnName).autoIncrement().entityId()
final override val primaryKey = PrimaryKey(id)
}

open class IntIdTable(name: String = "", columnName: String = "id") : IdTable(name) {
/** The identity column of this [IntIdTable], for storing 4-byte integers wrapped as [EntityID] instances. */
final override val id: Column> = integer(columnName).autoIncrement().entityId()
final override val primaryKey = PrimaryKey(id)
}

// The source I developed (idSeqName has been added to the source)
open class LongIdTable(name: String = "", columnName: String = "id", idSeqName: String? = null) : IdTable(name) {
/** The identity column of this [LongIdTable], for storing 8-byte integers wrapped as [EntityID] instances. */
final override val id: Column> = long(columnName).autoIncrement(idSeqName).entityId()
final override val primaryKey = PrimaryKey(id)
}

open class IntIdTable(name: String = "", columnName: String = "id", idSeqName: String? = null) : IdTable(name) {
/** The identity column of this [IntIdTable], for storing 4-byte integers wrapped as [EntityID] instances. */
final override val id: Column> = integer(columnName).autoIncrement(idSeqName).entityId()
final override val primaryKey = PrimaryKey(id)
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.