Kysely types - ID
We've created tables directly with sql script as we need inheritance and don't want xata_* columns in our data. Everything works nice, but when I try to query with id column I get this error:
Everything works when I try to get any other column. My guess is it's got something to do with the xata types for ID (every record type has
& XataRecord
)
id_test
works and id
doesn't, even though they are the same4 Replies
Hi there! Your suspicion is correct. The name "id" for a column is still reserved in xata and several functions assume you mean xata_id when you use this name.
If you're creating tables with their own columns named "id" via a script, you won't receive an error, but you will run into issues further down the line.
If you don't want xata columns in your data I would recommend using "id_x" for your id columns.
This is something we need to clarify and clean up on our end.
I see. Is there any benefit to keeping the internal xata_* columns? Will everything work without them?
Yes there's a benefit. Certain functions, bulk update of records, require the xata_id column (and accept "id" as the argument. For example https://discordapp.com/channels/996791218879086662/1306637331146608660/1306665470598058066
Would it be possible to change this by some flag/argument for
xata codegen
? It's not much of an issue, just DX.