Can't add a new batch because columns: don't have default values. DB defaults don't support in batch inserts
See original GitHub issueHello,
when I try to insert something in a many to many table with an extra column, it just throws the exception above. I am using MySQL.
My tables look like this:
object ManyToManys : UUIDTable("many_to_manys") {
val table1 = reference("table1", Tables1)
val table2 = reference("table2", Tables2)
val position = integer("position")
override val primaryKey = PrimaryKey(table1, position)
}
class ManyToMany(id: EntityID<UUID>) : UUIDEntity(id) {
companion object : EntityClass<UUID, ManyToMany>(ManyToManys)
var table1 by Table1 referencedOn ManyToManys.table1
var table2 by Table2 referencedOn ManyToManys.table2
var position by ManyToManys.position
}
(I am using this disgusting UUID hack since Exposed does not support many to many tables with extra columns)
when I try to insert via
ManyToMany.new {
this.table1 = myTable1
this.table2 = myTable2
this.position = myPos
}
it crashes with org.jetbrains.exposed.sql.statements.BatchDataInconsistentException: Can't add a new batch because columns: many_to_manys.`position` don't have default values. DB defaults don't support in batch inserts
eventhough I have supplied a position.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Kotlin Exposed batch insert not working as documented
I am trying to batch insert records into an SQL table using Kotlin Exposed. I have set up the code as per the...
Read more >Keep nulls or default values during bulk import - SQL Server
* For BULK INSERT, if default values are not available, the table column must be defined to allow null values.
Read more >Table updates not working with default values when used in ...
Hi, first post here so be gentle! I've had an issue where we use Oracle to update a bunch of records using batch...
Read more >Problems with adding NOT NULL columns or making nullable ...
This can happen when you try to add a new column that can't accept NULL values, or to change an existing, nullable column...
Read more >How to add a column with a default value to an existing table ...
How to: To SQL add a column with a default value is a simple operation in SQL. ... INSERT INTO student(student_id, student_name, major,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Had the same Problem because a column was not specified as
nullable
e.g.description
Added a project using
Project.new
in my service without setting a value fordescription
:Changed
description
to nullable withval description = varchar("description", 255).nullable()
. That resolved my problem.@gringofe , @stalexxx , please share a reproducible sample project on GitHub and I’ll debug it.