Why is insertId a string, not a number?
After inserting into a table with an auto-incrementing pk, the insertId in the returned ExecutedQuery is a string. Why isn't it a number?
8 Replies
can you post the schema of the table, and the ts code too. I've made mistakes where I duplicated the table column name which overrides the pk.
Actually, I think this has nothing to do with drizzle, it seems it's coming from PlanetScale's database.js:
https://github.com/planetscale/database-js/blob/8b1a360abd9b7b28ab953984e2aa9bd242d8a169/src/index.ts#L27
GitHub
database-js/src/index.ts at 8b1a360abd9b7b28ab953984e2aa9bd242d8a16...
A Fetch API-compatible PlanetScale database driver - database-js/src/index.ts at 8b1a360abd9b7b28ab953984e2aa9bd242d8a169 · planetscale/database-js
oh you're trying to get the inserted data. I forgot mysql doesn't have
returning
. I wonder if drizzle has .returning()
for mysql. I'm using sqlite and I'm able to do returnining().get()
to retrieve the new inserted dataIt doesn't have
returning
😦 I wish it didGitHub
Insert, update and delete with return for MySQL · drizzle-team driz...
V0.26 introduced a lot of very nice features! One very interesting is relational queries and insert, update and delete with return. Is there a plan to add MySQL to the list? Or is there any technic...
This was answered in tweet: MySQL does not provide returning and you always have to make an extra select and we don't do anything implicitly. That's a little less DX, but in a long run it's a win for everybody
Yes, for insertId we just proxy driver behavior
and also as long as MySQL doesn't have .returning we won't have it in Core API. But may have in some sort of helpers api on top of Core