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.

Emoji insert exception

See original GitHub issue

My code is

var sql = "INSERT IGNORE INTO cs SET " +
            "cs_title=?," +
            ...
        conn.query(sql, {
            replacements: [course.name, ...],
            type: sequelize.QueryTypes.INSERT
        }).then(function (courseId) {
...

when insert 我的心😘😉😘’

case this exception

UPDATE cs SET cs_title='我的心😘😉😘',....
Unhandled rejection SequelizeDatabaseError: ER_TRUNCATED_WRONG_VALUE_FOR_FIELD: Incorrect string value: '\xF0\x9F\x98\x98\xF0\x9F...' for column 'cs_title' at row 1
    at Query.formatError (/home/Tinstone-Course-Server/node_modules/sequelize/lib/dialects/mysql/query.js:175:14)
    at Query._callback (/home/Tinstone-Course-Server/node_modules/sequelize/lib/dialects/mysql/query.js:49:21)
    at Query.Sequence.end (/home/Tinstone-Course-Server/node_modules/mysql/lib/protocol/sequences/Sequence.js:85:24)
    at Query.ErrorPacket (/home/Tinstone-Course-Server/node_modules/mysql/lib/protocol/sequences/Query.js:94:8)
    at Protocol._parsePacket (/home/Tinstone-Course-Server/node_modules/mysql/lib/protocol/Protocol.js:280:23)
    at Parser.write (/home/Tinstone-Course-Server/node_modules/mysql/lib/protocol/Parser.js:74:12)
    at Protocol.write (/home/Tinstone-Course-Server/node_modules/mysql/lib/protocol/Protocol.js:39:16)
    at Socket.<anonymous> (/home/Tinstone-Course-Server/node_modules/mysql/lib/Connection.js:109:28)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:172:18)
    at Socket.Readable.push (_stream_readable.js:130:10)
    at TCP.onread (net.js:542:20)

Issue Analytics

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

github_iconTop GitHub Comments

4reactions
sushantdhimancommented, Oct 31, 2016

Hi @dongtong , Did you created the table first then set the it to utf8mb4 ? Please re-create the table with charset utf8mb4 and see if you can insert strings properly after that.

0reactions
npkecommented, Aug 24, 2017

Hi @DzmitryU DZ This configuration works for me config database charset. You should give it a try.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Insert statements working when inserting emojis, but throws ...
Whereas Emoji characters are up to 4 bytes long. Therefore we need to use utf8mb4 as our charset. Solution: 1. Open your config/database.php....
Read more >
How to Insert Emojis In Excel | Fix Emoji Error In Excel
How to Insert Emojis In Excel | Fix Emoji Error In Excel Thanks For Watching,Please Like, Share & Subscribe #datharamesh For More Videos....
Read more >
Unable to insert emoji into USER_COMMIT ... - Atlassian
Unable to insert emoji into USER_COMMIT. ... Exception: JDBC exception on Hibernate data access: SQLException for SQL [insert into USER_COMMIT ...
Read more >
Emoji Keyboard - Microsoft Community
Emoji Keyboard. I keep getting an error when i try to insert an emoji in a Word document... This thread is locked.
Read more >
emoji character causing PDOException [#2375541] | Drupal.org
emoji character causing PDOException ... When a user adds an emoji to their message, the site shows shows the 'Site Offline' message and...
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