You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Extend D1 docs with clarifications for one-way type conversions (#22093)
* Extend D1 docs with clarifications for one-way type conversions
Clarify the type conversion happening in D1 to avoid confusion by users.
Example: cloudflare/workers-sdk#8642
* PCX Review
---------
Co-authored-by: Jun Lee <[email protected]>
Copy file name to clipboardExpand all lines: src/content/docs/d1/worker-api/index.mdx
+32-14Lines changed: 32 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,26 +40,44 @@ const result = await env.MY_DB.prepare(
40
40
41
41
## Type conversion
42
42
43
-
D1 automatically converts supported JavaScript (including TypeScript) types passed as parameters via the Workers Binding API to their associated D1 types. The type conversion is as follows:
| undefined | Not supported. Queries with `undefined` values will return a `D1_TYPE_ERROR`|
54
-
55
-
<sup>1</sup> D1 supports 64-bit signed `INTEGER` values internally, however
43
+
D1 automatically converts supported JavaScript (including TypeScript) types passed as parameters via the Workers Binding API to their associated D1 types <sup>1</sup>.
44
+
This conversion is permanent and one-way only. This means that when reading the written values back in your code, you will get the converted values rather than the originally inserted values.
45
+
46
+
:::note
47
+
We recommend using [STRICT tables](https://www.sqlite.org/stricttables.html) in your SQL schema to avoid issues with mismatched types between values that are actually stored in your database compared to values defined by your schema.
<sup>5</sup> Queries with `undefined` values will return a `D1_TYPE_ERROR`.
80
+
63
81
## API playground
64
82
65
83
The D1 Worker Binding API playground is an `index.js` file where you can test each of the documented Worker Binding APIs for D1. The file builds from the end-state of the [Get started](/d1/get-started/#write-queries-within-your-worker) code.
0 commit comments