fun generateExposedTablePrimaryKey()

in exposed-gradle-plugin/plugin-build/exposed-code-generator/src/main/kotlin/org/jetbrains/exposed/gradle/builders/TableBuilder.kt [98:112]


    fun generateExposedTablePrimaryKey() {
        if (tableInfo.primaryKeyColumns.isEmpty() || tableInfo.superclass in listOf(IntIdTable::class, LongIdTable::class, UUIDTable::class)) {
            return
        }

        val primaryKeys = tableInfo.primaryKeyColumns.map {
            data.columnToPropertySpec[it]?.name
                    ?: throw ReferencedColumnNotFoundException("Primary key column ${it.fullName} not found.")
        }
        val primaryKey =
                PropertySpec.builder("primaryKey", ClassName("", "PrimaryKey"), KModifier.OVERRIDE)
                        .initializer(CodeBlock.of("%M(${primaryKeys.joinToString(", ")})", MemberName("", "PrimaryKey")))
                        .build()
        builder.addProperty(primaryKey)
    }