zt
06/17/2023, 11:41 PMException in thread "main" io.r2dbc.spi.R2dbcBadGrammarException: [42001] [42001] Syntax error in SQL statement "create table if not exists [*]user (id bigint not null, guild_id bigint not null, balance integer not null, exp float not null, constraint pk_user primary key(id))"; expected "identifier"; SQL statement:
create table if not exists user (id bigint not null, guild_id bigint not null, balance integer not null, exp float not null, constraint pk_user primary key(id)) [42001-214]
I'm not sure what im doing wrong though, everything looks correct to me:
val dbLocation = "./procyon.db"
val options = ConnectionFactoryOptions.builder()
.option(ConnectionFactoryOptions.DRIVER, "h2")
.option(ConnectionFactoryOptions.PROTOCOL, "file")
.option(ConnectionFactoryOptions.DATABASE, dbLocation)
.option(Option.valueOf("DB_CLOSE_DELAY"), "-1")
.build()
val db = R2dbcDatabase(options)
db.withTransaction {
db.runQuery(QueryDsl.create(Meta.guild, Meta.user))
}
@KomapperEntity
//@KomapperOneToMany(targetEntity = User::class)
data class Guild(
@KomapperId
val id: Long
)
@KomapperEntity
//@KomapperOneToMany(targetEntity = Guild::class)
data class User(
@KomapperId
val id: Long,
val balance: Int,
val exp: Float
)
Toshihiro Nakamura
06/18/2023, 12:51 AMuser
is a reserved word in your database.
Try @KomapperTable(alwaysQuote = true)
as follows:
@KomapperEntity
@KomapperTable(alwaysQuote = true)
data class User(...)