singlestoredb 1.12.4__py3-none-any.whl → 1.13.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of singlestoredb might be problematic. Click here for more details.
- singlestoredb/__init__.py +1 -1
- singlestoredb/apps/__init__.py +1 -0
- singlestoredb/apps/_config.py +6 -0
- singlestoredb/apps/_connection_info.py +8 -0
- singlestoredb/apps/_python_udfs.py +85 -0
- singlestoredb/config.py +14 -2
- singlestoredb/functions/__init__.py +11 -1
- singlestoredb/functions/decorator.py +102 -252
- singlestoredb/functions/dtypes.py +545 -198
- singlestoredb/functions/ext/asgi.py +288 -90
- singlestoredb/functions/ext/json.py +29 -36
- singlestoredb/functions/ext/mmap.py +1 -1
- singlestoredb/functions/ext/rowdat_1.py +50 -70
- singlestoredb/functions/signature.py +816 -144
- singlestoredb/functions/typing.py +41 -0
- singlestoredb/functions/utils.py +342 -0
- singlestoredb/http/connection.py +3 -1
- singlestoredb/management/manager.py +6 -1
- singlestoredb/management/utils.py +2 -2
- singlestoredb/tests/ext_funcs/__init__.py +476 -237
- singlestoredb/tests/test_ext_func.py +192 -3
- singlestoredb/tests/test_udf.py +101 -131
- singlestoredb/tests/test_udf_returns.py +459 -0
- {singlestoredb-1.12.4.dist-info → singlestoredb-1.13.0.dist-info}/METADATA +2 -1
- {singlestoredb-1.12.4.dist-info → singlestoredb-1.13.0.dist-info}/RECORD +29 -25
- {singlestoredb-1.12.4.dist-info → singlestoredb-1.13.0.dist-info}/LICENSE +0 -0
- {singlestoredb-1.12.4.dist-info → singlestoredb-1.13.0.dist-info}/WHEEL +0 -0
- {singlestoredb-1.12.4.dist-info → singlestoredb-1.13.0.dist-info}/entry_points.txt +0 -0
- {singlestoredb-1.12.4.dist-info → singlestoredb-1.13.0.dist-info}/top_level.txt +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
+
import base64
|
|
2
3
|
import datetime
|
|
3
4
|
import decimal
|
|
4
5
|
import re
|
|
5
6
|
from typing import Any
|
|
6
7
|
from typing import Callable
|
|
7
8
|
from typing import Optional
|
|
8
|
-
from typing import Tuple
|
|
9
9
|
from typing import Union
|
|
10
10
|
|
|
11
11
|
from ..converters import converters
|
|
@@ -20,6 +20,11 @@ from ..utils.dtypes import PYARROW_TYPE_MAP # noqa
|
|
|
20
20
|
DataType = Union[str, Callable[..., Any]]
|
|
21
21
|
|
|
22
22
|
|
|
23
|
+
class SQLString(str):
|
|
24
|
+
"""SQL string type."""
|
|
25
|
+
name: Optional[str] = None
|
|
26
|
+
|
|
27
|
+
|
|
23
28
|
class NULL:
|
|
24
29
|
"""NULL (for use in default values)."""
|
|
25
30
|
pass
|
|
@@ -101,7 +106,7 @@ def bytestr(x: Any) -> Optional[bytes]:
|
|
|
101
106
|
return x
|
|
102
107
|
if isinstance(x, bytes):
|
|
103
108
|
return x
|
|
104
|
-
return
|
|
109
|
+
return base64.b64decode(x)
|
|
105
110
|
|
|
106
111
|
|
|
107
112
|
PYTHON_CONVERTERS = {
|
|
@@ -194,7 +199,12 @@ def _bool(x: Optional[bool] = None) -> Optional[bool]:
|
|
|
194
199
|
return bool(x)
|
|
195
200
|
|
|
196
201
|
|
|
197
|
-
def BOOL(
|
|
202
|
+
def BOOL(
|
|
203
|
+
*,
|
|
204
|
+
nullable: bool = True,
|
|
205
|
+
default: Optional[bool] = None,
|
|
206
|
+
name: Optional[str] = None,
|
|
207
|
+
) -> SQLString:
|
|
198
208
|
"""
|
|
199
209
|
BOOL type specification.
|
|
200
210
|
|
|
@@ -204,16 +214,25 @@ def BOOL(*, nullable: bool = True, default: Optional[bool] = None) -> str:
|
|
|
204
214
|
Can the value be NULL?
|
|
205
215
|
default : bool, optional
|
|
206
216
|
Default value
|
|
217
|
+
name : str, optional
|
|
218
|
+
Name of the column / parameter
|
|
207
219
|
|
|
208
220
|
Returns
|
|
209
221
|
-------
|
|
210
|
-
|
|
222
|
+
SQLString
|
|
211
223
|
|
|
212
224
|
"""
|
|
213
|
-
|
|
225
|
+
out = SQLString('BOOL' + _modifiers(nullable=nullable, default=_bool(default)))
|
|
226
|
+
out.name = name
|
|
227
|
+
return out
|
|
214
228
|
|
|
215
229
|
|
|
216
|
-
def BOOLEAN(
|
|
230
|
+
def BOOLEAN(
|
|
231
|
+
*,
|
|
232
|
+
nullable: bool = True,
|
|
233
|
+
default: Optional[bool] = None,
|
|
234
|
+
name: Optional[str] = None,
|
|
235
|
+
) -> SQLString:
|
|
217
236
|
"""
|
|
218
237
|
BOOLEAN type specification.
|
|
219
238
|
|
|
@@ -223,16 +242,25 @@ def BOOLEAN(*, nullable: bool = True, default: Optional[bool] = None) -> str:
|
|
|
223
242
|
Can the value be NULL?
|
|
224
243
|
default : bool, optional
|
|
225
244
|
Default value
|
|
245
|
+
name : str, optional
|
|
246
|
+
Name of the column / parameter
|
|
226
247
|
|
|
227
248
|
Returns
|
|
228
249
|
-------
|
|
229
|
-
|
|
250
|
+
SQLString
|
|
230
251
|
|
|
231
252
|
"""
|
|
232
|
-
|
|
253
|
+
out = SQLString('BOOLEAN' + _modifiers(nullable=nullable, default=_bool(default)))
|
|
254
|
+
out.name = name
|
|
255
|
+
return out
|
|
233
256
|
|
|
234
257
|
|
|
235
|
-
def BIT(
|
|
258
|
+
def BIT(
|
|
259
|
+
*,
|
|
260
|
+
nullable: bool = True,
|
|
261
|
+
default: Optional[int] = None,
|
|
262
|
+
name: Optional[str] = None,
|
|
263
|
+
) -> SQLString:
|
|
236
264
|
"""
|
|
237
265
|
BIT type specification.
|
|
238
266
|
|
|
@@ -242,13 +270,17 @@ def BIT(*, nullable: bool = True, default: Optional[int] = None) -> str:
|
|
|
242
270
|
Can the value be NULL?
|
|
243
271
|
default : int, optional
|
|
244
272
|
Default value
|
|
273
|
+
name : str, optional
|
|
274
|
+
Name of the column / parameter
|
|
245
275
|
|
|
246
276
|
Returns
|
|
247
277
|
-------
|
|
248
|
-
|
|
278
|
+
SQLString
|
|
249
279
|
|
|
250
280
|
"""
|
|
251
|
-
|
|
281
|
+
out = SQLString('BIT' + _modifiers(nullable=nullable, default=default))
|
|
282
|
+
out.name = name
|
|
283
|
+
return out
|
|
252
284
|
|
|
253
285
|
|
|
254
286
|
def TINYINT(
|
|
@@ -257,7 +289,8 @@ def TINYINT(
|
|
|
257
289
|
nullable: bool = True,
|
|
258
290
|
default: Optional[int] = None,
|
|
259
291
|
unsigned: bool = False,
|
|
260
|
-
|
|
292
|
+
name: Optional[str] = None,
|
|
293
|
+
) -> SQLString:
|
|
261
294
|
"""
|
|
262
295
|
TINYINT type specification.
|
|
263
296
|
|
|
@@ -271,14 +304,20 @@ def TINYINT(
|
|
|
271
304
|
Default value
|
|
272
305
|
unsigned : bool, optional
|
|
273
306
|
Is the int unsigned?
|
|
307
|
+
name : str, optional
|
|
308
|
+
Name of the column / parameter
|
|
274
309
|
|
|
275
310
|
Returns
|
|
276
311
|
-------
|
|
277
|
-
|
|
312
|
+
SQLString
|
|
278
313
|
|
|
279
314
|
"""
|
|
280
315
|
out = f'TINYINT({display_width})' if display_width else 'TINYINT'
|
|
281
|
-
|
|
316
|
+
out = SQLString(
|
|
317
|
+
out + _modifiers(nullable=nullable, default=default, unsigned=unsigned),
|
|
318
|
+
)
|
|
319
|
+
out.name = name
|
|
320
|
+
return out
|
|
282
321
|
|
|
283
322
|
|
|
284
323
|
def TINYINT_UNSIGNED(
|
|
@@ -286,7 +325,8 @@ def TINYINT_UNSIGNED(
|
|
|
286
325
|
*,
|
|
287
326
|
nullable: bool = True,
|
|
288
327
|
default: Optional[int] = None,
|
|
289
|
-
|
|
328
|
+
name: Optional[str] = None,
|
|
329
|
+
) -> SQLString:
|
|
290
330
|
"""
|
|
291
331
|
TINYINT UNSIGNED type specification.
|
|
292
332
|
|
|
@@ -298,14 +338,18 @@ def TINYINT_UNSIGNED(
|
|
|
298
338
|
Can the value be NULL?
|
|
299
339
|
default : int, optional
|
|
300
340
|
Default value
|
|
341
|
+
name : str, optional
|
|
342
|
+
Name of the column / parameter
|
|
301
343
|
|
|
302
344
|
Returns
|
|
303
345
|
-------
|
|
304
|
-
|
|
346
|
+
SQLString
|
|
305
347
|
|
|
306
348
|
"""
|
|
307
349
|
out = f'TINYINT({display_width})' if display_width else 'TINYINT'
|
|
308
|
-
|
|
350
|
+
out = SQLString(out + _modifiers(nullable=nullable, default=default, unsigned=True))
|
|
351
|
+
out.name = name
|
|
352
|
+
return out
|
|
309
353
|
|
|
310
354
|
|
|
311
355
|
def SMALLINT(
|
|
@@ -314,7 +358,8 @@ def SMALLINT(
|
|
|
314
358
|
nullable: bool = True,
|
|
315
359
|
default: Optional[int] = None,
|
|
316
360
|
unsigned: bool = False,
|
|
317
|
-
|
|
361
|
+
name: Optional[str] = None,
|
|
362
|
+
) -> SQLString:
|
|
318
363
|
"""
|
|
319
364
|
SMALLINT type specification.
|
|
320
365
|
|
|
@@ -328,14 +373,20 @@ def SMALLINT(
|
|
|
328
373
|
Default value
|
|
329
374
|
unsigned : bool, optional
|
|
330
375
|
Is the int unsigned?
|
|
376
|
+
name : str, optional
|
|
377
|
+
Name of the column / parameter
|
|
331
378
|
|
|
332
379
|
Returns
|
|
333
380
|
-------
|
|
334
|
-
|
|
381
|
+
SQLString
|
|
335
382
|
|
|
336
383
|
"""
|
|
337
384
|
out = f'SMALLINT({display_width})' if display_width else 'SMALLINT'
|
|
338
|
-
|
|
385
|
+
out = SQLString(
|
|
386
|
+
out + _modifiers(nullable=nullable, default=default, unsigned=unsigned),
|
|
387
|
+
)
|
|
388
|
+
out.name = name
|
|
389
|
+
return out
|
|
339
390
|
|
|
340
391
|
|
|
341
392
|
def SMALLINT_UNSIGNED(
|
|
@@ -343,7 +394,8 @@ def SMALLINT_UNSIGNED(
|
|
|
343
394
|
*,
|
|
344
395
|
nullable: bool = True,
|
|
345
396
|
default: Optional[int] = None,
|
|
346
|
-
|
|
397
|
+
name: Optional[str] = None,
|
|
398
|
+
) -> SQLString:
|
|
347
399
|
"""
|
|
348
400
|
SMALLINT UNSIGNED type specification.
|
|
349
401
|
|
|
@@ -355,14 +407,18 @@ def SMALLINT_UNSIGNED(
|
|
|
355
407
|
Can the value be NULL?
|
|
356
408
|
default : int, optional
|
|
357
409
|
Default value
|
|
410
|
+
name : str, optional
|
|
411
|
+
Name of the column / parameter
|
|
358
412
|
|
|
359
413
|
Returns
|
|
360
414
|
-------
|
|
361
|
-
|
|
415
|
+
SQLString
|
|
362
416
|
|
|
363
417
|
"""
|
|
364
418
|
out = f'SMALLINT({display_width})' if display_width else 'SMALLINT'
|
|
365
|
-
|
|
419
|
+
out = SQLString(out + _modifiers(nullable=nullable, default=default, unsigned=True))
|
|
420
|
+
out.name = name
|
|
421
|
+
return out
|
|
366
422
|
|
|
367
423
|
|
|
368
424
|
def MEDIUMINT(
|
|
@@ -371,7 +427,8 @@ def MEDIUMINT(
|
|
|
371
427
|
nullable: bool = True,
|
|
372
428
|
default: Optional[int] = None,
|
|
373
429
|
unsigned: bool = False,
|
|
374
|
-
|
|
430
|
+
name: Optional[str] = None,
|
|
431
|
+
) -> SQLString:
|
|
375
432
|
"""
|
|
376
433
|
MEDIUMINT type specification.
|
|
377
434
|
|
|
@@ -385,14 +442,20 @@ def MEDIUMINT(
|
|
|
385
442
|
Default value
|
|
386
443
|
unsigned : bool, optional
|
|
387
444
|
Is the int unsigned?
|
|
445
|
+
name : str, optional
|
|
446
|
+
Name of the column / parameter
|
|
388
447
|
|
|
389
448
|
Returns
|
|
390
449
|
-------
|
|
391
|
-
|
|
450
|
+
SQLString
|
|
392
451
|
|
|
393
452
|
"""
|
|
394
453
|
out = f'MEDIUMINT({display_width})' if display_width else 'MEDIUMINT'
|
|
395
|
-
|
|
454
|
+
out = SQLString(
|
|
455
|
+
out + _modifiers(nullable=nullable, default=default, unsigned=unsigned),
|
|
456
|
+
)
|
|
457
|
+
out.name = name
|
|
458
|
+
return out
|
|
396
459
|
|
|
397
460
|
|
|
398
461
|
def MEDIUMINT_UNSIGNED(
|
|
@@ -400,7 +463,8 @@ def MEDIUMINT_UNSIGNED(
|
|
|
400
463
|
*,
|
|
401
464
|
nullable: bool = True,
|
|
402
465
|
default: Optional[int] = None,
|
|
403
|
-
|
|
466
|
+
name: Optional[str] = None,
|
|
467
|
+
) -> SQLString:
|
|
404
468
|
"""
|
|
405
469
|
MEDIUMINT UNSIGNED type specification.
|
|
406
470
|
|
|
@@ -412,14 +476,18 @@ def MEDIUMINT_UNSIGNED(
|
|
|
412
476
|
Can the value be NULL?
|
|
413
477
|
default : int, optional
|
|
414
478
|
Default value
|
|
479
|
+
name : str, optional
|
|
480
|
+
Name of the column / parameter
|
|
415
481
|
|
|
416
482
|
Returns
|
|
417
483
|
-------
|
|
418
|
-
|
|
484
|
+
SQLString
|
|
419
485
|
|
|
420
486
|
"""
|
|
421
487
|
out = f'MEDIUMINT({display_width})' if display_width else 'MEDIUMINT'
|
|
422
|
-
|
|
488
|
+
out = SQLString(out + _modifiers(nullable=nullable, default=default, unsigned=True))
|
|
489
|
+
out.name = name
|
|
490
|
+
return out
|
|
423
491
|
|
|
424
492
|
|
|
425
493
|
def INT(
|
|
@@ -428,7 +496,8 @@ def INT(
|
|
|
428
496
|
nullable: bool = True,
|
|
429
497
|
default: Optional[int] = None,
|
|
430
498
|
unsigned: bool = False,
|
|
431
|
-
|
|
499
|
+
name: Optional[str] = None,
|
|
500
|
+
) -> SQLString:
|
|
432
501
|
"""
|
|
433
502
|
INT type specification.
|
|
434
503
|
|
|
@@ -442,14 +511,20 @@ def INT(
|
|
|
442
511
|
Default value
|
|
443
512
|
unsigned : bool, optional
|
|
444
513
|
Is the int unsigned?
|
|
514
|
+
name : str, optional
|
|
515
|
+
Name of the column / parameter
|
|
445
516
|
|
|
446
517
|
Returns
|
|
447
518
|
-------
|
|
448
|
-
|
|
519
|
+
SQLString
|
|
449
520
|
|
|
450
521
|
"""
|
|
451
522
|
out = f'INT({display_width})' if display_width else 'INT'
|
|
452
|
-
|
|
523
|
+
out = SQLString(
|
|
524
|
+
out + _modifiers(nullable=nullable, default=default, unsigned=unsigned),
|
|
525
|
+
)
|
|
526
|
+
out.name = name
|
|
527
|
+
return out
|
|
453
528
|
|
|
454
529
|
|
|
455
530
|
def INT_UNSIGNED(
|
|
@@ -457,7 +532,8 @@ def INT_UNSIGNED(
|
|
|
457
532
|
*,
|
|
458
533
|
nullable: bool = True,
|
|
459
534
|
default: Optional[int] = None,
|
|
460
|
-
|
|
535
|
+
name: Optional[str] = None,
|
|
536
|
+
) -> SQLString:
|
|
461
537
|
"""
|
|
462
538
|
INT UNSIGNED type specification.
|
|
463
539
|
|
|
@@ -469,14 +545,18 @@ def INT_UNSIGNED(
|
|
|
469
545
|
Can the value be NULL?
|
|
470
546
|
default : int, optional
|
|
471
547
|
Default value
|
|
548
|
+
name : str, optional
|
|
549
|
+
Name of the column / parameter
|
|
472
550
|
|
|
473
551
|
Returns
|
|
474
552
|
-------
|
|
475
|
-
|
|
553
|
+
SQLString
|
|
476
554
|
|
|
477
555
|
"""
|
|
478
556
|
out = f'INT({display_width})' if display_width else 'INT'
|
|
479
|
-
|
|
557
|
+
out = SQLString(out + _modifiers(nullable=nullable, default=default, unsigned=True))
|
|
558
|
+
out.name = name
|
|
559
|
+
return out
|
|
480
560
|
|
|
481
561
|
|
|
482
562
|
def INTEGER(
|
|
@@ -485,7 +565,8 @@ def INTEGER(
|
|
|
485
565
|
nullable: bool = True,
|
|
486
566
|
default: Optional[int] = None,
|
|
487
567
|
unsigned: bool = False,
|
|
488
|
-
|
|
568
|
+
name: Optional[str] = None,
|
|
569
|
+
) -> SQLString:
|
|
489
570
|
"""
|
|
490
571
|
INTEGER type specification.
|
|
491
572
|
|
|
@@ -499,14 +580,20 @@ def INTEGER(
|
|
|
499
580
|
Default value
|
|
500
581
|
unsigned : bool, optional
|
|
501
582
|
Is the int unsigned?
|
|
583
|
+
name : str, optional
|
|
584
|
+
Name of the column / parameter
|
|
502
585
|
|
|
503
586
|
Returns
|
|
504
587
|
-------
|
|
505
|
-
|
|
588
|
+
SQLString
|
|
506
589
|
|
|
507
590
|
"""
|
|
508
591
|
out = f'INTEGER({display_width})' if display_width else 'INTEGER'
|
|
509
|
-
|
|
592
|
+
out = SQLString(
|
|
593
|
+
out + _modifiers(nullable=nullable, default=default, unsigned=unsigned),
|
|
594
|
+
)
|
|
595
|
+
out.name = name
|
|
596
|
+
return out
|
|
510
597
|
|
|
511
598
|
|
|
512
599
|
def INTEGER_UNSIGNED(
|
|
@@ -514,7 +601,8 @@ def INTEGER_UNSIGNED(
|
|
|
514
601
|
*,
|
|
515
602
|
nullable: bool = True,
|
|
516
603
|
default: Optional[int] = None,
|
|
517
|
-
|
|
604
|
+
name: Optional[str] = None,
|
|
605
|
+
) -> SQLString:
|
|
518
606
|
"""
|
|
519
607
|
INTEGER UNSIGNED type specification.
|
|
520
608
|
|
|
@@ -526,14 +614,18 @@ def INTEGER_UNSIGNED(
|
|
|
526
614
|
Can the value be NULL?
|
|
527
615
|
default : int, optional
|
|
528
616
|
Default value
|
|
617
|
+
name : str, optional
|
|
618
|
+
Name of the column / parameter
|
|
529
619
|
|
|
530
620
|
Returns
|
|
531
621
|
-------
|
|
532
|
-
|
|
622
|
+
SQLString
|
|
533
623
|
|
|
534
624
|
"""
|
|
535
625
|
out = f'INTEGER({display_width})' if display_width else 'INTEGER'
|
|
536
|
-
|
|
626
|
+
out = SQLString(out + _modifiers(nullable=nullable, default=default, unsigned=True))
|
|
627
|
+
out.name = name
|
|
628
|
+
return out
|
|
537
629
|
|
|
538
630
|
|
|
539
631
|
def BIGINT(
|
|
@@ -542,7 +634,8 @@ def BIGINT(
|
|
|
542
634
|
nullable: bool = True,
|
|
543
635
|
default: Optional[int] = None,
|
|
544
636
|
unsigned: bool = False,
|
|
545
|
-
|
|
637
|
+
name: Optional[str] = None,
|
|
638
|
+
) -> SQLString:
|
|
546
639
|
"""
|
|
547
640
|
BIGINT type specification.
|
|
548
641
|
|
|
@@ -556,14 +649,20 @@ def BIGINT(
|
|
|
556
649
|
Default value
|
|
557
650
|
unsigned : bool, optional
|
|
558
651
|
Is the int unsigned?
|
|
652
|
+
name : str, optional
|
|
653
|
+
Name of the column / parameter
|
|
559
654
|
|
|
560
655
|
Returns
|
|
561
656
|
-------
|
|
562
|
-
|
|
657
|
+
SQLString
|
|
563
658
|
|
|
564
659
|
"""
|
|
565
660
|
out = f'BIGINT({display_width})' if display_width else 'BIGINT'
|
|
566
|
-
|
|
661
|
+
out = SQLString(
|
|
662
|
+
out + _modifiers(nullable=nullable, default=default, unsigned=unsigned),
|
|
663
|
+
)
|
|
664
|
+
out.name = name
|
|
665
|
+
return out
|
|
567
666
|
|
|
568
667
|
|
|
569
668
|
def BIGINT_UNSIGNED(
|
|
@@ -571,7 +670,8 @@ def BIGINT_UNSIGNED(
|
|
|
571
670
|
*,
|
|
572
671
|
nullable: bool = True,
|
|
573
672
|
default: Optional[int] = None,
|
|
574
|
-
|
|
673
|
+
name: Optional[str] = None,
|
|
674
|
+
) -> SQLString:
|
|
575
675
|
"""
|
|
576
676
|
BIGINT UNSIGNED type specification.
|
|
577
677
|
|
|
@@ -583,14 +683,18 @@ def BIGINT_UNSIGNED(
|
|
|
583
683
|
Can the value be NULL?
|
|
584
684
|
default : int, optional
|
|
585
685
|
Default value
|
|
686
|
+
name : str, optional
|
|
687
|
+
Name of the column / parameter
|
|
586
688
|
|
|
587
689
|
Returns
|
|
588
690
|
-------
|
|
589
|
-
|
|
691
|
+
SQLString
|
|
590
692
|
|
|
591
693
|
"""
|
|
592
694
|
out = f'BIGINT({int(display_width)})' if display_width else 'BIGINT'
|
|
593
|
-
|
|
695
|
+
out = SQLString(out + _modifiers(nullable=nullable, default=default, unsigned=True))
|
|
696
|
+
out.name = name
|
|
697
|
+
return out
|
|
594
698
|
|
|
595
699
|
|
|
596
700
|
def FLOAT(
|
|
@@ -598,7 +702,8 @@ def FLOAT(
|
|
|
598
702
|
*,
|
|
599
703
|
nullable: bool = True,
|
|
600
704
|
default: Optional[float] = None,
|
|
601
|
-
|
|
705
|
+
name: Optional[str] = None,
|
|
706
|
+
) -> SQLString:
|
|
602
707
|
"""
|
|
603
708
|
FLOAT type specification.
|
|
604
709
|
|
|
@@ -610,14 +715,18 @@ def FLOAT(
|
|
|
610
715
|
Can the value be NULL?
|
|
611
716
|
default : float, optional
|
|
612
717
|
Default value
|
|
718
|
+
name : str, optional
|
|
719
|
+
Name of the column / parameter
|
|
613
720
|
|
|
614
721
|
Returns
|
|
615
722
|
-------
|
|
616
|
-
|
|
723
|
+
SQLString
|
|
617
724
|
|
|
618
725
|
"""
|
|
619
726
|
out = f'FLOAT({int(display_decimals)})' if display_decimals else 'FLOAT'
|
|
620
|
-
|
|
727
|
+
out = SQLString(out + _modifiers(nullable=nullable, default=default))
|
|
728
|
+
out.name = name
|
|
729
|
+
return out
|
|
621
730
|
|
|
622
731
|
|
|
623
732
|
def DOUBLE(
|
|
@@ -625,7 +734,8 @@ def DOUBLE(
|
|
|
625
734
|
*,
|
|
626
735
|
nullable: bool = True,
|
|
627
736
|
default: Optional[float] = None,
|
|
628
|
-
|
|
737
|
+
name: Optional[str] = None,
|
|
738
|
+
) -> SQLString:
|
|
629
739
|
"""
|
|
630
740
|
DOUBLE type specification.
|
|
631
741
|
|
|
@@ -637,14 +747,18 @@ def DOUBLE(
|
|
|
637
747
|
Can the value be NULL?
|
|
638
748
|
default : float, optional
|
|
639
749
|
Default value
|
|
750
|
+
name : str, optional
|
|
751
|
+
Name of the column / parameter
|
|
640
752
|
|
|
641
753
|
Returns
|
|
642
754
|
-------
|
|
643
|
-
|
|
755
|
+
SQLString
|
|
644
756
|
|
|
645
757
|
"""
|
|
646
758
|
out = f'DOUBLE({int(display_decimals)})' if display_decimals else 'DOUBLE'
|
|
647
|
-
|
|
759
|
+
out = SQLString(out + _modifiers(nullable=nullable, default=default))
|
|
760
|
+
out.name = name
|
|
761
|
+
return out
|
|
648
762
|
|
|
649
763
|
|
|
650
764
|
def REAL(
|
|
@@ -652,7 +766,8 @@ def REAL(
|
|
|
652
766
|
*,
|
|
653
767
|
nullable: bool = True,
|
|
654
768
|
default: Optional[float] = None,
|
|
655
|
-
|
|
769
|
+
name: Optional[str] = None,
|
|
770
|
+
) -> SQLString:
|
|
656
771
|
"""
|
|
657
772
|
REAL type specification.
|
|
658
773
|
|
|
@@ -664,14 +779,18 @@ def REAL(
|
|
|
664
779
|
Can the value be NULL?
|
|
665
780
|
default : float, optional
|
|
666
781
|
Default value
|
|
782
|
+
name : str, optional
|
|
783
|
+
Name of the column / parameter
|
|
667
784
|
|
|
668
785
|
Returns
|
|
669
786
|
-------
|
|
670
|
-
|
|
787
|
+
SQLString
|
|
671
788
|
|
|
672
789
|
"""
|
|
673
790
|
out = f'REAL({int(display_decimals)})' if display_decimals else 'REAL'
|
|
674
|
-
|
|
791
|
+
out = SQLString(out + _modifiers(nullable=nullable, default=default))
|
|
792
|
+
out.name = name
|
|
793
|
+
return out
|
|
675
794
|
|
|
676
795
|
|
|
677
796
|
def DECIMAL(
|
|
@@ -680,7 +799,8 @@ def DECIMAL(
|
|
|
680
799
|
*,
|
|
681
800
|
nullable: bool = True,
|
|
682
801
|
default: Optional[Union[str, decimal.Decimal]] = None,
|
|
683
|
-
|
|
802
|
+
name: Optional[str] = None,
|
|
803
|
+
) -> SQLString:
|
|
684
804
|
"""
|
|
685
805
|
DECIMAL type specification.
|
|
686
806
|
|
|
@@ -694,14 +814,20 @@ def DECIMAL(
|
|
|
694
814
|
Can the value be NULL?
|
|
695
815
|
default : str or decimal.Decimal, optional
|
|
696
816
|
Default value
|
|
817
|
+
name : str, optional
|
|
818
|
+
Name of the column / parameter
|
|
697
819
|
|
|
698
820
|
Returns
|
|
699
821
|
-------
|
|
700
|
-
|
|
822
|
+
SQLString
|
|
701
823
|
|
|
702
824
|
"""
|
|
703
|
-
|
|
704
|
-
|
|
825
|
+
out = SQLString(
|
|
826
|
+
f'DECIMAL({int(precision)}, {int(scale)})' +
|
|
827
|
+
_modifiers(nullable=nullable, default=default),
|
|
828
|
+
)
|
|
829
|
+
out.name = name
|
|
830
|
+
return out
|
|
705
831
|
|
|
706
832
|
|
|
707
833
|
def DEC(
|
|
@@ -710,7 +836,8 @@ def DEC(
|
|
|
710
836
|
*,
|
|
711
837
|
nullable: bool = True,
|
|
712
838
|
default: Optional[Union[str, decimal.Decimal]] = None,
|
|
713
|
-
|
|
839
|
+
name: Optional[str] = None,
|
|
840
|
+
) -> SQLString:
|
|
714
841
|
"""
|
|
715
842
|
DEC type specification.
|
|
716
843
|
|
|
@@ -724,14 +851,20 @@ def DEC(
|
|
|
724
851
|
Can the value be NULL?
|
|
725
852
|
default : str or decimal.Decimal, optional
|
|
726
853
|
Default value
|
|
854
|
+
name : str, optional
|
|
855
|
+
Name of the column / parameter
|
|
727
856
|
|
|
728
857
|
Returns
|
|
729
858
|
-------
|
|
730
|
-
|
|
859
|
+
SQLString
|
|
731
860
|
|
|
732
861
|
"""
|
|
733
|
-
|
|
734
|
-
|
|
862
|
+
out = SQLString(
|
|
863
|
+
f'DEC({int(precision)}, {int(scale)})' +
|
|
864
|
+
_modifiers(nullable=nullable, default=default),
|
|
865
|
+
)
|
|
866
|
+
out.name = name
|
|
867
|
+
return out
|
|
735
868
|
|
|
736
869
|
|
|
737
870
|
def FIXED(
|
|
@@ -740,7 +873,8 @@ def FIXED(
|
|
|
740
873
|
*,
|
|
741
874
|
nullable: bool = True,
|
|
742
875
|
default: Optional[Union[str, decimal.Decimal]] = None,
|
|
743
|
-
|
|
876
|
+
name: Optional[str] = None,
|
|
877
|
+
) -> SQLString:
|
|
744
878
|
"""
|
|
745
879
|
FIXED type specification.
|
|
746
880
|
|
|
@@ -754,14 +888,20 @@ def FIXED(
|
|
|
754
888
|
Can the value be NULL?
|
|
755
889
|
default : str or decimal.Decimal, optional
|
|
756
890
|
Default value
|
|
891
|
+
name : str, optional
|
|
892
|
+
Name of the column / parameter
|
|
757
893
|
|
|
758
894
|
Returns
|
|
759
895
|
-------
|
|
760
|
-
|
|
896
|
+
SQLString
|
|
761
897
|
|
|
762
898
|
"""
|
|
763
|
-
|
|
764
|
-
|
|
899
|
+
out = SQLString(
|
|
900
|
+
f'FIXED({int(precision)}, {int(scale)})' +
|
|
901
|
+
_modifiers(nullable=nullable, default=default),
|
|
902
|
+
)
|
|
903
|
+
out.name = name
|
|
904
|
+
return out
|
|
765
905
|
|
|
766
906
|
|
|
767
907
|
def NUMERIC(
|
|
@@ -770,7 +910,8 @@ def NUMERIC(
|
|
|
770
910
|
*,
|
|
771
911
|
nullable: bool = True,
|
|
772
912
|
default: Optional[Union[str, decimal.Decimal]] = None,
|
|
773
|
-
|
|
913
|
+
name: Optional[str] = None,
|
|
914
|
+
) -> SQLString:
|
|
774
915
|
"""
|
|
775
916
|
NUMERIC type specification.
|
|
776
917
|
|
|
@@ -784,21 +925,28 @@ def NUMERIC(
|
|
|
784
925
|
Can the value be NULL?
|
|
785
926
|
default : str or decimal.Decimal, optional
|
|
786
927
|
Default value
|
|
928
|
+
name : str, optional
|
|
929
|
+
Name of the column / parameter
|
|
787
930
|
|
|
788
931
|
Returns
|
|
789
932
|
-------
|
|
790
|
-
|
|
933
|
+
SQLString
|
|
791
934
|
|
|
792
935
|
"""
|
|
793
|
-
|
|
794
|
-
|
|
936
|
+
out = SQLString(
|
|
937
|
+
f'NUMERIC({int(precision)}, {int(scale)})' +
|
|
938
|
+
_modifiers(nullable=nullable, default=default),
|
|
939
|
+
)
|
|
940
|
+
out.name = name
|
|
941
|
+
return out
|
|
795
942
|
|
|
796
943
|
|
|
797
944
|
def DATE(
|
|
798
945
|
*,
|
|
799
946
|
nullable: bool = True,
|
|
800
947
|
default: Optional[Union[str, datetime.date]] = None,
|
|
801
|
-
|
|
948
|
+
name: Optional[str] = None,
|
|
949
|
+
) -> SQLString:
|
|
802
950
|
"""
|
|
803
951
|
DATE type specification.
|
|
804
952
|
|
|
@@ -808,13 +956,17 @@ def DATE(
|
|
|
808
956
|
Can the value be NULL?
|
|
809
957
|
default : str or datetime.date, optional
|
|
810
958
|
Default value
|
|
959
|
+
name : str, optional
|
|
960
|
+
Name of the column / parameter
|
|
811
961
|
|
|
812
962
|
Returns
|
|
813
963
|
-------
|
|
814
|
-
|
|
964
|
+
SQLString
|
|
815
965
|
|
|
816
966
|
"""
|
|
817
|
-
|
|
967
|
+
out = SQLString('DATE' + _modifiers(nullable=nullable, default=default))
|
|
968
|
+
out.name = name
|
|
969
|
+
return out
|
|
818
970
|
|
|
819
971
|
|
|
820
972
|
def TIME(
|
|
@@ -822,7 +974,8 @@ def TIME(
|
|
|
822
974
|
*,
|
|
823
975
|
nullable: bool = True,
|
|
824
976
|
default: Optional[Union[str, datetime.timedelta]] = None,
|
|
825
|
-
|
|
977
|
+
name: Optional[str] = None,
|
|
978
|
+
) -> SQLString:
|
|
826
979
|
"""
|
|
827
980
|
TIME type specification.
|
|
828
981
|
|
|
@@ -834,14 +987,18 @@ def TIME(
|
|
|
834
987
|
Can the value be NULL?
|
|
835
988
|
default : str or datetime.timedelta, optional
|
|
836
989
|
Default value
|
|
990
|
+
name : str, optional
|
|
991
|
+
Name of the column / parameter
|
|
837
992
|
|
|
838
993
|
Returns
|
|
839
994
|
-------
|
|
840
|
-
|
|
995
|
+
SQLString
|
|
841
996
|
|
|
842
997
|
"""
|
|
843
998
|
out = f'TIME({int(precision)})' if precision else 'TIME'
|
|
844
|
-
|
|
999
|
+
out = SQLString(out + _modifiers(nullable=nullable, default=default))
|
|
1000
|
+
out.name = name
|
|
1001
|
+
return out
|
|
845
1002
|
|
|
846
1003
|
|
|
847
1004
|
def DATETIME(
|
|
@@ -849,7 +1006,8 @@ def DATETIME(
|
|
|
849
1006
|
*,
|
|
850
1007
|
nullable: bool = True,
|
|
851
1008
|
default: Optional[Union[str, datetime.datetime]] = None,
|
|
852
|
-
|
|
1009
|
+
name: Optional[str] = None,
|
|
1010
|
+
) -> SQLString:
|
|
853
1011
|
"""
|
|
854
1012
|
DATETIME type specification.
|
|
855
1013
|
|
|
@@ -861,14 +1019,18 @@ def DATETIME(
|
|
|
861
1019
|
Can the value be NULL?
|
|
862
1020
|
default : str or datetime.datetime, optional
|
|
863
1021
|
Default value
|
|
1022
|
+
name : str, optional
|
|
1023
|
+
Name of the column / parameter
|
|
864
1024
|
|
|
865
1025
|
Returns
|
|
866
1026
|
-------
|
|
867
|
-
|
|
1027
|
+
SQLString
|
|
868
1028
|
|
|
869
1029
|
"""
|
|
870
1030
|
out = f'DATETIME({int(precision)})' if precision else 'DATETIME'
|
|
871
|
-
|
|
1031
|
+
out = SQLString(out + _modifiers(nullable=nullable, default=default))
|
|
1032
|
+
out.name = name
|
|
1033
|
+
return out
|
|
872
1034
|
|
|
873
1035
|
|
|
874
1036
|
def TIMESTAMP(
|
|
@@ -876,7 +1038,8 @@ def TIMESTAMP(
|
|
|
876
1038
|
*,
|
|
877
1039
|
nullable: bool = True,
|
|
878
1040
|
default: Optional[Union[str, datetime.datetime]] = None,
|
|
879
|
-
|
|
1041
|
+
name: Optional[str] = None,
|
|
1042
|
+
) -> SQLString:
|
|
880
1043
|
"""
|
|
881
1044
|
TIMESTAMP type specification.
|
|
882
1045
|
|
|
@@ -888,17 +1051,26 @@ def TIMESTAMP(
|
|
|
888
1051
|
Can the value be NULL?
|
|
889
1052
|
default : str or datetime.datetime, optional
|
|
890
1053
|
Default value
|
|
1054
|
+
name : str, optional
|
|
1055
|
+
Name of the column / parameter
|
|
891
1056
|
|
|
892
1057
|
Returns
|
|
893
1058
|
-------
|
|
894
|
-
|
|
1059
|
+
SQLString
|
|
895
1060
|
|
|
896
1061
|
"""
|
|
897
1062
|
out = f'TIMESTAMP({int(precision)})' if precision else 'TIMESTAMP'
|
|
898
|
-
|
|
1063
|
+
out = SQLString(out + _modifiers(nullable=nullable, default=default))
|
|
1064
|
+
out.name = name
|
|
1065
|
+
return out
|
|
899
1066
|
|
|
900
1067
|
|
|
901
|
-
def YEAR(
|
|
1068
|
+
def YEAR(
|
|
1069
|
+
*,
|
|
1070
|
+
nullable: bool = True,
|
|
1071
|
+
default: Optional[int] = None,
|
|
1072
|
+
name: Optional[str] = None,
|
|
1073
|
+
) -> SQLString:
|
|
902
1074
|
"""
|
|
903
1075
|
YEAR type specification.
|
|
904
1076
|
|
|
@@ -908,13 +1080,17 @@ def YEAR(*, nullable: bool = True, default: Optional[int] = None) -> str:
|
|
|
908
1080
|
Can the value be NULL?
|
|
909
1081
|
default : int, optional
|
|
910
1082
|
Default value
|
|
1083
|
+
name : str, optional
|
|
1084
|
+
Name of the column / parameter
|
|
911
1085
|
|
|
912
1086
|
Returns
|
|
913
1087
|
-------
|
|
914
|
-
|
|
1088
|
+
SQLString
|
|
915
1089
|
|
|
916
1090
|
"""
|
|
917
|
-
|
|
1091
|
+
out = SQLString('YEAR' + _modifiers(nullable=nullable, default=default))
|
|
1092
|
+
out.name = name
|
|
1093
|
+
return out
|
|
918
1094
|
|
|
919
1095
|
|
|
920
1096
|
def CHAR(
|
|
@@ -924,7 +1100,8 @@ def CHAR(
|
|
|
924
1100
|
default: Optional[str] = None,
|
|
925
1101
|
collate: Optional[str] = None,
|
|
926
1102
|
charset: Optional[str] = None,
|
|
927
|
-
|
|
1103
|
+
name: Optional[str] = None,
|
|
1104
|
+
) -> SQLString:
|
|
928
1105
|
"""
|
|
929
1106
|
CHAR type specification.
|
|
930
1107
|
|
|
@@ -940,17 +1117,23 @@ def CHAR(
|
|
|
940
1117
|
Collation
|
|
941
1118
|
charset : str, optional
|
|
942
1119
|
Character set
|
|
1120
|
+
name : str, optional
|
|
1121
|
+
Name of the column / parameter
|
|
943
1122
|
|
|
944
1123
|
Returns
|
|
945
1124
|
-------
|
|
946
|
-
|
|
1125
|
+
SQLString
|
|
947
1126
|
|
|
948
1127
|
"""
|
|
949
1128
|
out = f'CHAR({int(length)})' if length else 'CHAR'
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
1129
|
+
out = SQLString(
|
|
1130
|
+
out + _modifiers(
|
|
1131
|
+
nullable=nullable, default=default,
|
|
1132
|
+
collate=collate, charset=charset,
|
|
1133
|
+
),
|
|
953
1134
|
)
|
|
1135
|
+
out.name = name
|
|
1136
|
+
return out
|
|
954
1137
|
|
|
955
1138
|
|
|
956
1139
|
def VARCHAR(
|
|
@@ -960,7 +1143,8 @@ def VARCHAR(
|
|
|
960
1143
|
default: Optional[str] = None,
|
|
961
1144
|
collate: Optional[str] = None,
|
|
962
1145
|
charset: Optional[str] = None,
|
|
963
|
-
|
|
1146
|
+
name: Optional[str] = None,
|
|
1147
|
+
) -> SQLString:
|
|
964
1148
|
"""
|
|
965
1149
|
VARCHAR type specification.
|
|
966
1150
|
|
|
@@ -976,17 +1160,23 @@ def VARCHAR(
|
|
|
976
1160
|
Collation
|
|
977
1161
|
charset : str, optional
|
|
978
1162
|
Character set
|
|
1163
|
+
name : str, optional
|
|
1164
|
+
Name of the column / parameter
|
|
979
1165
|
|
|
980
1166
|
Returns
|
|
981
1167
|
-------
|
|
982
|
-
|
|
1168
|
+
SQLString
|
|
983
1169
|
|
|
984
1170
|
"""
|
|
985
1171
|
out = f'VARCHAR({int(length)})' if length else 'VARCHAR'
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
1172
|
+
out = SQLString(
|
|
1173
|
+
out + _modifiers(
|
|
1174
|
+
nullable=nullable, default=default,
|
|
1175
|
+
collate=collate, charset=charset,
|
|
1176
|
+
),
|
|
989
1177
|
)
|
|
1178
|
+
out.name = name
|
|
1179
|
+
return out
|
|
990
1180
|
|
|
991
1181
|
|
|
992
1182
|
def LONGTEXT(
|
|
@@ -996,7 +1186,8 @@ def LONGTEXT(
|
|
|
996
1186
|
default: Optional[str] = None,
|
|
997
1187
|
collate: Optional[str] = None,
|
|
998
1188
|
charset: Optional[str] = None,
|
|
999
|
-
|
|
1189
|
+
name: Optional[str] = None,
|
|
1190
|
+
) -> SQLString:
|
|
1000
1191
|
"""
|
|
1001
1192
|
LONGTEXT type specification.
|
|
1002
1193
|
|
|
@@ -1012,17 +1203,23 @@ def LONGTEXT(
|
|
|
1012
1203
|
Collation
|
|
1013
1204
|
charset : str, optional
|
|
1014
1205
|
Character set
|
|
1206
|
+
name : str, optional
|
|
1207
|
+
Name of the column / parameter
|
|
1015
1208
|
|
|
1016
1209
|
Returns
|
|
1017
1210
|
-------
|
|
1018
|
-
|
|
1211
|
+
SQLString
|
|
1019
1212
|
|
|
1020
1213
|
"""
|
|
1021
1214
|
out = f'LONGTEXT({int(length)})' if length else 'LONGTEXT'
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1215
|
+
out = SQLString(
|
|
1216
|
+
out + _modifiers(
|
|
1217
|
+
nullable=nullable, default=default,
|
|
1218
|
+
collate=collate, charset=charset,
|
|
1219
|
+
),
|
|
1025
1220
|
)
|
|
1221
|
+
out.name = name
|
|
1222
|
+
return out
|
|
1026
1223
|
|
|
1027
1224
|
|
|
1028
1225
|
def MEDIUMTEXT(
|
|
@@ -1032,7 +1229,8 @@ def MEDIUMTEXT(
|
|
|
1032
1229
|
default: Optional[str] = None,
|
|
1033
1230
|
collate: Optional[str] = None,
|
|
1034
1231
|
charset: Optional[str] = None,
|
|
1035
|
-
|
|
1232
|
+
name: Optional[str] = None,
|
|
1233
|
+
) -> SQLString:
|
|
1036
1234
|
"""
|
|
1037
1235
|
MEDIUMTEXT type specification.
|
|
1038
1236
|
|
|
@@ -1048,17 +1246,23 @@ def MEDIUMTEXT(
|
|
|
1048
1246
|
Collation
|
|
1049
1247
|
charset : str, optional
|
|
1050
1248
|
Character set
|
|
1249
|
+
name : str, optional
|
|
1250
|
+
Name of the column / parameter
|
|
1051
1251
|
|
|
1052
1252
|
Returns
|
|
1053
1253
|
-------
|
|
1054
|
-
|
|
1254
|
+
SQLString
|
|
1055
1255
|
|
|
1056
1256
|
"""
|
|
1057
1257
|
out = f'MEDIUMTEXT({int(length)})' if length else 'MEDIUMTEXT'
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1258
|
+
out = SQLString(
|
|
1259
|
+
out + _modifiers(
|
|
1260
|
+
nullable=nullable, default=default,
|
|
1261
|
+
collate=collate, charset=charset,
|
|
1262
|
+
),
|
|
1061
1263
|
)
|
|
1264
|
+
out.name = name
|
|
1265
|
+
return out
|
|
1062
1266
|
|
|
1063
1267
|
|
|
1064
1268
|
def TEXT(
|
|
@@ -1068,7 +1272,8 @@ def TEXT(
|
|
|
1068
1272
|
default: Optional[str] = None,
|
|
1069
1273
|
collate: Optional[str] = None,
|
|
1070
1274
|
charset: Optional[str] = None,
|
|
1071
|
-
|
|
1275
|
+
name: Optional[str] = None,
|
|
1276
|
+
) -> SQLString:
|
|
1072
1277
|
"""
|
|
1073
1278
|
TEXT type specification.
|
|
1074
1279
|
|
|
@@ -1084,17 +1289,23 @@ def TEXT(
|
|
|
1084
1289
|
Collation
|
|
1085
1290
|
charset : str, optional
|
|
1086
1291
|
Character set
|
|
1292
|
+
name : str, optional
|
|
1293
|
+
Name of the column / parameter
|
|
1087
1294
|
|
|
1088
1295
|
Returns
|
|
1089
1296
|
-------
|
|
1090
|
-
|
|
1297
|
+
SQLString
|
|
1091
1298
|
|
|
1092
1299
|
"""
|
|
1093
1300
|
out = f'TEXT({int(length)})' if length else 'TEXT'
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1301
|
+
out = SQLString(
|
|
1302
|
+
out + _modifiers(
|
|
1303
|
+
nullable=nullable, default=default,
|
|
1304
|
+
collate=collate, charset=charset,
|
|
1305
|
+
),
|
|
1097
1306
|
)
|
|
1307
|
+
out.name = name
|
|
1308
|
+
return out
|
|
1098
1309
|
|
|
1099
1310
|
|
|
1100
1311
|
def TINYTEXT(
|
|
@@ -1104,7 +1315,8 @@ def TINYTEXT(
|
|
|
1104
1315
|
default: Optional[str] = None,
|
|
1105
1316
|
collate: Optional[str] = None,
|
|
1106
1317
|
charset: Optional[str] = None,
|
|
1107
|
-
|
|
1318
|
+
name: Optional[str] = None,
|
|
1319
|
+
) -> SQLString:
|
|
1108
1320
|
"""
|
|
1109
1321
|
TINYTEXT type specification.
|
|
1110
1322
|
|
|
@@ -1120,17 +1332,23 @@ def TINYTEXT(
|
|
|
1120
1332
|
Collation
|
|
1121
1333
|
charset : str, optional
|
|
1122
1334
|
Character set
|
|
1335
|
+
name : str, optional
|
|
1336
|
+
Name of the column / parameter
|
|
1123
1337
|
|
|
1124
1338
|
Returns
|
|
1125
1339
|
-------
|
|
1126
|
-
|
|
1340
|
+
SQLString
|
|
1127
1341
|
|
|
1128
1342
|
"""
|
|
1129
1343
|
out = f'TINYTEXT({int(length)})' if length else 'TINYTEXT'
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1344
|
+
out = SQLString(
|
|
1345
|
+
out + _modifiers(
|
|
1346
|
+
nullable=nullable, default=default,
|
|
1347
|
+
collate=collate, charset=charset,
|
|
1348
|
+
),
|
|
1133
1349
|
)
|
|
1350
|
+
out.name = name
|
|
1351
|
+
return out
|
|
1134
1352
|
|
|
1135
1353
|
|
|
1136
1354
|
def BINARY(
|
|
@@ -1139,7 +1357,8 @@ def BINARY(
|
|
|
1139
1357
|
nullable: bool = True,
|
|
1140
1358
|
default: Optional[bytes] = None,
|
|
1141
1359
|
collate: Optional[str] = None,
|
|
1142
|
-
|
|
1360
|
+
name: Optional[str] = None,
|
|
1361
|
+
) -> SQLString:
|
|
1143
1362
|
"""
|
|
1144
1363
|
BINARY type specification.
|
|
1145
1364
|
|
|
@@ -1153,16 +1372,22 @@ def BINARY(
|
|
|
1153
1372
|
Default value
|
|
1154
1373
|
collate : str, optional
|
|
1155
1374
|
Collation
|
|
1375
|
+
name : str, optional
|
|
1376
|
+
Name of the column / parameter
|
|
1156
1377
|
|
|
1157
1378
|
Returns
|
|
1158
1379
|
-------
|
|
1159
|
-
|
|
1380
|
+
SQLString
|
|
1160
1381
|
|
|
1161
1382
|
"""
|
|
1162
1383
|
out = f'BINARY({int(length)})' if length else 'BINARY'
|
|
1163
|
-
|
|
1164
|
-
|
|
1384
|
+
out = SQLString(
|
|
1385
|
+
out + _modifiers(
|
|
1386
|
+
nullable=nullable, default=default, collate=collate,
|
|
1387
|
+
),
|
|
1165
1388
|
)
|
|
1389
|
+
out.name = name
|
|
1390
|
+
return out
|
|
1166
1391
|
|
|
1167
1392
|
|
|
1168
1393
|
def VARBINARY(
|
|
@@ -1171,7 +1396,8 @@ def VARBINARY(
|
|
|
1171
1396
|
nullable: bool = True,
|
|
1172
1397
|
default: Optional[bytes] = None,
|
|
1173
1398
|
collate: Optional[str] = None,
|
|
1174
|
-
|
|
1399
|
+
name: Optional[str] = None,
|
|
1400
|
+
) -> SQLString:
|
|
1175
1401
|
"""
|
|
1176
1402
|
VARBINARY type specification.
|
|
1177
1403
|
|
|
@@ -1185,16 +1411,22 @@ def VARBINARY(
|
|
|
1185
1411
|
Default value
|
|
1186
1412
|
collate : str, optional
|
|
1187
1413
|
Collation
|
|
1414
|
+
name : str, optional
|
|
1415
|
+
Name of the column / parameter
|
|
1188
1416
|
|
|
1189
1417
|
Returns
|
|
1190
1418
|
-------
|
|
1191
|
-
|
|
1419
|
+
SQLString
|
|
1192
1420
|
|
|
1193
1421
|
"""
|
|
1194
1422
|
out = f'VARBINARY({int(length)})' if length else 'VARBINARY'
|
|
1195
|
-
|
|
1196
|
-
|
|
1423
|
+
out = SQLString(
|
|
1424
|
+
out + _modifiers(
|
|
1425
|
+
nullable=nullable, default=default, collate=collate,
|
|
1426
|
+
),
|
|
1197
1427
|
)
|
|
1428
|
+
out.name = name
|
|
1429
|
+
return out
|
|
1198
1430
|
|
|
1199
1431
|
|
|
1200
1432
|
def LONGBLOB(
|
|
@@ -1203,7 +1435,8 @@ def LONGBLOB(
|
|
|
1203
1435
|
nullable: bool = True,
|
|
1204
1436
|
default: Optional[bytes] = None,
|
|
1205
1437
|
collate: Optional[str] = None,
|
|
1206
|
-
|
|
1438
|
+
name: Optional[str] = None,
|
|
1439
|
+
) -> SQLString:
|
|
1207
1440
|
"""
|
|
1208
1441
|
LONGBLOB type specification.
|
|
1209
1442
|
|
|
@@ -1217,16 +1450,22 @@ def LONGBLOB(
|
|
|
1217
1450
|
Default value
|
|
1218
1451
|
collate : str, optional
|
|
1219
1452
|
Collation
|
|
1453
|
+
name : str, optional
|
|
1454
|
+
Name of the column / parameter
|
|
1220
1455
|
|
|
1221
1456
|
Returns
|
|
1222
1457
|
-------
|
|
1223
|
-
|
|
1458
|
+
SQLString
|
|
1224
1459
|
|
|
1225
1460
|
"""
|
|
1226
1461
|
out = f'LONGBLOB({int(length)})' if length else 'LONGBLOB'
|
|
1227
|
-
|
|
1228
|
-
|
|
1462
|
+
out = SQLString(
|
|
1463
|
+
out + _modifiers(
|
|
1464
|
+
nullable=nullable, default=default, collate=collate,
|
|
1465
|
+
),
|
|
1229
1466
|
)
|
|
1467
|
+
out.name = name
|
|
1468
|
+
return out
|
|
1230
1469
|
|
|
1231
1470
|
|
|
1232
1471
|
def MEDIUMBLOB(
|
|
@@ -1235,7 +1474,8 @@ def MEDIUMBLOB(
|
|
|
1235
1474
|
nullable: bool = True,
|
|
1236
1475
|
default: Optional[bytes] = None,
|
|
1237
1476
|
collate: Optional[str] = None,
|
|
1238
|
-
|
|
1477
|
+
name: Optional[str] = None,
|
|
1478
|
+
) -> SQLString:
|
|
1239
1479
|
"""
|
|
1240
1480
|
MEDIUMBLOB type specification.
|
|
1241
1481
|
|
|
@@ -1249,16 +1489,22 @@ def MEDIUMBLOB(
|
|
|
1249
1489
|
Default value
|
|
1250
1490
|
collate : str, optional
|
|
1251
1491
|
Collation
|
|
1492
|
+
name : str, optional
|
|
1493
|
+
Name of the column / parameter
|
|
1252
1494
|
|
|
1253
1495
|
Returns
|
|
1254
1496
|
-------
|
|
1255
|
-
|
|
1497
|
+
SQLString
|
|
1256
1498
|
|
|
1257
1499
|
"""
|
|
1258
1500
|
out = f'MEDIUMBLOB({int(length)})' if length else 'MEDIUMBLOB'
|
|
1259
|
-
|
|
1260
|
-
|
|
1501
|
+
out = SQLString(
|
|
1502
|
+
out + _modifiers(
|
|
1503
|
+
nullable=nullable, default=default, collate=collate,
|
|
1504
|
+
),
|
|
1261
1505
|
)
|
|
1506
|
+
out.name = name
|
|
1507
|
+
return out
|
|
1262
1508
|
|
|
1263
1509
|
|
|
1264
1510
|
def BLOB(
|
|
@@ -1267,7 +1513,8 @@ def BLOB(
|
|
|
1267
1513
|
nullable: bool = True,
|
|
1268
1514
|
default: Optional[bytes] = None,
|
|
1269
1515
|
collate: Optional[str] = None,
|
|
1270
|
-
|
|
1516
|
+
name: Optional[str] = None,
|
|
1517
|
+
) -> SQLString:
|
|
1271
1518
|
"""
|
|
1272
1519
|
BLOB type specification.
|
|
1273
1520
|
|
|
@@ -1281,16 +1528,22 @@ def BLOB(
|
|
|
1281
1528
|
Default value
|
|
1282
1529
|
collate : str, optional
|
|
1283
1530
|
Collation
|
|
1531
|
+
name : str, optional
|
|
1532
|
+
Name of the column / parameter
|
|
1284
1533
|
|
|
1285
1534
|
Returns
|
|
1286
1535
|
-------
|
|
1287
|
-
|
|
1536
|
+
SQLString
|
|
1288
1537
|
|
|
1289
1538
|
"""
|
|
1290
1539
|
out = f'BLOB({int(length)})' if length else 'BLOB'
|
|
1291
|
-
|
|
1292
|
-
|
|
1540
|
+
out = SQLString(
|
|
1541
|
+
out + _modifiers(
|
|
1542
|
+
nullable=nullable, default=default, collate=collate,
|
|
1543
|
+
),
|
|
1293
1544
|
)
|
|
1545
|
+
out.name = name
|
|
1546
|
+
return out
|
|
1294
1547
|
|
|
1295
1548
|
|
|
1296
1549
|
def TINYBLOB(
|
|
@@ -1299,7 +1552,8 @@ def TINYBLOB(
|
|
|
1299
1552
|
nullable: bool = True,
|
|
1300
1553
|
default: Optional[bytes] = None,
|
|
1301
1554
|
collate: Optional[str] = None,
|
|
1302
|
-
|
|
1555
|
+
name: Optional[str] = None,
|
|
1556
|
+
) -> SQLString:
|
|
1303
1557
|
"""
|
|
1304
1558
|
TINYBLOB type specification.
|
|
1305
1559
|
|
|
@@ -1313,16 +1567,22 @@ def TINYBLOB(
|
|
|
1313
1567
|
Default value
|
|
1314
1568
|
collate : str, optional
|
|
1315
1569
|
Collation
|
|
1570
|
+
name : str, optional
|
|
1571
|
+
Name of the column / parameter
|
|
1316
1572
|
|
|
1317
1573
|
Returns
|
|
1318
1574
|
-------
|
|
1319
|
-
|
|
1575
|
+
SQLString
|
|
1320
1576
|
|
|
1321
1577
|
"""
|
|
1322
1578
|
out = f'TINYBLOB({int(length)})' if length else 'TINYBLOB'
|
|
1323
|
-
|
|
1324
|
-
|
|
1579
|
+
out = SQLString(
|
|
1580
|
+
out + _modifiers(
|
|
1581
|
+
nullable=nullable, default=default, collate=collate,
|
|
1582
|
+
),
|
|
1325
1583
|
)
|
|
1584
|
+
out.name = name
|
|
1585
|
+
return out
|
|
1326
1586
|
|
|
1327
1587
|
|
|
1328
1588
|
def JSON(
|
|
@@ -1332,7 +1592,8 @@ def JSON(
|
|
|
1332
1592
|
default: Optional[str] = None,
|
|
1333
1593
|
collate: Optional[str] = None,
|
|
1334
1594
|
charset: Optional[str] = None,
|
|
1335
|
-
|
|
1595
|
+
name: Optional[str] = None,
|
|
1596
|
+
) -> SQLString:
|
|
1336
1597
|
"""
|
|
1337
1598
|
JSON type specification.
|
|
1338
1599
|
|
|
@@ -1348,20 +1609,31 @@ def JSON(
|
|
|
1348
1609
|
Collation
|
|
1349
1610
|
charset : str, optional
|
|
1350
1611
|
Character set
|
|
1612
|
+
name : str, optional
|
|
1613
|
+
Name of the column / parameter
|
|
1351
1614
|
|
|
1352
1615
|
Returns
|
|
1353
1616
|
-------
|
|
1354
|
-
|
|
1617
|
+
SQLString
|
|
1355
1618
|
|
|
1356
1619
|
"""
|
|
1357
1620
|
out = f'JSON({int(length)})' if length else 'JSON'
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1621
|
+
out = SQLString(
|
|
1622
|
+
out + _modifiers(
|
|
1623
|
+
nullable=nullable, default=default,
|
|
1624
|
+
collate=collate, charset=charset,
|
|
1625
|
+
),
|
|
1361
1626
|
)
|
|
1627
|
+
out.name = name
|
|
1628
|
+
return out
|
|
1362
1629
|
|
|
1363
1630
|
|
|
1364
|
-
def GEOGRAPHYPOINT(
|
|
1631
|
+
def GEOGRAPHYPOINT(
|
|
1632
|
+
*,
|
|
1633
|
+
nullable: bool = True,
|
|
1634
|
+
default: Optional[str] = None,
|
|
1635
|
+
name: Optional[str] = None,
|
|
1636
|
+
) -> SQLString:
|
|
1365
1637
|
"""
|
|
1366
1638
|
GEOGRAPHYPOINT type specification.
|
|
1367
1639
|
|
|
@@ -1371,16 +1643,25 @@ def GEOGRAPHYPOINT(*, nullable: bool = True, default: Optional[str] = None) -> s
|
|
|
1371
1643
|
Can the value be NULL?
|
|
1372
1644
|
default : str, optional
|
|
1373
1645
|
Default value
|
|
1646
|
+
name : str, optional
|
|
1647
|
+
Name of the column / parameter
|
|
1374
1648
|
|
|
1375
1649
|
Returns
|
|
1376
1650
|
-------
|
|
1377
|
-
|
|
1651
|
+
SQLString
|
|
1378
1652
|
|
|
1379
1653
|
"""
|
|
1380
|
-
|
|
1654
|
+
out = SQLString('GEOGRAPHYPOINT' + _modifiers(nullable=nullable, default=default))
|
|
1655
|
+
out.name = name
|
|
1656
|
+
return out
|
|
1381
1657
|
|
|
1382
1658
|
|
|
1383
|
-
def GEOGRAPHY(
|
|
1659
|
+
def GEOGRAPHY(
|
|
1660
|
+
*,
|
|
1661
|
+
nullable: bool = True,
|
|
1662
|
+
default: Optional[str] = None,
|
|
1663
|
+
name: Optional[str] = None,
|
|
1664
|
+
) -> SQLString:
|
|
1384
1665
|
"""
|
|
1385
1666
|
GEOGRAPHYPOINT type specification.
|
|
1386
1667
|
|
|
@@ -1396,51 +1677,117 @@ def GEOGRAPHY(*, nullable: bool = True, default: Optional[str] = None) -> str:
|
|
|
1396
1677
|
str
|
|
1397
1678
|
|
|
1398
1679
|
"""
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1680
|
+
out = SQLString('GEOGRAPHY' + _modifiers(nullable=nullable, default=default))
|
|
1681
|
+
out.name = name
|
|
1682
|
+
return out
|
|
1683
|
+
|
|
1684
|
+
|
|
1685
|
+
# def RECORD(
|
|
1686
|
+
# *args: Tuple[str, DataType],
|
|
1687
|
+
# nullable: bool = True,
|
|
1688
|
+
# name: Optional[str] = None,
|
|
1689
|
+
# ) -> SQLString:
|
|
1690
|
+
# """
|
|
1691
|
+
# RECORD type specification.
|
|
1692
|
+
#
|
|
1693
|
+
# Parameters
|
|
1694
|
+
# ----------
|
|
1695
|
+
# *args : Tuple[str, DataType]
|
|
1696
|
+
# Field specifications
|
|
1697
|
+
# nullable : bool, optional
|
|
1698
|
+
# Can the value be NULL?
|
|
1699
|
+
# name : str, optional
|
|
1700
|
+
# Name of the column / parameter
|
|
1701
|
+
#
|
|
1702
|
+
# Returns
|
|
1703
|
+
# -------
|
|
1704
|
+
# SQLString
|
|
1705
|
+
#
|
|
1706
|
+
# """
|
|
1707
|
+
# assert len(args) > 0
|
|
1708
|
+
# fields = []
|
|
1709
|
+
# for name, value in args:
|
|
1710
|
+
# if callable(value):
|
|
1711
|
+
# fields.append(f'{escape_name(name)} {value()}')
|
|
1712
|
+
# else:
|
|
1713
|
+
# fields.append(f'{escape_name(name)} {value}')
|
|
1714
|
+
# out = SQLString(f'RECORD({", ".join(fields)})' + _modifiers(nullable=nullable))
|
|
1715
|
+
# out.name = name
|
|
1716
|
+
# return out
|
|
1717
|
+
|
|
1718
|
+
|
|
1719
|
+
# def ARRAY(
|
|
1720
|
+
# dtype: DataType,
|
|
1721
|
+
# nullable: bool = True,
|
|
1722
|
+
# name: Optional[str] = None,
|
|
1723
|
+
# ) -> SQLString:
|
|
1724
|
+
# """
|
|
1725
|
+
# ARRAY type specification.
|
|
1726
|
+
#
|
|
1727
|
+
# Parameters
|
|
1728
|
+
# ----------
|
|
1729
|
+
# dtype : DataType
|
|
1730
|
+
# The data type of the array elements
|
|
1731
|
+
# nullable : bool, optional
|
|
1732
|
+
# Can the value be NULL?
|
|
1733
|
+
# name : str, optional
|
|
1734
|
+
# Name of the column / parameter
|
|
1735
|
+
#
|
|
1736
|
+
# Returns
|
|
1737
|
+
# -------
|
|
1738
|
+
# SQLString
|
|
1739
|
+
#
|
|
1740
|
+
# """
|
|
1741
|
+
# if callable(dtype):
|
|
1742
|
+
# dtype = dtype()
|
|
1743
|
+
# out = SQLString(f'ARRAY({dtype})' + _modifiers(nullable=nullable))
|
|
1744
|
+
# out.name = name
|
|
1745
|
+
# return out
|
|
1746
|
+
|
|
1747
|
+
|
|
1748
|
+
# F32 = 'F32'
|
|
1749
|
+
# F64 = 'F64'
|
|
1750
|
+
# I8 = 'I8'
|
|
1751
|
+
# I16 = 'I16'
|
|
1752
|
+
# I32 = 'I32'
|
|
1753
|
+
# I64 = 'I64'
|
|
1754
|
+
|
|
1755
|
+
|
|
1756
|
+
# def VECTOR(
|
|
1757
|
+
# length: int,
|
|
1758
|
+
# element_type: str = F32,
|
|
1759
|
+
# *,
|
|
1760
|
+
# nullable: bool = True,
|
|
1761
|
+
# default: Optional[bytes] = None,
|
|
1762
|
+
# name: Optional[str] = None,
|
|
1763
|
+
# ) -> SQLString:
|
|
1764
|
+
# """
|
|
1765
|
+
# VECTOR type specification.
|
|
1766
|
+
#
|
|
1767
|
+
# Parameters
|
|
1768
|
+
# ----------
|
|
1769
|
+
# n : int
|
|
1770
|
+
# Number of elements in vector
|
|
1771
|
+
# element_type : str, optional
|
|
1772
|
+
# Type of the elements in the vector:
|
|
1773
|
+
# F32, F64, I8, I16, I32, I64
|
|
1774
|
+
# nullable : bool, optional
|
|
1775
|
+
# Can the value be NULL?
|
|
1776
|
+
# default : str, optional
|
|
1777
|
+
# Default value
|
|
1778
|
+
# name : str, optional
|
|
1779
|
+
# Name of the column / parameter
|
|
1780
|
+
#
|
|
1781
|
+
# Returns
|
|
1782
|
+
# -------
|
|
1783
|
+
# SQLString
|
|
1784
|
+
#
|
|
1785
|
+
# """
|
|
1786
|
+
# out = f'VECTOR({int(length)}, {element_type})'
|
|
1787
|
+
# out = SQLString(
|
|
1788
|
+
# out + _modifiers(
|
|
1789
|
+
# nullable=nullable, default=default,
|
|
1790
|
+
# ),
|
|
1791
|
+
# )
|
|
1792
|
+
# out.name = name
|
|
1793
|
+
# return out
|