question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't insert into MySQL table without auto index

See original GitHub issue

I’m trying to insert a simple row into a table:

                        transaction {
                            GuildPrefixTable.insert {
                                it[id]._value = event.guild.idLong
                                it[prefix] = ""//event.guild.idLong
                            }
                        }

it doesn’t throw an error but it never actually inserts anything (even if I remove the line setting it[id]._value. The table is defined as:

object GuildPrefixTable : LongIdTable("guild_prefix") {
    val prefix = text("prefix")
}
class GuildPrefix(id: EntityID<Long>) : LongEntity(id) {
    companion object : LongEntityClass<GuildPrefix>(GuildPrefixTable)
    var prefix by GuildPrefixTable.prefix
}

and in MySQL, the table is just id (bigint(20), not automatic primary key), prefix (tinytext)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
TheChilliPLcommented, Sep 16, 2020

Seems like it does work, thank you! I’d update the version given on the Getting Started page, it’d help beginners “fix” issues like this one

0reactions
Tapaccommented, Sep 13, 2020

Yes, please try with the latest version.

Read more comments on GitHub >

github_iconTop Results From Across the Web

I can't insert a row into table with auto_increment column
I have set the auto increment as 1 and truncated table also, but.. it still doesn't work.. I have no idea how to...
Read more >
MySQL 8.0 Reference Manual :: 13.2.7 INSERT Statement
INSERT with an ON DUPLICATE KEY UPDATE clause enables existing rows to be updated if a row to be inserted would cause a...
Read more >
How to INSERT If Row Does Not Exist (UPSERT) in MySQL
Learn how to INSERT an If Row Does Not Exist (UPSERT) in MySQL. MySQL provides a number of useful statements when it is...
Read more >
How to Work with Auto-Incrementing IDs in SQL - Retool
Intro: auto-incrementing fields and primary keys; Create a table with auto-incrementing IDs; Changing increment values; Insert ...
Read more >
How to Use PHP to Insert Data Into MySQL Database
In this tutorial, you will learn how to INSERT data into your MySQL database from PHP scripts. There are two methods that you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found