Uh oh!
There was an error while loading. Please reload this page.
Commit 5b288ad
committed
fix(shared): address review feedback on typed numeric SQL variants
P1 fixes
- Reject JS integers outside Number.MAX_SAFE_INTEGER in sql.number(),
sql.int(), and sql.bigint(number). The marker would otherwise advertise
BIGINT for a value already lost to JS-double precision.
- Widen sql.number("10") to BIGINT for integer-shaped strings so handler
code that passes req.query strings works with LIMIT/OFFSET. Decimal-
shaped strings still emit NUMERIC.
- Type-generator: extract INT/BIGINT/TINYINT/SMALLINT/FLOAT/DOUBLE/DECIMAL
-- @PARAM annotations, give them sensible defaults, and route each SQL
type to its closest typed helper in sqlTypeToHelper.
P2 fixes
- Reject Infinity / -Infinity / NaN, hex / scientific-only / whitespace
strings via a strict NUMERIC_LITERAL_RE.
- Emit BIGINT wire values via BigInt(value).toString() so 1e15 -> "1000000000000000"
rather than exponent text.
- Bound-check sql.int (32-bit signed) and sql.bigint (64-bit signed)
inputs; surface a descriptive error pointing to the wider helper.
- Narrow each typed helper's return type to the exact __sql_type literal.
- Add bound, boundary, error, and precision-loss tests for the typed
helpers, plus an integration test for LIMIT :n OFFSET :m bindings.
- Add @returns and @example for every new helper; regenerate
docs/docs/api/appkit/Variable.sql.md.
- Rename sql.decimal -> sql.numeric so name matches the wire literal
(existing typed helpers all match name -> wire). Update analytics.md
to mention the new helpers and refresh the LIMIT example.
Co-authored-by: Isaac
Signed-off-by: James Broadhead <jamesbroadhead@gmail.com>1 parent 73ec9c4 commit 5b288ad
10 files changed
Lines changed: 532 additions & 113 deletions
File tree
- docs/docs
- api/appkit
- plugins
- packages
- appkit/src
- plugins/analytics/tests
- type-generator
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
| 108 | + | |
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
13 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
14 | 24 | | |
15 | 25 | | |
16 | 26 | | |
| |||
23 | 33 | | |
24 | 34 | | |
25 | 35 | | |
26 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
27 | 39 | | |
28 | 40 | | |
29 | 41 | | |
30 | 42 | | |
31 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
32 | 47 | | |
33 | 48 | | |
34 | 49 | | |
| |||
38 | 53 | | |
39 | 54 | | |
40 | 55 | | |
41 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
42 | 69 | | |
43 | 70 | | |
44 | 71 | | |
| |||
159 | 186 | | |
160 | 187 | | |
161 | 188 | | |
162 | | - | |
| 189 | + | |
163 | 190 | | |
164 | 191 | | |
165 | | - | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
166 | 195 | | |
167 | 196 | | |
168 | | - | |
169 | | - | |
170 | | - | |
| 197 | + | |
| 198 | + | |
171 | 199 | | |
172 | 200 | | |
173 | 201 | | |
174 | 202 | | |
175 | 203 | | |
176 | | - | |
| 204 | + | |
177 | 205 | | |
178 | 206 | | |
179 | 207 | | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
192 | 211 | | |
193 | | - | |
194 | | - | |
195 | | - | |
| 212 | + | |
196 | 213 | | |
197 | | - | |
| 214 | + | |
198 | 215 | | |
199 | | - | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
200 | 219 | | |
201 | 220 | | |
202 | 221 | | |
203 | 222 | | |
204 | | - | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
205 | 226 | | |
206 | 227 | | |
207 | | - | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
208 | 231 | | |
209 | 232 | | |
210 | 233 | | |
| |||
214 | 237 | | |
215 | 238 | | |
216 | 239 | | |
217 | | - | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
218 | 251 | | |
219 | 252 | | |
220 | 253 | | |
221 | 254 | | |
222 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
223 | 258 | | |
224 | 259 | | |
225 | 260 | | |
226 | 261 | | |
227 | 262 | | |
228 | 263 | | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
229 | 268 | | |
230 | 269 | | |
231 | 270 | | |
| |||
234 | 273 | | |
235 | 274 | | |
236 | 275 | | |
237 | | - | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
238 | 288 | | |
239 | 289 | | |
240 | 290 | | |
| |||
248 | 298 | | |
249 | 299 | | |
250 | 300 | | |
251 | | - | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
252 | 304 | | |
253 | | - | |
254 | | - | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
255 | 309 | | |
256 | 310 | | |
257 | 311 | | |
| |||
268 | 322 | | |
269 | 323 | | |
270 | 324 | | |
271 | | - | |
272 | | - | |
273 | | - | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
274 | 364 | | |
275 | 365 | | |
276 | 366 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
52 | 56 | | |
53 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
54 | 61 | | |
55 | 62 | | |
56 | 63 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
| 174 | + | |
174 | 175 | | |
175 | | - | |
| 176 | + | |
176 | 177 | | |
177 | 178 | | |
178 | 179 | | |
179 | 180 | | |
180 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
181 | 227 | | |
182 | 228 | | |
183 | 229 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
197 | | - | |
| 197 | + | |
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
210 | 215 | | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
211 | 219 | | |
212 | 220 | | |
213 | 221 | | |
| |||
0 commit comments