Qore SqlUtil Module Reference 1.9
Loading...
Searching...
No Matches
SqlUtil.qm.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
4/* SqlUtil.qm Copyright (C) 2013 - 2023 Qore Technologies, s.r.o.
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23*/
24
25// minimum required Qore version
26
27// requires the Util module
28
29// requires the DataProvider module
30
31// don't use "$" signs for variables and class members, assume local variable scope
32
33// require type definitions everywhere
34
35// enable all warnings
36
37
38// version history is included below in the docs
39
2319namespace SqlUtil {
2321 public hashdecl GenericColumnInfo {
2327 softint size;
2329 softint scale;
2335 *string comment;
2337 bool notnull = False;
2339 hash<string, hash> driver;
2342 };
2343
2345 public hashdecl OperatorInfo {
2346 string op;
2347 auto arg;
2348 };
2349
2351 public hashdecl ColumnOperatorInfo {
2352 string cop;
2353 auto column;
2354 auto arg;
2355 };
2356
2358 public hashdecl InsertOperatorInfo {
2359 string _iop;
2360 any arg;
2361 };
2362
2364 public hashdecl UpdateOperatorInfo {
2365 string uop;
2366 auto arg;
2367 *hash nest;
2368 };
2369
2371 public hashdecl JoinOperatorInfo {
2372 string jop;
2373 auto table;
2374 *string alias;
2375 *hash jcols;
2376 *hash cond;
2377 *string ta;
2378 *hash<auto> opt;
2379 };
2380
2385
2387 *TimeZone data_timezone;
2388
2390 *TimeZone db_timezone;
2391
2394
2396 *softbool mandatory;
2397
2399
2401 *softint maxlen;
2402 };
2403
2405
2407 public hashdecl SqlCommandInfo {
2409 string sql;
2410
2412 list<auto> args;
2413 };
2414
2420
2422 const DB_FUNCTIONS = "functions";
2424 const DB_MVIEWS = "materialized views";
2426 const DB_PACKAGES = "packages";
2428 const DB_PROCEDURES = "procedures";
2430 const DB_SEQUENCES = "sequences";
2432 const DB_TABLES = "tables";
2434 const DB_TYPES = "named types";
2436 const DB_VIEWS = "views";
2438 const DB_SYNONYMS = "synonyms";
2440
2441 /* @defgroup SqlTypeConstants SQL Type Constants
2442 These constants can be used for the \c "qore_type" values when creating columns to specify additional SQL column types
2443 */
2446 const VARCHAR = "string";
2447
2449 const NUMERIC = "number";
2450
2452 const CHAR = "char";
2453
2455 const BLOB = "blob";
2456
2458 const CLOB = "clob";
2460
2466 const SZ_NONE = 0;
2467
2469 const SZ_MAND = 1;
2470
2472 const SZ_OPT = 2;
2473
2475 const SZ_NUM = 3;
2477
2483
2485 const COP_AS = "as";
2486
2488
2490 const COP_CAST = "cast";
2491
2493
2495 const COP_PREPEND = "prepend";
2496
2498
2500 const COP_APPEND = "append";
2501
2503
2505 const COP_VALUE = "value";
2506
2508
2510 const COP_UPPER = "upper";
2511
2513
2515 const COP_LOWER = "lower";
2516
2518
2520 const COP_DISTINCT = "distinct";
2521
2523
2525 const COP_MIN = "min";
2526
2528
2530 const COP_MAX = "max";
2531
2533
2535 const COP_AVG = "avg";
2536
2538
2540 const COP_SUM = "sum";
2541
2543
2545 const COP_COUNT = "count";
2546
2548
2550 const COP_OVER = "over";
2551
2553
2555 const COP_MINUS = "minus";
2556
2558
2560 const COP_PLUS = "plus";
2561
2563
2565 const COP_DIVIDE = "divide";
2566
2568
2570 const COP_MULTIPLY = "multiply";
2571
2573
2575 const COP_YEAR = "year";
2576
2578
2580 const COP_YEAR_MONTH = "year_month";
2581
2583
2585 const COP_YEAR_DAY = "year_day";
2586
2588
2590 const COP_YEAR_HOUR = "year_hour";
2591
2593
2595 const COP_SEQ = "seq";
2596
2598
2600 const COP_SEQ_CURRVAL = "seq_currval";
2601
2603
2605 const COP_COALESCE = "coalesce";
2606
2608
2610 const COP_SUBSTR = "substr";
2611
2613
2617 const COP_LENGTH = "length";
2618
2620
2626 const COP_TRUNC_DATE = "truncate_date";
2627
2629
2633 const COP_CUME_DIST = "cume_dist";
2634
2636
2640 const COP_DENSE_RANK = "dense_rank";
2641
2643
2647 const COP_FIRST_VALUE = "first_value";
2648
2650
2654 const COP_LAST_VALUE = "last_value";
2655
2657
2661 const COP_NTILE = "ntile";
2662
2664
2668 const COP_PERCENT_RANK = "percent_rank";
2669
2671
2675 const COP_RANK = "rank";
2676
2678
2682 const COP_ROW_NUMBER = "row_number";
2683
2685 public hashdecl QueryInfo {
2687 object table;
2688
2690 *hash<auto> query_hash;
2691
2693 *hash<auto> query_options;
2694
2696 *hash<string, AbstractTable> join_map;
2697
2699 *hash<string, bool> subquery_column_map;
2700
2703
2705 *hash<auto> expression_map;
2706
2709
2712
2714 list<auto> args;
2715 };
2716
2718 const DefaultCopMap = ...;
2719
2721
2764
2772 hash<ColumnOperatorInfo> make_cop(string cop, auto column, auto arg);
2773
2774
2776
2788 hash<ColumnOperatorInfo> cop_as(auto column, string arg);
2789
2790
2792
2806 hash<ColumnOperatorInfo> cop_cast(auto column, string arg, auto arg1, auto arg2);
2807
2808
2810
2820 hash<ColumnOperatorInfo> cop_prepend(auto column, string arg);
2821
2822
2824
2834 hash<ColumnOperatorInfo> cop_append(auto column, string arg);
2835
2836
2838
2966 hash<ColumnOperatorInfo> cop_value(auto arg);
2967
2968
2970
2979 hash<ColumnOperatorInfo> cop_upper(auto column);
2980
2981
2983
2992 hash<ColumnOperatorInfo> cop_lower(auto column);
2993
2994
2996
3005 hash<ColumnOperatorInfo> cop_distinct(auto column);
3006
3007
3009
3018 hash<ColumnOperatorInfo> cop_min(auto column);
3019
3020
3022
3031 hash<ColumnOperatorInfo> cop_max(auto column);
3032
3033
3035
3044 hash<ColumnOperatorInfo> cop_avg(auto column);
3045
3046
3048
3057 hash<ColumnOperatorInfo> cop_sum(auto column);
3058
3059
3061
3068 hash<ColumnOperatorInfo> cop_count(auto column = '');
3069
3070
3072
3079 hash<ColumnOperatorInfo> cop_over(auto column, *string partitionby, *string orderby);
3080
3081
3083
3093 hash<ColumnOperatorInfo> cop_minus(auto column1, auto column2);
3094
3095
3097
3107 hash<ColumnOperatorInfo> cop_plus(auto column1, auto column2);
3108
3109
3111
3121 hash<ColumnOperatorInfo> cop_divide(auto column1, auto column2);
3122
3123
3125
3135 hash<ColumnOperatorInfo> cop_multiply(auto column1, auto column2);
3136
3137
3139
3148 hash<ColumnOperatorInfo> cop_year(auto column);
3149
3150
3152
3161 hash<ColumnOperatorInfo> cop_year_month(auto column);
3162
3163
3165
3174 hash<ColumnOperatorInfo> cop_year_day(auto column);
3175
3176
3178
3187 hash<ColumnOperatorInfo> cop_year_hour(auto column);
3188
3189
3191
3201 hash<ColumnOperatorInfo> cop_seq(string seq, *string as);
3202
3203
3205
3215 hash<ColumnOperatorInfo> cop_seq_currval(string seq, *string as);
3216
3217
3219
3231 hash<ColumnOperatorInfo> cop_coalesce(auto col1, auto col2);
3232
3233
3235
3246 hash<ColumnOperatorInfo> cop_substr(auto column, int start, *int count);
3247
3248
3250
3261 hash<ColumnOperatorInfo> cop_length(auto column);
3262
3263
3265
3279 hash<ColumnOperatorInfo> cop_trunc_date(auto column, string mask);
3280
3281
3282
3284
3312 hash<ColumnOperatorInfo> cop_cume_dist();
3313
3314
3316
3344 hash<ColumnOperatorInfo> cop_dense_rank();
3345
3346
3348
3376 hash<ColumnOperatorInfo> cop_first_value(any column);
3377
3378
3380
3408 hash<ColumnOperatorInfo> cop_last_value(any column);
3409
3410
3412
3442 hash<ColumnOperatorInfo> cop_ntile(int value);
3443
3444
3446
3474 hash<ColumnOperatorInfo> cop_percent_rank();
3475
3476
3478
3506 hash<ColumnOperatorInfo> cop_rank();
3507
3508
3510
3538 hash<ColumnOperatorInfo> cop_row_number();
3539
3540
3542
3594 const DT_YEAR = "Y";
3595
3597 const DT_MONTH = "M";
3598
3600 const DT_DAY = "D";
3601
3603 const DT_HOUR = "H";
3604
3606 const DT_MINUTE = "m";
3607
3609 const DT_SECOND = "S";
3610
3611 // let's simulate and enum here'
3612 const DT_ALL_VALUES = ( DT_YEAR, DT_MONTH, DT_DAY, DT_HOUR, DT_MINUTE, DT_SECOND );
3614
3620 const DefaultUopMap = ...;
3621
3623
3646
3654 hash<UpdateOperatorInfo> make_uop(string uop, auto arg, *hash<UpdateOperatorInfo> nest);
3655
3656
3658
3668 hash<UpdateOperatorInfo> uop_prepend(string arg, *hash<UpdateOperatorInfo> nest);
3669
3670
3672
3682 hash<UpdateOperatorInfo> uop_append(string arg, *hash<UpdateOperatorInfo> nest);
3683
3684
3686
3695 hash<UpdateOperatorInfo> uop_upper(*hash<UpdateOperatorInfo> nest);
3696
3697
3699
3708 hash<UpdateOperatorInfo> uop_lower(*hash<UpdateOperatorInfo> nest);
3709
3710
3712
3723 hash<UpdateOperatorInfo> uop_substr(int start, *int count, *hash<UpdateOperatorInfo> nest);
3724
3725
3727
3737 hash<UpdateOperatorInfo> uop_plus(auto arg, *hash<UpdateOperatorInfo> nest);
3738
3739
3741
3751 hash<UpdateOperatorInfo> uop_minus(auto arg, *hash<UpdateOperatorInfo> nest);
3752
3753
3755
3765 hash<UpdateOperatorInfo> uop_multiply(auto arg, *hash<UpdateOperatorInfo> nest);
3766
3767
3769
3779 hash<UpdateOperatorInfo> uop_divide(auto arg, *hash<UpdateOperatorInfo> nest);
3780
3781
3783
3792 hash<UpdateOperatorInfo> uop_seq(string seq);
3793
3794
3796
3805 hash<UpdateOperatorInfo> uop_seq_currval(string seq);
3806
3808
3816
3818 const JOP_INNER = "inner";
3819
3821
3823 const JOP_LEFT = "left";
3824
3826
3828 const JOP_RIGHT = "right";
3829
3831 const JopMap = {
3832 JOP_INNER: "inner",
3833 JOP_LEFT: "left outer",
3834 JOP_RIGHT: "right outer",
3835 };
3837
3848
3851 hash<string, hash<JoinOperatorInfo>> make_jop(string jop, AbstractTable table, *string alias, *hash jcols, *hash cond, *string ta, *hash<auto> opt);
3852
3853
3855
3859 hash<string, hash<JoinOperatorInfo>> make_jop(string jop, string table_name, *string alias, *hash jcols, *hash cond, *string ta, *hash<auto> opt);
3860
3861
3863
3882 hash<string, hash<JoinOperatorInfo>> join_inner(AbstractTable table, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
3883
3884
3886
3905 hash<string, hash<JoinOperatorInfo>> join_inner(Table table, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
3906
3907
3909
3928 hash<string, hash<JoinOperatorInfo>> join_inner(string table_name, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
3929
3930
3932
3954 hash<string, hash<JoinOperatorInfo>> join_inner(string ta, AbstractTable table, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
3955
3956
3958
3978 hash<string, hash<JoinOperatorInfo>> join_inner(string ta, Table table, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
3979
3980
3982
4004 hash<string, hash<JoinOperatorInfo>> join_inner_alias(string ta, string table_name, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
4005
4006
4008
4027 hash<string, hash<JoinOperatorInfo>> join_left(AbstractTable table, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
4028
4029
4031
4050 hash<string, hash<JoinOperatorInfo>> join_left(Table table, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
4051
4052
4054
4075 hash<string, hash<JoinOperatorInfo>> join_left(string table_name, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
4076
4077
4079
4099 hash<string, hash<JoinOperatorInfo>> join_left(string ta, AbstractTable table, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
4100
4101
4103
4123 hash<string, hash<JoinOperatorInfo>> join_left(string ta, Table table, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
4124
4125
4127
4149 hash<string, hash<JoinOperatorInfo>> join_left_alias(string ta, string table_name, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
4150
4151
4153
4172 hash<string, hash<JoinOperatorInfo>> join_right(AbstractTable table, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
4173
4174
4176
4195 hash<string, hash<JoinOperatorInfo>> join_right(Table table, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
4196
4197
4199
4220 hash<string, hash<JoinOperatorInfo>> join_right(string table_name, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
4221
4222
4224
4244 hash<string, hash<JoinOperatorInfo>> join_right(string ta, AbstractTable table, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
4245
4246
4248
4268 hash<string, hash<JoinOperatorInfo>> join_right(string ta, Table table, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
4269
4270
4272
4294 hash<string, hash<JoinOperatorInfo>> join_right_alias(string ta, string table_name, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
4295
4297
4303
4305 const OP_LIKE = "like";
4306
4308
4310 const OP_LT = "<";
4311
4313
4315 const OP_LE = "<=";
4316
4318
4320 const OP_GT = ">";
4321
4323
4325 const OP_GE = ">=";
4326
4328
4330 const OP_NE = "!=";
4331
4333
4335 const OP_EQ = "=";
4336
4338
4340 const OP_CLT = "C<";
4341
4343
4345 const OP_CLE = "C<=";
4346
4348
4350 const OP_CGT = "C>";
4351
4353
4355 const OP_CGE = "C>=";
4356
4358
4360 const OP_CNE = "C!=";
4361
4363
4365 const OP_CEQ = "C=";
4366
4368
4370 const OP_BETWEEN = "between";
4371
4373
4375 const OP_IN = "in";
4376
4378
4380 const OP_NOT = "not";
4381
4383
4385 const OP_SUBSTR = "substr";
4386
4388
4390 const OP_OR = "or";
4391
4393
4395 const OP_IN_SELECT = "in_select";
4396
4399 // first the "AND" and "OR" "operators"
4400 DP_OP_AND: {
4401 "exp": AbstractDataProvider::GenericExpressions{DP_OP_AND},
4402 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4403 return "("
4404 + (foldl $1 + " and " + $2,
4405 (map info.table.getExpressionArg(\info, role, $1, AbstractDataProviderTypeMap."bool"), args))
4406 + ")";
4407 },
4408 },
4409 DP_OP_OR: {
4410 "exp": AbstractDataProvider::GenericExpressions{DP_OP_OR},
4411 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4412 return "("
4413 + (foldl $1 + " or " + $2,
4414 (map info.table.getExpressionArg(\info, role, $1, AbstractDataProviderTypeMap."bool"), args))
4415 + ")";
4416 },
4417 },
4418 OP_LIKE: {
4419 "exp": <DataProviderExpressionInfo>{
4420 "type": DET_Operator,
4421 "label": "like",
4422 "name": "like",
4423 "desc": "The value to bind as the 'like' value (ex: '%some string%')",
4424 "symbol": "like",
4425 "args": (
4426 DataProviderSignatureStringType,
4427 DataProviderSignatureStringValueType,
4428 ),
4429 "return_type": AbstractDataProviderTypeMap."bool",
4430 },
4431 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4432 return sprintf("%s like %s",
4433 info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."string"),
4434 info.table.getExpressionArg(\info, role, args[1], AbstractDataProviderTypeMap."string"));
4435 },
4436 },
4437 OP_LT: {
4438 "exp": AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_LT},
4439 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4440 return sprintf("%s < %s",
4441 info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."any"),
4442 info.table.getExpressionArg(\info, role, args[1], AbstractDataProviderTypeMap."any"));
4443 },
4444 },
4445 OP_LE: {
4446 "exp": AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_LE},
4447 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4448 return sprintf("%s <= %s",
4449 info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."any"),
4450 info.table.getExpressionArg(\info, role, args[1], AbstractDataProviderTypeMap."any"));
4451 },
4452 },
4453 OP_GT: {
4454 "exp": AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_GT},
4455 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4456 return sprintf("%s > %s",
4457 info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."any"),
4458 info.table.getExpressionArg(\info, role, args[1], AbstractDataProviderTypeMap."any"));
4459 },
4460 },
4461 OP_GE: {
4462 "exp": AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_GE},
4463 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4464 return sprintf("%s >= %s",
4465 info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."any"),
4466 info.table.getExpressionArg(\info, role, args[1], AbstractDataProviderTypeMap."any"));
4467 },
4468 },
4469 OP_NE: {
4470 "exp": AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_NE},
4471 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4472 bool null0 = (args[0] === NULL || !exists args[0]);
4473 bool null1 = (args[1] === NULL || !exists args[1]);
4474 if (null0 && null1) {
4475 return "1 = 0";
4476 }
4477 if (null0) {
4478 return sprintf("%s is not null",
4479 info.table.getExpressionArg(\info, role, args[1], AbstractDataProviderTypeMap."any"));
4480 }
4481 if (null1) {
4482 return sprintf("%s is not null",
4483 info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."any"));
4484 }
4485 string exp0 = info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."any");
4486 string exp1 = info.table.getExpressionArg(\info, role, args[1], AbstractDataProviderTypeMap."any");
4487 return sprintf("%s != %s", exp0, exp1);
4488 },
4489 },
4490 OP_EQ: {
4491 "exp": AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_EQ},
4492 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4493 bool null0 = (args[0] === NULL || !exists args[0]);
4494 bool null1 = (args[1] === NULL || !exists args[1]);
4495 if (null0 && null1) {
4496 return "1 = 1";
4497 }
4498 if (null0) {
4499 return sprintf("%s is null",
4500 info.table.getExpressionArg(\info, role, args[1], AbstractDataProviderTypeMap."any"));
4501 }
4502 if (null1) {
4503 return sprintf("%s is null",
4504 info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."any"));
4505 }
4506 string exp0 = info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."any");
4507 string exp1 = info.table.getExpressionArg(\info, role, args[1], AbstractDataProviderTypeMap."any");
4508 return sprintf("%s = %s", exp0, exp1);
4509 },
4510 },
4511 OP_BETWEEN: {
4512 "exp": AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_BETWEEN},
4513 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4514 return sprintf("%s between %s and %s",
4515 info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."any"),
4516 info.table.getExpressionArg(\info, role, args[1], AbstractDataProviderTypeMap."any"),
4517 info.table.getExpressionArg(\info, role, args[2], AbstractDataProviderTypeMap."any"));
4518 },
4519 },
4520 OP_IN: {
4521 "exp": AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_IN},
4522 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4523 string exp0 = info.table.getExpressionArg(\info, role, shift args, AbstractDataProviderTypeMap."any");
4524 *string ins = (foldl $1 + "," + $2, (map info.table.getExpressionArg(\info, role, $1,
4525 AbstractDataProviderTypeMap."any"), args));
4526 return exists ins ? sprintf("%s in (%s)", exp0, ins) : "1 != 1";
4527 },
4528 },
4529 OP_NOT: {
4530 "exp": AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_NOT},
4531 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4532 return sprintf("not (%s)", info.table.getExpressionArg(\info, role, args[0],
4533 AbstractDataProviderTypeMap."bool"));
4534 },
4535 },
4536 OP_SUBSTR: {
4537 "exp": <DataProviderExpressionInfo>{
4538 "type": DET_Operator,
4539 "label": "substr",
4540 "name": "substr",
4541 "desc": "returns a substring from a string; args: string, int start char, [int length]",
4542 "symbol": "substr",
4543 "args": (
4544 DataProviderSignatureStringType,
4545 DataProviderSignatureIntValueType,
4546 DataProviderSignatureOptionalIntValueType,
4547 ),
4548 "return_type": AbstractDataProviderTypeMap."string",
4549 },
4550 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4551 string exp0 = info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."string");
4552 string exp1 = info.table.getExpressionArg(\info, role, args[1], AbstractDataProviderTypeMap."int");
4553 if (!exists args[2]) {
4554 return sprintf("substring(%s from %s)", exp0, exp1);
4555 }
4556 return sprintf("substring(%s from %s for %s)", exp0, exp1,
4557 info.table.getExpressionArg(\info, role, args[2], AbstractDataProviderTypeMap."int"));
4558 },
4559 },
4560 OP_IN_SELECT: {
4561 "exp": <DataProviderExpressionInfo>{
4562 "type": DET_Operator,
4563 "label": "in_select",
4564 "name": "in_select",
4565 "desc": "check if a value is in a sub-select; args: value, table name for the subselect, subselect "
4566 "query hash",
4567 "symbol": "in_select",
4568 "args": (
4569 DataProviderSignatureAnyType, # any value, expression, or field reference
4570 DataProviderSignatureStringValueType, # table name
4571 DataProviderSignatureHashValueType, # query hash
4572 ),
4573 "return_type": AbstractDataProviderTypeMap."bool",
4574 },
4575 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4576 string exp0 = info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."any");
4577 object subtable = info.table.getSubtableFromString(args[1], info.query_options);
4578 list<auto> subargs;
4579 string subsql = subtable.getSelectSql(args[2], \subargs);
4580 args += subargs;
4581 return sprintf("%s in (%s)", exp0, subsql);
4582 },
4583 },
4584 COP_AS: {
4585 "exp": <DataProviderExpressionInfo>{
4586 "type": DET_Operator,
4587 "label": "as",
4588 "name": "as",
4589 "desc": "aliases a result; args: expression or value, string label",
4590 "symbol": "as",
4591 "role": ER_Field,
4592 "args": (
4593 DataProviderSignatureAnyType,
4594 DataProviderSignatureStringValueType,
4595 ),
4596 "return_type": AbstractDataProviderTypeMap."any",
4597 },
4598 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4599 string exp = info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."any");
4600 string arg = args[1];
4601 info.pseudo_column_map{arg} = exp;
4602 return sprintf("%s as %s", exp, info.table.getColumnSqlName(arg));
4603 },
4604 },
4605 COP_PREPEND: {
4606 "exp": <DataProviderExpressionInfo>{
4607 "type": DET_Operator,
4608 "label": COP_PREPEND,
4609 "name": COP_PREPEND,
4610 "desc": "prepends a string to another string; args: string to be prepended, string to prepend to the "
4611 "first string",
4612 "symbol": COP_PREPEND,
4613 "args": (
4614 DataProviderSignatureStringType,
4615 DataProviderSignatureStringType,
4616 ),
4617 "return_type": AbstractDataProviderTypeMap."string",
4618 },
4619 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4620 string exp0 = info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."string");
4621 string exp1 = info.table.getExpressionArg(\info, role, args[1], AbstractDataProviderTypeMap."string");
4622 return sprintf("%s || %s", exp1, exp0);
4623 },
4624 },
4625 COP_APPEND: {
4626 "exp": <DataProviderExpressionInfo>{
4627 "type": DET_Operator,
4628 "label": COP_APPEND,
4629 "name": COP_APPEND,
4630 "desc": "appends or catenates a string to another string; args: string to be appended, string to "
4631 "append or concatenate to the first string",
4632 "symbol": COP_APPEND,
4633 "args": (
4634 DataProviderSignatureStringType,
4635 DataProviderSignatureStringType,
4636 ),
4637 "return_type": AbstractDataProviderTypeMap."string",
4638 },
4639 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4640 string exp0 = info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."string");
4641 string exp1 = info.table.getExpressionArg(\info, role, args[1], AbstractDataProviderTypeMap."string");
4642 return sprintf("%s || %s", exp0, exp1);
4643 },
4644 },
4645 COP_UPPER: {
4646 "exp": <DataProviderExpressionInfo>{
4647 "type": DET_Operator,
4648 "label": COP_UPPER,
4649 "name": COP_UPPER,
4650 "desc": "converts a string to all upper case; arg: string",
4651 "symbol": COP_UPPER,
4652 "args": (
4653 DataProviderSignatureStringType,
4654 ),
4655 "return_type": AbstractDataProviderTypeMap."string",
4656 },
4657 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4658 return sprintf("upper(%s)", info.table.getExpressionArg(\info, role, args[0],
4659 AbstractDataProviderTypeMap."string"));
4660 },
4661 },
4662 COP_LOWER: {
4663 "exp": <DataProviderExpressionInfo>{
4664 "type": DET_Operator,
4665 "label": COP_LOWER,
4666 "name": COP_LOWER,
4667 "desc": "converts a string to all lower case; arg: string",
4668 "symbol": COP_LOWER,
4669 "args": (
4670 DataProviderSignatureStringType,
4671 ),
4672 "return_type": AbstractDataProviderTypeMap."string",
4673 },
4674 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4675 return sprintf("lower(%s)", info.table.getExpressionArg(\info, role, args[0],
4676 AbstractDataProviderTypeMap."string"));
4677 },
4678 },
4679 COP_DISTINCT: {
4680 "exp": <DataProviderExpressionInfo>{
4681 "type": DET_Operator,
4682 "label": COP_DISTINCT,
4683 "name": COP_DISTINCT,
4684 "desc": "indicates that only records with distinct values of the given field should be returned",
4685 "symbol": COP_DISTINCT,
4686 "role": ER_Field,
4687 "args": (
4688 DataProviderSignatureAnyType,
4689 ),
4690 "return_type": AbstractDataProviderTypeMap."any",
4691 },
4692 "code": string sub (reference<hash<QueryInfo>> info, int role, *list<auto> args) {
4693 return sprintf("distinct %s", info.table.getExpressionArg(\info, role, args[0],
4694 AbstractDataProviderTypeMap."any"));
4695 },
4696 },
4697 COP_MIN: {
4698 "exp": <DataProviderExpressionInfo>{
4699 "type": DET_Operator,
4700 "label": COP_MIN,
4701 "name": COP_MIN,
4702 "desc": "Returns the minimum value in the group",
4703 "symbol": COP_MIN,
4704 "role": ER_Field,
4705 "args": (
4706 DataProviderSignatureAnyType,
4707 ),
4708 "return_type": AbstractDataProviderTypeMap."any",
4709 },
4710 "code": string sub (reference<hash<QueryInfo>> info, int role, *list<auto> args) {
4711 return sprintf("min(%s)", info.table.getExpressionArg(\info, role, args[0],
4712 AbstractDataProviderTypeMap."any"));
4713 },
4714 "group": True,
4715 },
4716 COP_MAX: {
4717 "exp": <DataProviderExpressionInfo>{
4718 "type": DET_Operator,
4719 "label": COP_MAX,
4720 "name": COP_MAX,
4721 "desc": "Returns the maximum value in the group",
4722 "symbol": COP_MAX,
4723 "role": ER_Field,
4724 "args": (
4725 DataProviderSignatureAnyType,
4726 ),
4727 "return_type": AbstractDataProviderTypeMap."any",
4728 },
4729 "code": string sub (reference<hash<QueryInfo>> info, int role, *list<auto> args) {
4730 return sprintf("max(%s)", info.table.getExpressionArg(\info, role, args[0],
4731 AbstractDataProviderTypeMap."any"));
4732 },
4733 "group": True,
4734 },
4735 COP_AVG: {
4736 "exp": <DataProviderExpressionInfo>{
4737 "type": DET_Operator,
4738 "label": COP_AVG,
4739 "name": COP_AVG,
4740 "desc": "Returns the average of the given values in the group",
4741 "symbol": COP_AVG,
4742 "role": ER_Field,
4743 "args": (
4744 DataProviderSignatureAnyType,
4745 ),
4746 "return_type": AbstractDataProviderTypeMap."any",
4747 },
4748 "code": string sub (reference<hash<QueryInfo>> info, int role, *list<auto> args) {
4749 return sprintf("avg(%s)", info.table.getExpressionArg(\info, role, args[0],
4750 AbstractDataProviderTypeMap."any"));
4751 },
4752 "group": True,
4753 },
4754 COP_SUM: {
4755 "exp": <DataProviderExpressionInfo>{
4756 "type": DET_Operator,
4757 "label": COP_SUM,
4758 "name": COP_SUM,
4759 "desc": "Returns the sum of the given values",
4760 "symbol": COP_SUM,
4761 "role": ER_Field,
4762 "args": (
4763 DataProviderSignatureAnyType,
4764 ),
4765 "return_type": AbstractDataProviderTypeMap."any",
4766 },
4767 "code": string sub (reference<hash<QueryInfo>> info, int role, *list<auto> args) {
4768 return sprintf("sum(%s)", info.table.getExpressionArg(\info, role, args[0],
4769 AbstractDataProviderTypeMap."any"));
4770 },
4771 "group": True,
4772 },
4773 COP_COUNT: {
4774 "exp": <DataProviderExpressionInfo>{
4775 "type": DET_Operator,
4776 "label": COP_COUNT,
4777 "name": COP_COUNT,
4778 "desc": "Count the number of rows in the group",
4779 "symbol": COP_COUNT,
4780 "role": ER_Field,
4781 "args": (
4782 DataProviderSignatureAnyType,
4783 ),
4784 "return_type": AbstractDataProviderTypeMap."int",
4785 },
4786 "code": string sub (reference<hash<QueryInfo>> info, int role, *list<auto> args) {
4787 if (exists args[0] && args[0] != NULL) {
4788 return sprintf("count(%s)", info.table.getExpressionArg(\info, role, args[0],
4789 AbstractDataProviderTypeMap."any"));
4790 }
4791 return "count(1)";
4792 },
4793 },
4794 COP_MINUS: {
4795 "exp": <DataProviderExpressionInfo>{
4796 "type": DET_Operator,
4797 "label": COP_MINUS,
4798 "name": COP_MINUS,
4799 "desc": "Subtracts one number from another",
4800 "symbol": COP_MINUS,
4801 "args": (
4802 DataProviderSignatureAnyType,
4803 DataProviderSignatureAnyType,
4804 ),
4805 "return_type": AbstractDataProviderTypeMap."any",
4806 },
4807 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4808 string exp0 = info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."any");
4809 string exp1 = info.table.getExpressionArg(\info, role, args[1], AbstractDataProviderTypeMap."any");
4810 return sprintf("%s - %s", exp0, exp1);
4811 },
4812 },
4813 COP_PLUS: {
4814 "exp": <DataProviderExpressionInfo>{
4815 "type": DET_Operator,
4816 "label": COP_PLUS,
4817 "name": COP_PLUS,
4818 "desc": "Adds two numbers",
4819 "symbol": COP_PLUS,
4820 "args": (
4821 DataProviderSignatureAnyType,
4822 DataProviderSignatureAnyType,
4823 ),
4824 "return_type": AbstractDataProviderTypeMap."any",
4825 },
4826 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4827 string exp0 = info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."any");
4828 string exp1 = info.table.getExpressionArg(\info, role, args[1], AbstractDataProviderTypeMap."any");
4829 return sprintf("%s + %s", exp0, exp1);
4830 },
4831 },
4832 COP_DIVIDE: {
4833 "exp": <DataProviderExpressionInfo>{
4834 "type": DET_Operator,
4835 "label": COP_DIVIDE,
4836 "name": COP_DIVIDE,
4837 "desc": "Divides one number by another",
4838 "symbol": COP_DIVIDE,
4839 "args": (
4840 DataProviderSignatureAnyType,
4841 DataProviderSignatureAnyType,
4842 ),
4843 "return_type": AbstractDataProviderTypeMap."any",
4844 },
4845 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4846 string exp0 = info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."any");
4847 string exp1 = info.table.getExpressionArg(\info, role, args[1], AbstractDataProviderTypeMap."any");
4848 return sprintf("%s / %s", exp0, exp1);
4849 },
4850 },
4851 COP_MULTIPLY: {
4852 "exp": <DataProviderExpressionInfo>{
4853 "type": DET_Operator,
4854 "label": COP_MULTIPLY,
4855 "name": COP_MULTIPLY,
4856 "desc": "Multiplies two numbers",
4857 "symbol": COP_MULTIPLY,
4858 "args": (
4859 DataProviderSignatureAnyType,
4860 DataProviderSignatureAnyType,
4861 ),
4862 "return_type": AbstractDataProviderTypeMap."any",
4863 },
4864 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4865 string exp0 = info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."any");
4866 string exp1 = info.table.getExpressionArg(\info, role, args[1], AbstractDataProviderTypeMap."any");
4867 return sprintf("%s * %s", exp0, exp1);
4868 },
4869 },
4870 COP_COALESCE: {
4871 "exp": <DataProviderExpressionInfo>{
4872 "type": DET_Operator,
4873 "label": COP_COALESCE,
4874 "name": COP_COALESCE,
4875 "desc": "Returns the value of the first expression with a value",
4876 "symbol": COP_COALESCE,
4877 "args": (
4878 DataProviderSignatureAnyType,
4879 ),
4880 "varargs": True,
4881 "return_type": AbstractDataProviderTypeMap."any",
4882 },
4883 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4884 return sprintf("coalesce(%s)", (foldl $1 + "," + $2,
4885 (map info.table.getExpressionArg(\info, role, $1, AbstractDataProviderTypeMap."any"), args)));
4886 }
4887 },
4888 COP_LENGTH: {
4889 "exp": <DataProviderExpressionInfo>{
4890 "type": DET_Operator,
4891 "label": COP_LENGTH,
4892 "name": COP_LENGTH,
4893 "desc": "Returns the length of the argument",
4894 "symbol": COP_LENGTH,
4895 "args": (
4896 DataProviderSignatureAnyType,
4897 ),
4898 "return_type": AbstractDataProviderTypeMap."int",
4899 },
4900 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4901 return sprintf("length(%s)", info.table.getExpressionArg(\info, role, args[0],
4902 AbstractDataProviderTypeMap."any"));
4903 },
4904 },
4905 COP_SEQ: {
4906 "exp": <DataProviderExpressionInfo>{
4907 "type": DET_Operator,
4908 "label": COP_SEQ,
4909 "name": COP_SEQ,
4910 "desc": "returns the next value in the given sequence; args: sequence name",
4911 "symbol": COP_SEQ,
4912 "args": (
4913 DataProviderSignatureStringValueType,
4914 ),
4915 "return_type": AbstractDataProviderTypeMap."int",
4916 },
4917 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4918 throw "SEQUENCE-ERROR", sprintf("cannot select sequence %y because this database does not support "
4919 "sequences", args[0]);
4920 }
4921 },
4923 "exp": <DataProviderExpressionInfo>{
4924 "type": DET_Operator,
4925 "label": COP_SEQ_CURRVAL,
4926 "name": COP_SEQ_CURRVAL,
4927 "desc": "returns the current value in the given sequence; args: sequence name",
4928 "symbol": COP_SEQ_CURRVAL,
4929 "args": (
4930 DataProviderSignatureStringValueType,
4931 ),
4932 "return_type": AbstractDataProviderTypeMap."int",
4933 },
4934 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4935 throw "SEQUENCE-ERROR", sprintf("cannot select the current value of sequence %y because this "
4936 "database does not support sequences", args[0]);
4937 }
4938 },
4939 COP_OVER: {
4940 "exp": <DataProviderExpressionInfo>{
4941 "type": DET_Operator,
4942 "label": COP_OVER,
4943 "name": COP_OVER,
4944 "desc": "returns the output of the SQL window given by the arguments; args: *string partiion by, "
4945 "*string order by",
4946 "symbol": COP_OVER,
4947 "args": (
4948 DataProviderSignatureFieldType,
4949 DataProviderSignatureOptionalStringValueType,
4950 DataProviderSignatureOptionalStringValueType,
4951 ),
4952 "role": ER_Field,
4953 "return_type": AbstractDataProviderTypeMap."any",
4954 },
4955 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4956 string column_name = args[0];
4957 *string partitionby = args[1];
4958 *string orderby = args[2];
4959 if (!exists partitionby && exists orderby) {
4960 throw "OVER-ERROR", "Argument 2 (partition by) must be given in case of usage of argument 3 "
4961 "(order by)";
4962 }
4963 string sql = column_name + " over (";
4964 Columns cols;
4965 if (exists partitionby) {
4966 if (!info.pseudo_column_map{partitionby}) {
4967 cols = info.table.describe();
4968 if (!exists cols{partitionby}) {
4969 throw "OVER-ERROR", sprintf("Argument 2 (partition by) %y is not an alias or an "
4970 "accessible column", partitionby);
4971 }
4972 }
4973 sql += sprintf("partition by %s", partitionby);
4974 }
4975 if (exists orderby) {
4976 if (!info.pseudo_column_map{orderby}) {
4977 if (!cols) {
4978 cols = info.table.describe();
4979 if (!exists cols{orderby}) {
4980 throw "OVER-ERROR", sprintf("Argument 3 (order by) %y is not an alias or an "
4981 "accessible column", orderby);
4982 }
4983 }
4984 }
4985 sql += sprintf(" order by %s", orderby);
4986 }
4987 sql += ")";
4988 return sql;
4989 }
4990 },
4992 "exp": <DataProviderExpressionInfo>{
4993 "type": DET_Operator,
4994 "label": COP_DENSE_RANK,
4995 "name": COP_DENSE_RANK,
4996 "desc": "Returns the rank of a row in an ordered group of rows as a number",
4997 "symbol": COP_DENSE_RANK,
4998 "args": (),
4999 "role": ER_Field,
5000 "return_type": AbstractDataProviderTypeMap."any",
5001 },
5002 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
5003 return "dense_rank()";
5004 },
5005 ),
5007 "exp": <DataProviderExpressionInfo>{
5008 "type": DET_Operator,
5009 "label": COP_FIRST_VALUE,
5010 "name": COP_FIRST_VALUE,
5011 "desc": "Returns the first value in an ordered group of rows",
5012 "symbol": COP_FIRST_VALUE,
5013 "args": (
5014 DataProviderSignatureFieldType,
5015 ),
5016 "role": ER_Field,
5017 "return_type": AbstractDataProviderTypeMap."any",
5018 },
5019 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
5020 return sprintf("first_value(%s)", args[0]);
5021 },
5022 ),
5024 "exp": <DataProviderExpressionInfo>{
5025 "type": DET_Operator,
5026 "label": COP_LAST_VALUE,
5027 "name": COP_LAST_VALUE,
5028 "desc": "Returns the last value in an ordered group of rows",
5029 "symbol": COP_LAST_VALUE,
5030 "args": (
5031 DataProviderSignatureFieldType,
5032 ),
5033 "role": ER_Field,
5034 "return_type": AbstractDataProviderTypeMap."any",
5035 },
5036 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
5037 return sprintf("last_value(%s)", args[0]);
5038 },
5039 ),
5040 COP_NTILE: (
5041 "exp": <DataProviderExpressionInfo>{
5042 "type": DET_Operator,
5043 "label": COP_NTILE,
5044 "name": COP_NTILE,
5045 "desc": "Returns the group number of an ordered group of rows",
5046 "symbol": COP_NTILE,
5047 "args": (
5048 DataProviderSignatureIntValueType,
5049 ),
5050 "role": ER_Field,
5051 "return_type": AbstractDataProviderTypeMap."int",
5052 },
5053 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
5054 return sprintf("ntile(%d)", args[0]);
5055 },
5056 ),
5058 "exp": <DataProviderExpressionInfo>{
5059 "type": DET_Operator,
5060 "label": COP_PERCENT_RANK,
5061 "name": COP_PERCENT_RANK,
5062 "desc": "Returns the percent rank of a row in an ordered group of rows",
5063 "symbol": COP_PERCENT_RANK,
5064 "args": (),
5065 "role": ER_Field,
5066 "return_type": AbstractDataProviderTypeMap."int",
5067 },
5068 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
5069 return "percent_rank()";
5070 },
5071 ),
5072 COP_RANK: (
5073 "exp": <DataProviderExpressionInfo>{
5074 "type": DET_Operator,
5075 "label": COP_PERCENT_RANK,
5076 "name": COP_PERCENT_RANK,
5077 "desc": "Returns the row number of a row in an ordered group of rows",
5078 "symbol": COP_PERCENT_RANK,
5079 "args": (),
5080 "role": ER_Field,
5081 "return_type": AbstractDataProviderTypeMap."int",
5082 },
5083 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
5084 return "rank()";
5085 },
5086 ),
5088 "exp": <DataProviderExpressionInfo>{
5089 "type": DET_Operator,
5090 "label": COP_ROW_NUMBER,
5091 "name": COP_ROW_NUMBER,
5092 "desc": "Returns the row number of a result set",
5093 "symbol": COP_ROW_NUMBER,
5094 "args": (),
5095 "role": ER_Field,
5096 "return_type": AbstractDataProviderTypeMap."int",
5097 },
5098 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
5099 return "row_number()";
5100 },
5101 ),
5102 };
5103
5106 OP_LIKE: {
5107 "code": string sub (reference<hash<QueryInfo>> info, string cn, auto arg) {
5108 info.args += arg;
5109 return sprintf("%s like %v", cn);
5110 },
5111 "name": "like",
5112 "args": (DataProviderSignatureStringType, DataProviderSignatureStringValueType),
5113 "return_type": AbstractDataProviderTypeMap."bool",
5114 "desc": "The value to bind as the 'like' value (ex: '%some string%')",
5115 },
5116 OP_LT: AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_LT} + (
5117 "code": string sub (reference<hash<QueryInfo>> info, string cn, auto arg) {
5118 info.args += arg;
5119 return sprintf("%s < %v", cn);
5120 },
5121 ),
5122 OP_LE: AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_LE} + (
5123 "code": string sub (reference<hash<QueryInfo>> info, string cn, auto arg) {
5124 info.args += arg;
5125 return sprintf("%s <= %v", cn);
5126 },
5127 ),
5128 OP_GT: AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_GT} + (
5129 "code": string sub (reference<hash<QueryInfo>> info, string cn, auto arg) {
5130 info.args += arg;
5131 return sprintf("%s > %v", cn);
5132 },
5133 ),
5134 OP_GE: AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_GE} + (
5135 "code": string sub (reference<hash<QueryInfo>> info, string cn, auto arg) {
5136 info.args += arg;
5137 return sprintf("%s >= %v", cn);
5138 },
5139 ),
5140 OP_NE: AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_NE} + (
5141 "code": string sub (reference<hash<QueryInfo>> info, string cn, auto arg) {
5142 if (arg === NULL || !exists arg)
5143 return sprintf("%s is not null", cn);
5144 info.args += arg;
5145 return sprintf("(%s != %v or %s is null)", cn, cn);
5146 },
5147 ),
5148 OP_EQ: AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_EQ} + (
5149 "code": string sub (reference<hash<QueryInfo>> info, string cn, auto arg) {
5150 if (arg === NULL || !exists arg)
5151 return sprintf("%s is null", cn);
5152 info.args += arg;
5153 return sprintf("%s = %v", cn);
5154 },
5155 ),
5156 OP_BETWEEN: AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_BETWEEN} + (
5157 "code": string sub (reference<hash<QueryInfo>> info, string cn, auto arg) {
5158 info.args += arg[0];
5159 info.args += arg[1];
5160 return sprintf("%s between %v and %v", cn);
5161 },
5162 ),
5163 OP_IN: AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_IN} + (
5164 "code": string sub (reference<hash<QueryInfo>> info, string cn, auto arg) {
5165 *string ins = (foldl $1 + "," + $2, (map info.table.getSqlValue($1), arg));
5166 return exists ins ? sprintf("%s in (%s)", cn, ins) : "1 != 1";
5167 },
5168 ),
5169 OP_IN_SELECT: {
5170 "code": string sub (reference<hash<QueryInfo>> info, string cn, auto arg,
5171 *hash<auto> opt) {
5172 object subtable;
5173 if (arg.table.typeCode() == NT_STRING) {
5174 subtable = info.table.getSubtableFromString(arg.table, opt);
5175 } else {
5176 subtable = arg.table;
5177 }
5178
5179 list<auto> subargs;
5180 string subsql = subtable.getSelectSql(arg.select_hash, \subargs);
5181 info.args += subargs;
5182 return sprintf("%s in (%s)", cn, subsql);
5183 },
5184 "withopt": True,
5185 },
5186 OP_NOT: AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_NOT} + (
5187 "recursive": True,
5188 "code": string sub (reference<hash<QueryInfo>> info, string cn, auto arg) {
5189 return sprintf("not (%s)", cn);
5190 },
5191 ),
5192 OP_CLT: (
5193 "argcolumn": True,
5194 "code": string sub (reference<hash<QueryInfo>> info, string cn, auto arg) {
5195 return sprintf("%s < %s", cn, arg);
5196 },
5197 "name": "column <",
5198 "type": AbstractDataProviderType::get(StringType),
5199 "desc": "a column name for less than comparisons; if the field value is less than the column argument's "
5200 "value, then the operation returns true; the other column must have a compatible type",
5201 ),
5202 OP_CLE: (
5203 "argcolumn": True,
5204 "code": string sub (reference<hash<QueryInfo>> info, string cn, auto arg) {
5205 return sprintf("%s <= %s", cn, arg);
5206 },
5207 "name": "column <=",
5208 "type": AbstractDataProviderType::get(StringType),
5209 "desc": "a column name for less than or equals comparisons; if the field value is less than or equal to "
5210 "the column argument's, then the operation returns true; the other column must have a compatible type",
5211 ),
5212 OP_CGT: (
5213 "argcolumn": True,
5214 "code": string sub (reference<hash<QueryInfo>> info, string cn, auto arg) {
5215 return sprintf("%s > %s", cn, arg);
5216 },
5217 "name": "column >",
5218 "type": AbstractDataProviderType::get(StringType),
5219 "desc": "a column name for less than comparisons; if the field value is less than the column argument's, "
5220 "then the operation returns true; the other column must have a compatible type",
5221 ),
5222 OP_CGE: (
5223 "argcolumn": True,
5224 "code": string sub (reference<hash<QueryInfo>> info, string cn, auto arg) {
5225 return sprintf("%s >= %s", cn, arg);
5226 },
5227 "name": "column >=",
5228 "type": AbstractDataProviderType::get(StringType),
5229 "desc": "a column name for greater than or equals comparisons; if the field value is greater than or "
5230 "equal to the column argument's, then the operation returns true; the other column must have a "
5231 "compatible type",
5232 ),
5233 OP_CNE: (
5234 "argcolumn": True,
5235 "code": string sub (reference<hash<QueryInfo>> info, string cn, auto arg) {
5236 return sprintf("%s != %s", cn, arg);
5237 },
5238 "name": "column !=",
5239 "type": AbstractDataProviderType::get(StringType),
5240 "desc": "a column name for not=equals comparisons; the other column must have a compatible type",
5241 ),
5242 OP_CEQ: (
5243 "argcolumn": True,
5244 "code": string sub (reference<hash<QueryInfo>> info, string cn, string arg) {
5245 return sprintf("%s = %s", cn, arg);
5246 },
5247 "name": "column =",
5248 "type": AbstractDataProviderType::get(StringType),
5249 "desc": "a value for equality comparisons; the other column must have a compatible type",
5250 ),
5251 OP_SUBSTR: (
5252 "code": string sub (reference<hash<QueryInfo>> info, string cn, auto arg) {
5253 info.args += arg[0]; // start
5254 if (!exists arg[1]) {
5255 info.args += arg[2]; # text
5256 return sprintf("substring(%s from %v) = %v", cn);
5257 }
5258 info.args += arg[1]; # count
5259 info.args += arg[2]; # text
5260 return sprintf("substring(%s from %v for %v) = %v", cn);
5261 },
5262 ),
5263 OP_OR: (
5264 "code": string sub (reference<hash<QueryInfo>> info, string cn, list<auto> arg) {
5265 return info.table.getOrClause(\info, arg);
5266 },
5267 ),
5268 };
5270
5295 hash<OperatorInfo> make_op(string op, auto arg);
5296
5297
5299
5308 hash<OperatorInfo> op_like(string str);
5309
5310
5312
5323 hash<OperatorInfo> op_lt(auto arg);
5324
5325
5327
5338 hash<OperatorInfo> op_le(auto arg);
5339
5340
5342
5353 hash<OperatorInfo> op_gt(auto arg);
5354
5355
5357
5368 hash<OperatorInfo> op_ge(auto arg);
5369
5370
5372
5385 hash<OperatorInfo> op_ne(auto arg);
5386
5387
5389
5402 hash<OperatorInfo> op_eq(auto arg);
5403
5404
5406
5418 hash<OperatorInfo> op_between(auto l, auto r);
5419
5420
5422
5431 hash<OperatorInfo> op_in();
5432
5433
5435
5442 hash<OperatorInfo> op_in_select(string table, hash<auto> select_hash);
5443
5444
5446
5453 hash<OperatorInfo> op_in_select(AbstractTable table, hash<auto> select_hash);
5454
5455
5457
5464 hash<OperatorInfo> op_in_select(Table table, hash<auto> select_hash);
5465
5466
5468
5479 hash<OperatorInfo> op_in(list<auto> args);
5480
5481
5483
5490 hash<OperatorInfo> op_not(hash arg);
5491
5492
5494
5505 hash<OperatorInfo> op_clt(string arg);
5506
5507
5509
5520 hash<OperatorInfo> op_cle(string arg);
5521
5522
5524
5535 hash<OperatorInfo> op_cgt(string arg);
5536
5537
5539
5550 hash<OperatorInfo> op_cge(string arg);
5551
5552
5554
5565 hash<OperatorInfo> op_cne(string arg);
5566
5567
5569
5580 hash<OperatorInfo> op_ceq(string arg);
5581
5582
5584
5595 hash<OperatorInfo> op_substr(int start, *int count, string text);
5596
5597
5599
5609 hash<OperatorInfo> op_substr(int start, string text);
5610
5611
5613
5630 hash<string, hash<OperatorInfo>> wop_or(hash h1, hash h2);
5631
5633
5641
5643 const IOP_SEQ = "seq";
5644
5646
5648 const IOP_SEQ_CURRVAL = "seq_currval";
5649
5651 const DefaultIopMap = {};
5653
5660
5667 hash<InsertOperatorInfo> make_iop(string iop, auto arg);
5668
5669
5671
5680 hash<InsertOperatorInfo> iop_seq(string arg);
5681
5682
5684
5693 hash<InsertOperatorInfo> iop_seq_currval(string arg);
5694
5696
5698 const SqlUtilDrivers = ...;
5699
5700
5701 // private variable to store the closure used to deserialize datasources (if any)
5702 extern code ds_get;
5703
5704 // private variable to store the closure used to serialize datasources (if any)
5705 extern code ds_do;
5706
5709
5710
5713
5714
5715 // private function used to deserialize datasources
5716 AbstractDatasource sqlutil_get_ds(string type, string config);
5717
5718
5719 // private function used to serialize datasources
5720 hash<auto> sqlutil_ds(AbstractDatasource ds);
5721
5722
5725
5726public:
5727
5728
5729protected:
5731 *hash h;
5732
5733public:
5734
5736 constructor(*hash nh);
5737
5738
5741
5742
5745
5746
5748
5763 auto memberGate(string k);
5764
5765
5767
5774
5775
5777 abstract auto take(string k);
5778
5780 renameKey(string old_name, string new_name);
5781
5782
5784 *hash<auto> getHash();
5785
5786
5788
5797 bool matchKeys(hash h1);
5798
5799
5801
5810 bool matchKeys(list<auto> l);
5811
5812
5814
5824
5825
5827
5836 bool partialMatchKeys(hash h1);
5837
5838
5840
5849 bool partialMatchKeys(list<auto> l);
5850
5851
5853
5863
5864
5866
5875 bool val();
5876
5877
5879
5886 list<string> keys();
5887
5888
5890
5897 list<auto> values();
5898
5899
5901
5909
5910
5912
5920
5921
5923
5931
5932
5934 bool empty();
5935
5936
5938
5945 int size();
5946
5947
5949
5958 bool hasKey(string k);
5959
5960
5962
5971 bool hasKeyValue(string k);
5972
5973
5975
5984 *string firstKey();
5985
5986
5988
5997 *string lastKey();
5998
5999
6001 abstract string getElementName();
6002 };
6003
6006
6007public:
6008
6009
6010protected:
6011 softlist l;
6012
6013public:
6014
6016 constructor(softlist nl);
6017
6018
6020
6031 abstract auto get(softint i);
6032
6034 add(auto val);
6035
6036
6038 auto take(int i);
6039
6040
6042 list<auto> getList();
6043
6044
6046
6055 bool val();
6056
6057
6059
6067
6068
6070 bool empty();
6071
6072
6074
6081 int size();
6082
6083
6085 abstract string getElementName();
6086
6087protected:
6088 checkIndex(int i);
6089public:
6090
6091 };
6092
6095
6096public:
6099
6100
6102 constructor(AbstractDatasource ds, hash tables, *hash<auto> opt);
6103
6104
6106 constructor(AbstractDatasource ds);
6107
6108
6110 add(string k, Table val);
6111
6112
6115
6116
6119
6120
6123
6124
6127
6128
6130 populate(AbstractDatasource ds, hash<auto> tables, *hash<auto> opt);
6131
6132
6134 populate(AbstractDatasource ds);
6135
6136
6138
6154 *list<auto> getDropAllForeignConstraintsOnTableSql(string name, *hash<auto> opt);
6155
6156
6158
6174
6175
6178
6179
6181 *AbstractTable getIfExists(AbstractDatasource ds, string name);
6182
6183
6185 AbstractTable get(AbstractDatasource ds, string name);
6186
6187
6189
6204 *string getRenameTableIfExistsSql(string old_name, string new_name, *hash<auto> opts);
6205
6206
6208
6219 bool tableRenamed(string old_name, string new_name, string old_sql_name);
6220
6221
6222protected:
6223 tableRenamedIntern(string old_name, string new_name, string oldsn);
6224public:
6225
6226
6228
6243 *string getDropConstraintIfExistsSql(string tname, string cname, *hash<auto> opts);
6244
6245
6246 list<auto> getCreateList();
6247
6248
6249 Qore::AbstractIterator createIterator();
6250
6251
6253
6261 list<auto> getDropList();
6262
6263
6265
6273
6274
6275protected:
6276 getDependencies(reference<hash> tdh, reference<hash> sdh, *reference<hash> th);
6277public:
6278
6279 };
6280
6283
6284public:
6286 constructor(*hash c) ;
6287
6288
6291
6292
6295
6296
6299
6300
6302
6318
6319
6321 Columns subset(softlist l);
6322
6323
6326
6327
6329 bool equal(Columns cols);
6330
6331
6333 AbstractIterator getSqlColumnNameIterator();
6334
6335 };
6336
6339
6340public:
6342 string name;
6343
6345 string ddl_name;
6346
6348protected:
6350public:
6351
6352
6355
6356
6358
6360 abstract string getDdlName(string name);
6361 };
6362
6365
6366public:
6369
6371 *string qore_type;
6372
6374 int size;
6375
6378
6380 *string def_val;
6381
6383 *string comment;
6384
6386 *int scale;
6387
6390
6392protected:
6394public:
6395
6396
6397 constructor(string n, string nt, *string qt, int sz, bool nul, *string dv, *string c, *int scale)
6398 ;
6399
6400
6402
6406 hash<GenericColumnInfo> getDescriptionHash();
6407
6408
6410
6413
6414
6417
6418
6420
6429 abstract list<auto> getAddColumnSql(AbstractTable t);
6430
6432 string getDropSql(string table_name);
6433
6434
6436
6449 list<auto> getModifySql(AbstractTable t, AbstractColumn c, *hash<auto> opt);
6450
6451
6453
6463 abstract string getRenameSql(AbstractTable t, string new_name);
6464
6467
6468
6470protected:
6471 abstract bool equalImpl(AbstractColumn c);
6472public:
6473
6475
6491protected:
6492 abstract list<auto> getModifySqlImpl(AbstractTable t, AbstractColumn c, *hash<auto> opt);
6493public:
6494 };
6495
6498
6499public:
6500 constructor(*hash c) ;
6501
6502
6505
6506
6509
6510
6513
6514
6517
6518
6520
6536
6537
6539
6540 };
6541
6544
6545public:
6547 string name;
6548
6551
6554
6555protected:
6558
6561
6562public:
6563
6565 constructor(string n, bool u, hash c);
6566
6567
6569 string getName();
6570
6571
6573 bool hasColumn(string cname);
6574
6575
6577 abstract string getCreateSql(string table_name, *hash<auto> opt);
6578
6580 string getDropSql(string table_name);
6581
6582
6585
6586
6589
6590
6592 abstract bool equalImpl(AbstractIndex ix);
6593
6595 abstract string getRenameSql(string table_name, string new_name);
6596
6599
6600
6603
6604
6607
6608
6611
6612
6615
6616
6619
6620
6622 *list<AbstractColumnConstraint> getAllSupportingConstraints();
6623
6624
6626 list<auto> getRecreateSql(AbstractDatasource ds, string table_name, *hash<auto> opt);
6627
6628 };
6629
6632
6633public:
6634 constructor(*hash c) ;
6635
6636
6639
6640
6643
6644
6647
6648
6650
6666
6667
6669
6670 };
6671
6674
6675public:
6676
6677
6678protected:
6680 string name;
6681
6682public:
6683
6685 constructor(string n);
6686
6687
6689 string getName();
6690
6691
6693 rename(string n);
6694
6695
6697 abstract string getCreateSql(string table_name, *hash<auto> opt);
6698
6700 string getDropSql(string table_name);
6701
6702
6704 abstract list<auto> getRenameSql(string table_name, string new_name);
6705
6707 string getDisableSql(string table_name);
6708
6709
6711 string getEnableSql(string table_name, *hash<auto> opt);
6712
6713
6716
6717
6719protected:
6721public:
6722
6724 abstract bool setIndexBase(string ix);
6725
6727 abstract clearIndex();
6728
6730 bool hasColumn(string cname);
6731
6732 };
6733
6736
6737public:
6739 string src;
6740
6742 constructor(string n, string n_src) ;
6743
6744
6746protected:
6748public:
6749
6750
6752 bool setIndexBase(string ix);
6753
6754
6757
6758 };
6759
6762
6763public:
6764protected:
6766 *string index;
6767
6768public:
6769
6771 constructor(string name, *hash<auto> cols, *string index) ;
6772
6773
6775 constructor(string name, Columns cols, *string index) ;
6776
6777
6779 bool setIndexBase(string ix);
6780
6781
6784
6785 };
6786
6789
6790public:
6791protected:
6793 *hash<string, hash<string, AbstractForeignConstraint>> sourceConstraints;
6794
6795public:
6796
6798 constructor(string name, *hash<auto> cols, *string index) ;
6799
6800
6802 constructor(string name, Columns cols, *string index) ;
6803
6804
6806
6811
6812
6814 hash<auto> getDisableReenableSql(AbstractDatasource ds, string table_name, *hash<auto> opts);
6815
6816
6819
6820
6822
6833
6834
6836 removeSourceConstraint(string tname, list<auto> cols);
6837
6838
6840 renameSourceConstraintTable(string old_name, string new_name);
6841
6842
6844 bool hasColumn(string cname);
6845
6846
6848 *string getIndex();
6849
6850
6852protected:
6854public:
6855
6856
6858 abstract string getCreateSql(string table_name, *hash<auto> opts);
6859 };
6860
6863
6864public:
6866 constructor(string n, *hash<auto> c, *string n_index) ;
6867
6868 };
6869
6872
6873public:
6874 constructor() ;
6875
6876
6877 constructor(string n, *hash<auto> c) ;
6878
6879 };
6880
6883
6884public:
6885 constructor(*hash<auto> c) ;
6886
6887
6890
6891
6894
6895
6898
6899
6901
6917
6918
6920 *hash<auto> findConstraintOn(string table, softlist<auto> cols);
6921
6922
6925
6926 };
6927
6930
6931public:
6933 string table;
6934
6937
6939 constructor(string t, Columns c);
6940
6941
6944
6945 };
6946
6949
6950public:
6953
6955
6956
6958protected:
6960public:
6961
6962 };
6963
6966
6967public:
6969 string name;
6970
6972 number start;
6973
6976
6978 *number max;
6979
6981 constructor(string n_name, number n_start = 1, number n_increment = 1, *softnumber n_max);
6982
6983
6985 abstract string getCreateSql(*hash<auto> opt);
6986
6988
6990 string getDropSql(*hash<auto> opt);
6991
6992
6994
6997 abstract softlist<auto> getRenameSql(string new_name, *hash<auto> opt);
6998 };
6999
7002
7003public:
7004 // ! potential object schema
7005 *string schema;
7006
7008 string name;
7009
7011 string src;
7012
7015
7017 constructor(string n_name, string n_src);
7018
7019
7021 abstract string getCreateSql(*hash<auto> opt);
7022
7024
7026 string getDropSql(*hash<auto> opt);
7027
7028
7030
7033 abstract softlist<auto> getRenameSql(string new_name, *hash<auto> opt);
7034 };
7035
7038
7039public:
7041 string name;
7042
7044 string type;
7045
7047 string src;
7048
7050
7054 constructor(string n, string n_type, string n_src);
7055
7056
7058 string getType();
7059
7060
7062
7064 string getDropSql(*hash<auto> opt);
7065
7066
7069
7070
7072 string getNormalizedSource(string src);
7073
7074
7076protected:
7078public:
7079 };
7080
7083
7084public:
7086
7090 constructor(string n, string n_type, string n_src) ;
7091
7092
7094 abstract list<auto> getCreateSql(*hash<auto> opt);
7095
7097
7100 abstract softlist<auto> getRenameSql(string new_name, *hash<auto> opt);
7101
7103 setName(string new_name);
7104
7105 };
7106
7109
7110public:
7111 constructor(*hash c) ;
7112
7113
7116
7117
7120
7121
7123
7139
7140
7142
7143 };
7144
7147
7148public:
7150 constructor(string n, string n_src) ;
7151
7152
7154 abstract list<auto> getCreateSql(string table_name, *hash<auto> opt);
7155
7157 abstract softlist<auto> getRenameSql(string table_name, string new_name);
7158
7160 abstract list<auto> getDropSql(string table_name);
7161 };
7162
7165
7166public:
7167 constructor(*hash c) ;
7168
7169
7172
7173
7176
7177
7179
7195
7196
7198
7199 };
7200};
abstract class for check constraints
Definition: SqlUtil.qm.dox.h:6735
string src
the source of the check clause
Definition: SqlUtil.qm.dox.h:6739
bool equalImpl(AbstractConstraint c)
returns True if the argument is equal to the current object, False if not
constructor(string n, string n_src)
creates the object and sets its name and the check clause source
bool setIndexBase(string ix)
returns True if the object supports an index property and is set, False if not
clearIndex()
clears any index base for the constraint
the API for a constraint with columns
Definition: SqlUtil.qm.dox.h:6761
*string index
the index supporting the constraint
Definition: SqlUtil.qm.dox.h:6766
constructor(string name, Columns cols, *string index)
creates the object from the name and a Columns object
clearIndex()
clears any index base for the constraint
constructor(string name, *hash< auto > cols, *string index)
creates the object from the name and a hash of column information
bool setIndexBase(string ix)
returns True if the object supports an index property and is set, False if not
the base class for column information
Definition: SqlUtil.qm.dox.h:6364
abstract bool equalImpl(AbstractColumn c)
returns True if the argument is equal to the current object, False if not
abstract string getRenameSql(AbstractTable t, string new_name)
returns a string that can be used to rename the column
hash< GenericColumnInfo > getDescriptionHash()
Returns a description hash of the column.
string native_type
the native type name of the column
Definition: SqlUtil.qm.dox.h:6368
abstract list< auto > getModifySqlImpl(AbstractTable t, AbstractColumn c, *hash< auto > opt)
returns a list of sql strings that can be used to modify the column to the new definition
*string comment
comment on the column
Definition: SqlUtil.qm.dox.h:6383
*string def_val
default value for column
Definition: SqlUtil.qm.dox.h:6380
list< auto > getModifySql(AbstractTable t, AbstractColumn c, *hash< auto > opt)
returns a list of sql strings that can be used to modify the column to the new definition; if the col...
constructor()
empty constructor for subclasses
*string qore_type
the equivalent qore type name of the column if known
Definition: SqlUtil.qm.dox.h:6371
string getCreateSql(AbstractTable t)
returns an sql string that can be used to add the column to a table
bool nullable
True if the column can hold a NULL value, False if not
Definition: SqlUtil.qm.dox.h:6377
bool equal(AbstractColumn c)
returns True if the argument is equal to the current object, False if not
const DefaultVarcharSize
Default VARCHAR column size.
Definition: SqlUtil.qm.dox.h:6389
string getNativeTypeString()
returns the string describing the native type that can be used in SQL
int size
the size of the column
Definition: SqlUtil.qm.dox.h:6374
*int scale
the scale for numeric columns
Definition: SqlUtil.qm.dox.h:6386
abstract list< auto > getAddColumnSql(AbstractTable t)
returns a list of sql strings that can be used to add the column to an existing table
string getDropSql(string table_name)
returns a string that can be used to drop the column from the table
the API for a constraint with columns
Definition: SqlUtil.qm.dox.h:6788
Qore::AbstractIterator getSourceConstraintIterator()
returns an iterator through all known source foreign constraints on the current table
addSourceConstraint(string tname, AbstractForeignConstraint fk)
adds a foreign constraint source to the unique constraint
*hash< string, hash< string, AbstractForeignConstraint > > sourceConstraints
a hash of ForeignConstraintSources, keyed by table name, the value is a hash of foreign constraints k...
Definition: SqlUtil.qm.dox.h:6793
constructor(string name, Columns cols, *string index)
creates the object from the name and a Columns object
renameSourceConstraintTable(string old_name, string new_name)
renames a table in a source constraint
abstract string getCreateSql(string table_name, *hash< auto > opts)
returns a string that can be used to create the constraint in the database
findMatchingIndex(*Indexes indexes)
find an index that matches the constraint and marks both objects as related
*string getIndex()
returns the name of the associated index, if any
hash< auto > getDisableReenableSql(AbstractDatasource ds, string table_name, *hash< auto > opts)
returns lists of SQL strings to disable this constraint plus any dependent constraints and another li...
removeSourceConstraint(string tname, list< auto > cols)
removes a source constraint
bool equalImpl(AbstractConstraint c)
returns True if the argument is equal to the current object, False if not
constructor(string name, *hash< auto > cols, *string index)
creates the object from the name and a hash of column information
bool hasColumn(string cname)
returns True if the constraint references the named column
abstract base class for constraints
Definition: SqlUtil.qm.dox.h:6673
abstract bool setIndexBase(string ix)
returns True if the object supports an index property and is set, False if not
string getDisableSql(string table_name)
returns a string that can be used to temporarily disable the constraint from the database; if disabli...
string getName()
returns the constraint name
constructor(string n)
creates the object and sets its name
bool hasColumn(string cname)
returns True if the constraint references the named column
rename(string n)
renames the constraint
abstract list< auto > getRenameSql(string table_name, string new_name)
returns a list of SQL strings that can be used to rename the constraint in the database
abstract clearIndex()
clears any index base for the constraint
string getDropSql(string table_name)
returns a string that can be used to drop the constraint from the database
string name
the name of the constraint
Definition: SqlUtil.qm.dox.h:6680
abstract bool equalImpl(AbstractConstraint c)
returns True if the argument is equal to the current object, False if not
bool equal(AbstractConstraint c)
returns True if the argument is equal to the current object, False if not
string getEnableSql(string table_name, *hash< auto > opt)
returns a string that can be used to enable the constraint in the database; if disabling constraints ...
abstract string getCreateSql(string table_name, *hash< auto > opt)
returns a string that can be used to create the constraint in the database
the base class for named objects
Definition: SqlUtil.qm.dox.h:6338
constructor()
empty constructor for subclasses
abstract string getDdlName(string name)
returns the column name with quoting in case the column name is a reserved word
string ddl_name
the name of the object for DDL (in case it's a reserved word)
Definition: SqlUtil.qm.dox.h:6345
string name
the name of the object
Definition: SqlUtil.qm.dox.h:6342
constructor(string name)
creates the object from the name
the base class for foreign key constraint information
Definition: SqlUtil.qm.dox.h:6948
bool equalImpl(AbstractConstraint con)
returns True if the argument is equal to the current object, False if not
ForeignConstraintTarget target
a ForeignConstraintTarget object to describe the target table and columns
Definition: SqlUtil.qm.dox.h:6952
base class for function or objects with code
Definition: SqlUtil.qm.dox.h:7037
string getNormalizedSource(string src)
returns normalized source for comparisons
string name
the name of the object
Definition: SqlUtil.qm.dox.h:7041
abstract bool equalImpl(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
constructor(string n, string n_type, string n_src)
creates the object from the arguments passed
string getDropSql(*hash< auto > opt)
returns a string that can be used to drop the function from the database
bool equal(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
string src
the source of the object
Definition: SqlUtil.qm.dox.h:7047
string type
the type of object
Definition: SqlUtil.qm.dox.h:7044
string getType()
returns the type of object
base class for functions
Definition: SqlUtil.qm.dox.h:7082
abstract softlist< auto > getRenameSql(string new_name, *hash< auto > opt)
returns a list of strings that can be used to rename the function in the database
setName(string new_name)
sets the new name of the object
abstract list< auto > getCreateSql(*hash< auto > opt)
returns a list of SQL strings that can be used to create the function in the database
constructor(string n, string n_type, string n_src)
creates the object from the arguments passed
abstract container class that throws an exception if an unknown key is accessed
Definition: SqlUtil.qm.dox.h:5724
bool partialMatchKeys(hash h1)
returns True if the hash argument has at least the same keys (in any order, can have more keys),...
Qore::AbstractIterator pairIterator()
Returns a HashPairIterator object for the contained hash.
bool hasKeyValue(string k)
Returns True if the key exists in the contained hash and is assigned a value, False if not.
abstract auto take(string k)
removes the given key from the contained hash and returns the value
bool partialMatchKeys(list< auto > l)
returns True if the list<auto> argument has at least the same keys (in any order, can have more keys)...
*string firstKey()
Returns the first key name in the contained hash or NOTHING if the contained hash has no keys.
bool partialMatchKeys(AbstractHashContainer c)
returns True if the container argument has at least the same keys (in any order, can have more keys),...
Qore::AbstractIterator iterator()
Returns a HashIterator object for the contained hash.
auto memberGate(string k)
returns the value of the given key in the contained hash if it exists, otherwise throws a KEY-ERROR e...
bool hasKey(string k)
Returns True if the key exists in the contained hash (may or may not be assigned a value),...
renameKey(string old_name, string new_name)
renames the given key; maintains the key order
list< auto > values()
Returns a list of values of the contained hash.
*string lastKey()
Returns the last key name in the contained hash or NOTHING if the contained hash has no keys.
*hash< auto > getHash()
returns the hash contained by this object
clear()
purges the contained data
bool matchKeys(hash h1)
returns True if the hash argument has the same keys (in any order), False if not
*hash h
the data to be contained
Definition: SqlUtil.qm.dox.h:5731
abstract string getElementName()
must return the name of the contained element
list< string > keys()
Returns a list of key names of the contained hash.
Qore::AbstractIterator keyIterator()
Returns a HashKeyIterator object for the contained hash.
int size()
Returns the number of keys in the contained hash.
constructor(*hash nh)
creates the object with the hash argument passed
bool matchKeys(list< auto > l)
returns True if the list<auto> argument has the same list of key strings as the keys in the object (i...
constructor(AbstractHashContainer old)
creates a copy of the object
bool empty()
returns True if the container is empty, False if not
bool matchKeys(AbstractHashContainer c)
returns True if the container argument has the same keys (in any order), False if not
bool val()
Returns False if the contained hash has no keys, True if it does.
copy(AbstractHashContainer old)
creates a "deep copy" of the object
the abstract base class for index information
Definition: SqlUtil.qm.dox.h:6543
bool equalExceptName(AbstractIndex ix)
returns True if the argument is equal to the current index with the exception of the name,...
bool hasColumn(string cname)
returns True if the constraint references the named column
*AbstractForeignConstraint foreign_constraint
Any foreign constraint that this index supports.
Definition: SqlUtil.qm.dox.h:6560
abstract bool equalImpl(AbstractIndex ix)
returns True if the argument is equal to the current index, False if not
setForeignConstraint()
clears the supporting constraint
*AbstractColumnSupportingConstraint getSupportingConstraint()
returns the supporting constraint, if any
abstract string getCreateSql(string table_name, *hash< auto > opt)
returns a string that can be used to create the index in the database
string name
the name of the index
Definition: SqlUtil.qm.dox.h:6547
*AbstractForeignConstraint getForeignConstraint()
returns the supporting constraint, if any
constructor(string n, bool u, hash c)
creates the object from the name, a unique flag, and a hash of column information
setSupportingConstraint(AbstractForeignConstraint c)
tags the index with a column supporting constraint (unique or fk constraint, etc) that the index supp...
setSupportingConstraint(AbstractColumnSupportingConstraint c)
tags the index with a column supporting constraint (unique or fk constraint, etc) that the index supp...
bool unique
True if the index is a unique index, False if not
Definition: SqlUtil.qm.dox.h:6550
*AbstractColumnSupportingConstraint constraint
the AbstractColumnSupportingConstraint that this index supports, if any
Definition: SqlUtil.qm.dox.h:6557
string getName()
returns the index name
setSupportingConstraint()
clears the supporting constraint
bool equal(AbstractIndex ix)
returns True if the argument is equal to the current index, False if not
*list< AbstractColumnConstraint > getAllSupportingConstraints()
returns all supporting constraints, if any
string getDropSql(string table_name)
returns a string that can be used to drop the index from the database
abstract string getRenameSql(string table_name, string new_name)
returns a string that can be used to rename the index in the database
Columns columns
an object of class Columns representing the columns in the index
Definition: SqlUtil.qm.dox.h:6553
list< auto > getRecreateSql(AbstractDatasource ds, string table_name, *hash< auto > opt)
returns a list of strings to drop and recreate the current index; if there are dependent constraints,...
abstract container class that throws an exception if an unknown key is accessed
Definition: SqlUtil.qm.dox.h:6005
list< auto > getList()
returns the list contained by this object
bool empty()
returns True if the container is empty, False if not
abstract auto get(softint i)
returns the value of the given element in the contained list if it exists, otherwise throws an ELEMEN...
auto take(int i)
removes the given element from the contained list and returns the value
add(auto val)
adds the given value to the list
bool val()
Returns False if the contained list is empty, True if not.
abstract string getElementName()
must return the name of the contained element
constructor(softlist nl)
creates the object with the list<auto> argument passed
Qore::ListIterator iterator()
Returns a ListIterator object for the contained list.
int size()
Returns the number of elements in the contained list.
represents a primary key
Definition: SqlUtil.qm.dox.h:6871
base class for sequences
Definition: SqlUtil.qm.dox.h:6965
*number max
the ending number
Definition: SqlUtil.qm.dox.h:6978
string name
the name of the sequence
Definition: SqlUtil.qm.dox.h:6969
string getDropSql(*hash< auto > opt)
returns a string that can be used to drop the sequence from the database
abstract softlist< auto > getRenameSql(string new_name, *hash< auto > opt)
returns a list of strings that can be used to rename the sequence in the database
abstract string getCreateSql(*hash< auto > opt)
returns a string that can be used to create the sequence in the database
number start
the starting number
Definition: SqlUtil.qm.dox.h:6972
number increment
the increment
Definition: SqlUtil.qm.dox.h:6975
constructor(string n_name, number n_start=1, number n_increment=1, *softnumber n_max)
creates the object from the arguments
the base abstract class for the table implementation
Definition: AbstractTable.qc.dox.h:30
the base class for triggers
Definition: SqlUtil.qm.dox.h:7146
abstract softlist< auto > getRenameSql(string table_name, string new_name)
returns a string that can be used to rename the trigger in the database
abstract list< auto > getDropSql(string table_name)
returns a string that can be used to drop the trigger in the database
constructor(string n, string n_src)
creates the object and sets its name and the trigger source
abstract list< auto > getCreateSql(string table_name, *hash< auto > opt)
returns a string that can be used to create the trigger in the database
represents a unique column constraint
Definition: SqlUtil.qm.dox.h:6862
constructor(string n, *hash< auto > c, *string n_index)
creates the object from the name an a hash of column information
base class for views
Definition: SqlUtil.qm.dox.h:7001
bool updatable
Flag showing if is the view updatable with DML commands.
Definition: SqlUtil.qm.dox.h:7014
string name
the name of the sequence
Definition: SqlUtil.qm.dox.h:7008
abstract softlist< auto > getRenameSql(string new_name, *hash< auto > opt)
returns a list with command(s) that can be used to rename the view in the database
constructor(string n_name, string n_src)
creates the object from the arguments
string src
the source code
Definition: SqlUtil.qm.dox.h:7011
string getDropSql(*hash< auto > opt)
returns a string that can be used to drop the view from the database
abstract string getCreateSql(*hash< auto > opt)
returns a string that can be used to create the view in the database
column container class that throws an exception if an unknown column is accessed
Definition: SqlUtil.qm.dox.h:6282
bool equal(Columns cols)
returns True if the argument has the same columns in the same order as the current object,...
add(string k, AbstractColumn val)
adds the given value to the hash with the given key name
Columns subset(softlist l)
returns a subset of the current columns according to the list<auto> argument
string getElementName()
returns "column" since this object stores column objects
AbstractIterator getSqlColumnNameIterator()
returns an iterator for column SQL names
AbstractColumn memberGate(string k)
returns the AbstractColumn object corresponding to the key given or throws a KEY-ERROR exception
AbstractColumn take(string k)
removes the given key from the contained hash and returns the value
constructor(Columns old)
creates a copy of the object
constructor(*hash c)
creates the object from the argument
constraint container class that throws an exception if an unknown constraint is accessed
Definition: SqlUtil.qm.dox.h:6631
AbstractConstraint memberGate(string k)
returns the AbstractConstraint object corresponding to the key given or throws a KEY-ERROR exception
AbstractConstraint take(string k)
removes the given key from the contained hash and returns the value
*AbstractUniqueConstraint findEqualUniqueConstraint(AbstractUniqueConstraint uk)
finds a unique constraint with the same columns as the unique constraint passed
add(string k, AbstractConstraint val)
adds the given value to the hash with the given key name
string getElementName()
must return the name of the contained element
a class describing a foreign constraint target
Definition: SqlUtil.qm.dox.h:6929
constructor(string t, Columns c)
creates the object and sets the target table name and the target columns
bool equal(ForeignConstraintTarget targ)
returns True if the argument is equal to the current object, False if not
Columns columns
columns in the target table
Definition: SqlUtil.qm.dox.h:6936
string table
the name of the target table
Definition: SqlUtil.qm.dox.h:6933
foreign constraint container class that throws an exception if an unknown constraint is accessed
Definition: SqlUtil.qm.dox.h:6882
AbstractForeignConstraint take(string k)
removes the given key from the contained hash and returns the value
*AbstractForeignConstraint findEqual(AbstractForeignConstraint fk)
find an index with columns equal to the index passed
add(string k, AbstractForeignConstraint val)
adds the given value to the hash with the given key name
string getElementName()
returns "foreign constraint" for the type of object encapsulated
*hash< auto > findConstraintOn(string table, softlist< auto > cols)
returns either a hash of AbstractColumn information or NOTHING if no foreign constraint can be found ...
AbstractForeignConstraint memberGate(string k)
returns the AbstractForeignConstraint object corresponding to the key given or throws a KEY-ERROR exc...
function container class that throws an exception if an unknown function is accessed
Definition: SqlUtil.qm.dox.h:7108
add(string k, AbstractFunction val)
adds the given value to the hash with the given key name
AbstractFunction take(string k)
removes the given key from the contained hash and returns the value
string getElementName()
must return the name of the contained element
AbstractFunction memberGate(string k)
returns the AbstractFunction object corresponding to the key given or throws a KEY-ERROR exception
index container class that throws an exception if an unknown index is accessed
Definition: SqlUtil.qm.dox.h:6497
string getElementName()
must return the name of the contained element
AbstractIndex take(string k)
removes the given key from the contained hash and returns the value
*AbstractIndex tryTake(string k)
tries to remove the given key from the contained hash and returns the value if it exists
*AbstractIndex findEqual(AbstractIndex ix)
find an index with columns equal to the index passed
add(string k, AbstractIndex val)
adds the given value to the hash with the given key name
AbstractIndex memberGate(string k)
returns the AbstractIndex object corresponding to the key given or throws a KEY-ERROR exception
represents a database table; this class embeds an AbstractTable object that is created automatically ...
Definition: Table.qc.dox.h:44
the table container class stores a collection of tables in a schema
Definition: SqlUtil.qm.dox.h:6094
AbstractTable memberGate(string k)
returns the AbstractTable object corresponding to the key given or throws a KEY-ERROR exception
Qore::AbstractIterator dropIterator()
returns an iterator for a list of cached table names in the order that can be used to drop the tables...
constructor(AbstractDatasource ds, hash tables, *hash< auto > opt)
creates and populates the object from a hash<auto> description
populate(AbstractDatasource ds, hash< auto > tables, *hash< auto > opt)
populates the object from a hash<auto> description
*list< auto > getDropAllForeignConstraintsOnTableSql(string name, *hash< auto > opt)
returns a list of SQL strings that can be used to drop all the foreign constraints on a particular ta...
list< auto > getDropList()
returns a list of cached table names in the order that can be used to drop the tables,...
bool tableRenamed(string old_name, string new_name, string old_sql_name)
updates table names and internal references for renamed tables
add(AbstractTable val)
adds the given value to the hash with the given key name
add(string k, Table val)
adds the given value to the hash with the given key name
AbstractTable take(string k)
removes the given key from the contained hash and returns the value
*AbstractTable getIfExists(AbstractDatasource ds, string name)
gets a table from the database or from the cache if already cached; if the table does not exist,...
populate(AbstractDatasource ds)
populates the object from tables in the database
constructor(AbstractDatasource ds)
creates and populates the object from tables in the database
add(string k, AbstractTable val)
adds the given value to the hash with the given key name
*string getDropConstraintIfExistsSql(string tname, string cname, *hash< auto > opts)
returns an SQL string that can be used to drop an existing constraint on a table, if the table is not...
add(Table val)
adds the given value to the hash with the given key name
*string getRenameTableIfExistsSql(string old_name, string new_name, *hash< auto > opts)
returns an SQL string that can be used to rename the given table if it exists and the target does not...
string getElementName()
returns "table" since this object stores AbstractTable objects
constructor()
creates an empty object
AbstractTable get(AbstractDatasource ds, string name)
gets a table from the database or from the cache if already cached
trigger container class that throws an exception if an unknown trigger is accessed
Definition: SqlUtil.qm.dox.h:7164
AbstractTrigger memberGate(string k)
returns the AbstractTrigger object corresponding to the key given or throws a KEY-ERROR exception
AbstractTrigger take(string k)
removes the given key from the contained hash and returns the value
add(string k, AbstractTrigger val)
adds the given value to the hash with the given key name
string getElementName()
must return the name of the contained element
const SZ_NONE
Definition: SqlUtil.qm.dox.h:2466
const SZ_NUM
the data type is numeric so takes an optional precision and scale
Definition: SqlUtil.qm.dox.h:2475
const SZ_MAND
the data type takes a mandatory size parameter
Definition: SqlUtil.qm.dox.h:2469
const SZ_OPT
the data type takes an optional size parameter
Definition: SqlUtil.qm.dox.h:2472
const CLOB
specifies a large variable-length character column (ie CLOB or TEXT, etc)
Definition: SqlUtil.qm.dox.h:2458
const DB_SYNONYMS
Feature: synonyms.
Definition: SqlUtil.qm.dox.h:2438
const DB_PACKAGES
Feature: packages.
Definition: SqlUtil.qm.dox.h:2426
const VARCHAR
Definition: SqlUtil.qm.dox.h:2446
const DB_MVIEWS
Feature: materialized views / snapshots.
Definition: SqlUtil.qm.dox.h:2424
const BLOB
specifies a large variable-length binary column (ie BLOB or BYTEA, etc)
Definition: SqlUtil.qm.dox.h:2455
const DB_PROCEDURES
Feature: procedures.
Definition: SqlUtil.qm.dox.h:2428
const DB_TABLES
Feature: tables.
Definition: SqlUtil.qm.dox.h:2432
const DB_VIEWS
Feature: views.
Definition: SqlUtil.qm.dox.h:2436
const CHAR
specifies a CHAR column
Definition: SqlUtil.qm.dox.h:2452
const NUMERIC
specifies a numeric column (equivalent to Qore::Type::Number)
Definition: SqlUtil.qm.dox.h:2449
const DB_FUNCTIONS
Feature: functions.
Definition: SqlUtil.qm.dox.h:2422
const DB_SEQUENCES
Feature: sequences.
Definition: SqlUtil.qm.dox.h:2430
const DB_TYPES
Feature: named types.
Definition: SqlUtil.qm.dox.h:2434
hash< ColumnOperatorInfo > cop_plus(auto column1, auto column2)
returns a ColumnOperatorInfo hash for the "+" operator with the given arguments
hash< ColumnOperatorInfo > cop_year(auto column)
returns a ColumnOperatorInfo hash for the "year" operator with the given argument
hash< ColumnOperatorInfo > cop_as(auto column, string arg)
returns a ColumnOperatorInfo hash for the "as" operator with the given argument
hash< ColumnOperatorInfo > cop_seq_currval(string seq, *string as)
returns a ColumnOperatorInfo hash for the "seq_currval" operator with the given argument giving the s...
hash< ColumnOperatorInfo > cop_year_day(auto column)
returns a ColumnOperatorInfo hash for the "year_day" operator with the given argument
hash< ColumnOperatorInfo > cop_year_month(auto column)
returns a ColumnOperatorInfo hash for the "year_month" operator with the given argument
hash< ColumnOperatorInfo > cop_count(auto column='')
returns a ColumnOperatorInfo hash for the "count" operator; returns row counts
hash< ColumnOperatorInfo > cop_append(auto column, string arg)
returns a ColumnOperatorInfo hash for the "append" operator with the given argument
hash< ColumnOperatorInfo > cop_coalesce(auto col1, auto col2)
returns a ColumnOperatorInfo hash for the "coalesce" operator with the given column arguments; the fi...
hash< ColumnOperatorInfo > cop_dense_rank()
Analytic/window function: rank of the current row without gaps.
hash< ColumnOperatorInfo > cop_length(auto column)
returns a ColumnOperatorInfo hash for the "len" operator with the given argument; returns the length ...
hash< ColumnOperatorInfo > cop_lower(auto column)
returns a ColumnOperatorInfo hash for the "lower" operator with the given argument; returns a column ...
hash< ColumnOperatorInfo > cop_multiply(auto column1, auto column2)
returns a ColumnOperatorInfo hash for the "*" operator with the given arguments
hash< ColumnOperatorInfo > cop_seq(string seq, *string as)
returns a ColumnOperatorInfo hash for the "seq" operator with the given argument giving the sequence ...
hash< ColumnOperatorInfo > cop_value(auto arg)
returns a ColumnOperatorInfo hash for the "value" (literal) operator with the given argument
hash< ColumnOperatorInfo > cop_last_value(any column)
Analytic/window function: value evaluated at the row that is the last row of the window frame.
hash< ColumnOperatorInfo > cop_prepend(auto column, string arg)
returns a ColumnOperatorInfo hash for the "prepend" operator with the given argument
hash< ColumnOperatorInfo > cop_rank()
Analytic/window function: rank of the current row with gaps.
hash< ColumnOperatorInfo > cop_min(auto column)
returns a ColumnOperatorInfo hash for the "min" operator; returns minimum column values
hash< ColumnOperatorInfo > cop_row_number()
Analytic/window function: number of the current row within its partition, counting from 1.
hash< ColumnOperatorInfo > cop_cume_dist()
Analytic/window function: relative rank of the current row.
hash< ColumnOperatorInfo > cop_cast(auto column, string arg, auto arg1, auto arg2)
returns a ColumnOperatorInfo hash for the "cast" operator with the given argument(s)
hash< ColumnOperatorInfo > cop_upper(auto column)
returns a ColumnOperatorInfo hash for the "upper" operator with the given argument; returns a column ...
hash< ColumnOperatorInfo > cop_avg(auto column)
returns a ColumnOperatorInfo hash for the "avg" operator; returns average column values
hash< ColumnOperatorInfo > cop_percent_rank()
Analytic/window function: relative rank of the current row.
hash< ColumnOperatorInfo > cop_substr(auto column, int start, *int count)
returns a ColumnOperatorInfo hash for the "substr" operator with the given arguments; returns a subst...
hash< ColumnOperatorInfo > cop_sum(auto column)
returns a ColumnOperatorInfo hash for the "sum" operator; returns the total sum of a numeric column.
hash< ColumnOperatorInfo > cop_distinct(auto column)
returns a ColumnOperatorInfo hash for the "distinct" operator with the given argument; returns distin...
hash< ColumnOperatorInfo > cop_minus(auto column1, auto column2)
returns a ColumnOperatorInfo hash for the "-" operator with the given arguments
hash< ColumnOperatorInfo > cop_over(auto column, *string partitionby, *string orderby)
returns a ColumnOperatorInfo hash for the "over" clause
hash< ColumnOperatorInfo > make_cop(string cop, auto column, auto arg)
hash< ColumnOperatorInfo > cop_divide(auto column1, auto column2)
returns a ColumnOperatorInfo hash for the "/" operator with the given arguments
hash< ColumnOperatorInfo > cop_ntile(int value)
Analytic/window function: integer ranging from 1 to the argument value, dividing the partition as equ...
hash< ColumnOperatorInfo > cop_first_value(any column)
Analytic/window function: value evaluated at the row that is the first row of the window frame.
hash< ColumnOperatorInfo > cop_max(auto column)
returns a ColumnOperatorInfo hash for the "max" operator; returns maximum column values
hash< ColumnOperatorInfo > cop_year_hour(auto column)
returns a ColumnOperatorInfo hash for the "year_hour" operator with the given argument
hash< ColumnOperatorInfo > cop_trunc_date(auto column, string mask)
Truncates a date column or value regarding the given mask. The resulting value remains Qore::date (no...
const DT_YEAR
Definition: SqlUtil.qm.dox.h:3594
const DT_MINUTE
Format unit: minute.
Definition: SqlUtil.qm.dox.h:3606
const DT_SECOND
Format unit: hour.
Definition: SqlUtil.qm.dox.h:3609
const DT_MONTH
Format unit: month.
Definition: SqlUtil.qm.dox.h:3597
const DT_HOUR
Format unit: hour.
Definition: SqlUtil.qm.dox.h:3603
const DT_DAY
Format unit: day.
Definition: SqlUtil.qm.dox.h:3600
const COP_MAX
to return the maximum value
Definition: SqlUtil.qm.dox.h:2530
const COP_OVER
the SQL "over" clause
Definition: SqlUtil.qm.dox.h:2550
const COP_SEQ_CURRVAL
to return the last value of a sequence issued in the same session
Definition: SqlUtil.qm.dox.h:2600
const COP_LENGTH
to get the length of a text field
Definition: SqlUtil.qm.dox.h:2617
const COP_RANK
Analytic (window) function: RANK.
Definition: SqlUtil.qm.dox.h:2675
const COP_VALUE
to append a constant value (SQL Literal) to use as an output column value
Definition: SqlUtil.qm.dox.h:2505
const COP_COALESCE
to return the first non-null argument in the list
Definition: SqlUtil.qm.dox.h:2605
const COP_MIN
to return the minimum value
Definition: SqlUtil.qm.dox.h:2525
const COP_YEAR_HOUR
to return a date value with year to hextern information
Definition: SqlUtil.qm.dox.h:2590
const COP_DIVIDE
the SQL "divide" operator
Definition: SqlUtil.qm.dox.h:2565
const COP_YEAR
to return a date value with year information only
Definition: SqlUtil.qm.dox.h:2575
const COP_COUNT
to return the row count
Definition: SqlUtil.qm.dox.h:2545
const COP_MULTIPLY
the SQL "multiply" operator
Definition: SqlUtil.qm.dox.h:2570
const COP_AVG
to return the average value
Definition: SqlUtil.qm.dox.h:2535
const COP_PLUS
the SQL "plus" operator
Definition: SqlUtil.qm.dox.h:2560
const COP_CUME_DIST
Analytic (window) function: CUME_DIST.
Definition: SqlUtil.qm.dox.h:2633
const COP_SUBSTR
to extract a substring from a column
Definition: SqlUtil.qm.dox.h:2610
const COP_SEQ
to return the next value of a sequence
Definition: SqlUtil.qm.dox.h:2595
const COP_APPEND
to append a string to a column on output
Definition: SqlUtil.qm.dox.h:2500
const COP_PERCENT_RANK
Analytic (window) function: PERCENT_RANK.
Definition: SqlUtil.qm.dox.h:2668
const COP_NTILE
Analytic (window) function: NTILE.
Definition: SqlUtil.qm.dox.h:2661
const COP_YEAR_MONTH
to return a date value with year to month information
Definition: SqlUtil.qm.dox.h:2580
const COP_PREPEND
to prepend a string to a column on output
Definition: SqlUtil.qm.dox.h:2495
const COP_LOWER
to return column value in lower case
Definition: SqlUtil.qm.dox.h:2515
const COP_AS
Definition: SqlUtil.qm.dox.h:2485
const COP_CAST
to convert column value into another datatype
Definition: SqlUtil.qm.dox.h:2490
const COP_ROW_NUMBER
Analytic (window) function: ROW_NUMBER.
Definition: SqlUtil.qm.dox.h:2682
const COP_YEAR_DAY
to return a date value with year to day information
Definition: SqlUtil.qm.dox.h:2585
const COP_UPPER
to return column value in upper case
Definition: SqlUtil.qm.dox.h:2510
const COP_DENSE_RANK
Analytic (window) function: DENSE_RANK.
Definition: SqlUtil.qm.dox.h:2640
const COP_TRUNC_DATE
to return the date with truncated value
Definition: SqlUtil.qm.dox.h:2626
const COP_MINUS
the SQL "minus" operator
Definition: SqlUtil.qm.dox.h:2555
const COP_LAST_VALUE
Analytic (window) function: LAST_VALUE.
Definition: SqlUtil.qm.dox.h:2654
const COP_FIRST_VALUE
Analytic (window) function: FIRST_VALUE.
Definition: SqlUtil.qm.dox.h:2647
const DefaultCopMap
a hash of default column operator descriptions
Definition: SqlUtil.qm.dox.h:2718
const COP_DISTINCT
to return distinct values
Definition: SqlUtil.qm.dox.h:2520
const COP_SUM
to return the sum value
Definition: SqlUtil.qm.dox.h:2540
hash< InsertOperatorInfo > make_iop(string iop, auto arg)
hash< InsertOperatorInfo > iop_seq_currval(string arg)
returns an InsertOperatorInfo hash for retrieving the current value of the given sequence in insert q...
hash< InsertOperatorInfo > iop_seq(string arg)
returns an InsertOperatorInfo hash for retrieving the value of the given sequence in insert queries
const IOP_SEQ
Definition: SqlUtil.qm.dox.h:5643
const DefaultIopMap
a hash of default insert operator descriptions (currently empty, all operators are driver-dependent)
Definition: SqlUtil.qm.dox.h:5651
const IOP_SEQ_CURRVAL
for using the last value of a sequence issued in the current session
Definition: SqlUtil.qm.dox.h:5648
hash< string, hash< JoinOperatorInfo > > join_inner_alias(string ta, string table_name, *string alias, *hash jcols, *hash cond, *hash< auto > opt)
returns a hash for standard inner joins with the given arguments for use when joining with a table ot...
hash< string, hash< JoinOperatorInfo > > join_right(AbstractTable table, *string alias, *hash jcols, *hash cond, *hash< auto > opt)
returns a hash for right outer joins with the given arguments
hash< string, hash< JoinOperatorInfo > > join_right_alias(string ta, string table_name, *string alias, *hash jcols, *hash cond, *hash< auto > opt)
returns a hash for right outer joins with the given arguments for use when joining with a table other...
hash< string, hash< JoinOperatorInfo > > join_left(AbstractTable table, *string alias, *hash jcols, *hash cond, *hash< auto > opt)
returns a hash for left outer joins with the given arguments
hash< string, hash< JoinOperatorInfo > > join_left_alias(string ta, string table_name, *string alias, *hash jcols, *hash cond, *hash< auto > opt)
returns a hash for left outer joins with the given arguments for use when joining with a table other ...
hash< string, hash< JoinOperatorInfo > > make_jop(string jop, AbstractTable table, *string alias, *hash jcols, *hash cond, *string ta, *hash< auto > opt)
hash< string, hash< JoinOperatorInfo > > join_inner(AbstractTable table, *string alias, *hash jcols, *hash cond, *hash< auto > opt)
returns a hash for standard inner joins with the given arguments
const JopMap
a hash of valid join operators
Definition: SqlUtil.qm.dox.h:3831
const JOP_INNER
Definition: SqlUtil.qm.dox.h:3818
const JOP_RIGHT
for right outer joins
Definition: SqlUtil.qm.dox.h:3828
const JOP_LEFT
for left outer joins
Definition: SqlUtil.qm.dox.h:3823
hash< OperatorInfo > op_ceq(string arg)
returns an OperatorInfo hash for the "=" operator with the given argument for use in where clauses wh...
hash< OperatorInfo > op_clt(string arg)
returns an OperatorInfo hash for the "<" operator with the given argument for use in where clauses wh...
hash< OperatorInfo > op_between(auto l, auto r)
returns an OperatorInfo hash for the "between" operator with the given arguments, neither of which ca...
hash< OperatorInfo > op_cle(string arg)
returns an OperatorInfo hash for the "<=" operator with the given argument for use in where clauses w...
hash< OperatorInfo > op_cne(string arg)
returns an OperatorInfo hash for the "!=" or "<>" operator with the given argument for use in where c...
hash< OperatorInfo > op_cgt(string arg)
returns an OperatorInfo hash for the ">" operator with the given argument for use in where clauses wh...
hash< OperatorInfo > op_ne(auto arg)
returns an OperatorInfo hash for the "!=" or "<>" operator with the given argument for use in where c...
hash< string, hash< OperatorInfo > > wop_or(hash h1, hash h2)
returns an OperatorInfo hash with a fake "_OR_" column name; the list of arguments to the function is...
hash< OperatorInfo > make_op(string op, auto arg)
hash< OperatorInfo > op_lt(auto arg)
returns an OperatorInfo hash for the "<" operator with the given argument for use in where clauses wh...
hash< OperatorInfo > op_substr(int start, *int count, string text)
returns an OperatorInfo hash for the "substr" operator with the given arguments; for use in where cla...
hash< OperatorInfo > op_like(string str)
returns an OperatorInfo hash for the "like" operator with the given argument for use in where clauses
hash< OperatorInfo > op_gt(auto arg)
returns an OperatorInfo hash for the ">" operator with the given argument for use in where clauses wh...
hash< OperatorInfo > op_in_select(string table, hash< auto > select_hash)
returns an OperatorInfo hash for the "in" operator with a subquery as the argument; for use in where ...
hash< OperatorInfo > op_ge(auto arg)
returns an OperatorInfo hash for the ">=" operator with the given argument for use in where clauses w...
hash< OperatorInfo > op_not(hash arg)
returns an OperatorInfo hash for the "not" operator; for use in where clauses
hash< OperatorInfo > op_eq(auto arg)
returns an OperatorInfo hash for the "=" operator with the given argument for use in where clauses wh...
hash< OperatorInfo > op_cge(string arg)
returns an OperatorInfo hash for the ">=" operator with the given argument for use in where clauses w...
hash< OperatorInfo > op_in()
returns an OperatorInfo hash for the "in" operator with all arguments passed to the function; for use...
hash< OperatorInfo > op_le(auto arg)
returns an OperatorInfo hash for the "<=" operator with the given argument for use in where clauses w...
const OP_GE
the SQL greater than or equals operator (>=) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4325
const OP_NE
the SQL not equals operator (!= or <>) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4330
const OP_LE
the SQL less than or equals (<=) operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4315
const OP_EQ
the SQL equals operator (=) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4335
const OP_IN
the SQL "in" operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4375
const OP_NOT
the SQL "not" operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4380
const DefaultExpressionMap
Default expressions to be supported by all SqlUtil modules.
Definition: SqlUtil.qm.dox.h:4398
const DefaultOpMap
a hash of valid operators for use in Where Clauses
Definition: SqlUtil.qm.dox.h:5105
const OP_SUBSTR
the SQL "substr" operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4385
const OP_CGE
the SQL greater than or equals operator (>=) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4355
const OP_LT
the SQL less than (<) operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4310
const OP_CLE
the SQL less than or equals (<=) operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4345
const OP_BETWEEN
the SQL "between" operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4370
const OP_GT
the SQL greater than operator (>) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4320
const OP_CNE
the SQL not equals operator (!= or <>) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4360
const OP_CLT
the SQL less than (<) operator for use in Where Clauses when comparing two columns
Definition: SqlUtil.qm.dox.h:4340
const OP_OR
to combine SQL expressions with "or" for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4390
const OP_IN_SELECT
the SQL "in" operator with a select query for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4395
const OP_CGT
the SQL greater than operator (>) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4350
const OP_CEQ
the SQL equals operator (=) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4365
const OP_LIKE
Definition: SqlUtil.qm.dox.h:4305
hash< UpdateOperatorInfo > uop_plus(auto arg, *hash< UpdateOperatorInfo > nest)
returns an UpdateOperatorInfo hash for the "+" operator with the given arguments
hash< UpdateOperatorInfo > uop_seq_currval(string seq)
returns an UpdateOperatorInfo hash for the "seq" operator with the given argument giving the sequence...
hash< UpdateOperatorInfo > uop_prepend(string arg, *hash< UpdateOperatorInfo > nest)
returns an UpdateOperatorInfo hash for the "prepend" operator with the given argument
hash< UpdateOperatorInfo > uop_seq(string seq)
returns an UpdateOperatorInfo hash for the "seq" operator with the given argument giving the sequence...
hash< UpdateOperatorInfo > uop_upper(*hash< UpdateOperatorInfo > nest)
returns an UpdateOperatorInfo hash for the "upper" operator with the given argument; returns a column...
hash< UpdateOperatorInfo > uop_divide(auto arg, *hash< UpdateOperatorInfo > nest)
returns an UpdateOperatorInfo hash for the "/" operator with the given arguments
hash< UpdateOperatorInfo > uop_append(string arg, *hash< UpdateOperatorInfo > nest)
returns an UpdateOperatorInfo hash for the "append" or concatenate operator with the given argument
hash< UpdateOperatorInfo > make_uop(string uop, auto arg, *hash< UpdateOperatorInfo > nest)
hash< UpdateOperatorInfo > uop_substr(int start, *int count, *hash< UpdateOperatorInfo > nest)
returns an UpdateOperatorInfo hash for the "substr" operator with the given arguments; returns a subs...
hash< UpdateOperatorInfo > uop_multiply(auto arg, *hash< UpdateOperatorInfo > nest)
returns an UpdateOperatorInfo hash for the "*" operator with the given arguments
hash< UpdateOperatorInfo > uop_lower(*hash< UpdateOperatorInfo > nest)
returns an UpdateOperatorInfo hash for the "lower" operator with the given argument; returns a column...
hash< UpdateOperatorInfo > uop_minus(auto arg, *hash< UpdateOperatorInfo > nest)
returns an UpdateOperatorInfo hash for the "-" operator with the given arguments
const DefaultUopMap
Definition: SqlUtil.qm.dox.h:3620
Qore AbstractDatabase class definition.
Definition: AbstractDatabase.qc.dox.h:26
sqlutil_register_ds_deserializer(*code new_ds_get)
registers a closure or call reference taking a string type and string datasource configuration that w...
sqlutil_register_ds_serializer(*code new_ds_do)
registers a closure or call reference taking a string type and string datasource configuration that w...
const SqlUtilDrivers
known drivers
Definition: SqlUtil.qm.dox.h:5698
column operator info hash as returned by all column operator functions
Definition: SqlUtil.qm.dox.h:2351
string cop
the column operator string code
Definition: SqlUtil.qm.dox.h:2352
auto arg
optional argument
Definition: SqlUtil.qm.dox.h:2354
auto column
column sopecifier, may be a string or a complex hash
Definition: SqlUtil.qm.dox.h:2353
generic column description hash in schema descriptions
Definition: SqlUtil.qm.dox.h:2321
bool notnull
if the column should have a "not null" constraint on it; if missing the default value is False
Definition: SqlUtil.qm.dox.h:2337
hash< string, hash > driver
this key can optionally contain a hash keyed by driver name which contains a hash of values that will...
Definition: SqlUtil.qm.dox.h:2339
auto default_value
the default value for the column
Definition: SqlUtil.qm.dox.h:2331
softint scale
for numeric data types, this value gives the scale
Definition: SqlUtil.qm.dox.h:2329
softint size
for data types requiring a size component, the size; for numeric columns this represents the precisio...
Definition: SqlUtil.qm.dox.h:2327
bool default_value_native
a boolean flag to say if a default_value should be validated against table column type (False) or use...
Definition: SqlUtil.qm.dox.h:2333
*string comment
an optional comment for the column
Definition: SqlUtil.qm.dox.h:2335
string qore_type
a qore type string that will be converted to a native DB type with some default conversion
Definition: SqlUtil.qm.dox.h:2323
string native_type
the native database column type; if both native_type and qore_type are given then native_type is used
Definition: SqlUtil.qm.dox.h:2325
*bool auto_increment
True for DBs that support an auto-increment column
Definition: SqlUtil.qm.dox.h:2341
insert operator info hash as returned by all insert operator functions
Definition: SqlUtil.qm.dox.h:2358
string _iop
the insert operator string code
Definition: SqlUtil.qm.dox.h:2359
any arg
optional argument
Definition: SqlUtil.qm.dox.h:2360
join operator info hash as returned by all join operator functions
Definition: SqlUtil.qm.dox.h:2371
*hash cond
additional conditions for the join clause for the table argument; see Where Clauses for more informat...
Definition: SqlUtil.qm.dox.h:2376
*string alias
optional alias for table in the query
Definition: SqlUtil.qm.dox.h:2374
*string ta
optional table name or alias of the other table to join with when not joining with the primary table
Definition: SqlUtil.qm.dox.h:2377
auto table
the table to join with (either an AbstractTable object or a string table name)
Definition: SqlUtil.qm.dox.h:2373
*hash jcols
the columns to use for the join, the keys will be columns in the source table and the values are colu...
Definition: SqlUtil.qm.dox.h:2375
*hash< auto > opt
optional join options (for example, to specify a partition for the join if supported)
Definition: SqlUtil.qm.dox.h:2378
string jop
the join operator string code
Definition: SqlUtil.qm.dox.h:2372
SQL operator info hash as returned by all operator functions.
Definition: SqlUtil.qm.dox.h:2345
auto arg
optional argument
Definition: SqlUtil.qm.dox.h:2347
string op
the operator string code
Definition: SqlUtil.qm.dox.h:2346
Query information.
Definition: SqlUtil.qm.dox.h:2685
*hash< auto > expression_map
The expression map.
Definition: SqlUtil.qm.dox.h:2705
*hash< string, AbstractTable > join_map
Tables in this join; table alias -> table.
Definition: SqlUtil.qm.dox.h:2696
*hash< auto > pseudo_column_map
Any valid pseudocolumns or aliases generated in th query.
Definition: SqlUtil.qm.dox.h:2702
*hash< auto > where_operator_map
The old-style backwards-compatible "where operator" map.
Definition: SqlUtil.qm.dox.h:2708
object table
The primary table object.
Definition: SqlUtil.qm.dox.h:2687
*hash< auto > query_hash
The original query hash.
Definition: SqlUtil.qm.dox.h:2690
*hash< auto > column_operator_map
Any custom column operator map.
Definition: SqlUtil.qm.dox.h:2711
list< auto > args
arguments to bind in the query generated
Definition: SqlUtil.qm.dox.h:2714
*hash< auto > query_options
Any query options.
Definition: SqlUtil.qm.dox.h:2693
*hash< string, bool > subquery_column_map
When executing a superquery, we can only reference colums in the subquery.
Definition: SqlUtil.qm.dox.h:2699
A hash describing SQL and arguments for an SQL DML command.
Definition: SqlUtil.qm.dox.h:2407
string sql
the SQL string for the update
Definition: SqlUtil.qm.dox.h:2409
list< auto > args
the arguments for the string
Definition: SqlUtil.qm.dox.h:2412
column data type options
Definition: SqlUtil.qm.dox.h:2382
*string number_format
optional format string for converting strings to numeric / decimal / number columns
Definition: SqlUtil.qm.dox.h:2393
*TimeZone data_timezone
the timezone when converting dates from external data to the DB's date
Definition: SqlUtil.qm.dox.h:2387
*softint maxlen
optional additional limit to the maximum length of the data
Definition: SqlUtil.qm.dox.h:2401
*TimeZone db_timezone
the timezone to use when sending date/time values to the DB
Definition: SqlUtil.qm.dox.h:2390
*softbool mandatory
optional flag to overrude any nullable attribute and require data for the column
Definition: SqlUtil.qm.dox.h:2396
*string date_format
optional format string for converting strings to dates for date / timestamp columns
Definition: SqlUtil.qm.dox.h:2384
update operator info hash as returned by all update operator functions
Definition: SqlUtil.qm.dox.h:2364
*hash nest
option nested operation hash
Definition: SqlUtil.qm.dox.h:2367
auto arg
optional argument
Definition: SqlUtil.qm.dox.h:2366
string uop
the update operator string code
Definition: SqlUtil.qm.dox.h:2365