Qore SqlUtil Module Reference 1.8.1
Loading...
Searching...
No Matches
SqlUtil.qm.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
4/* SqlUtil.qm Copyright (C) 2013 - 2022 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
2313namespace SqlUtil {
2315 public hashdecl GenericColumnInfo {
2321 softint size;
2323 softint scale;
2329 *string comment;
2331 bool notnull = False;
2333 hash<string, hash> driver;
2336 };
2337
2339 public hashdecl OperatorInfo {
2340 string op;
2341 auto arg;
2342 };
2343
2345 public hashdecl ColumnOperatorInfo {
2346 string cop;
2347 auto column;
2348 auto arg;
2349 };
2350
2352 public hashdecl InsertOperatorInfo {
2353 string _iop;
2354 any arg;
2355 };
2356
2358 public hashdecl UpdateOperatorInfo {
2359 string uop;
2360 auto arg;
2361 *hash nest;
2362 };
2363
2365 public hashdecl JoinOperatorInfo {
2366 string jop;
2367 auto table;
2368 *string alias;
2369 *hash jcols;
2370 *hash cond;
2371 *string ta;
2372 *hash<auto> opt;
2373 };
2374
2379
2381 *TimeZone data_timezone;
2382
2384 *TimeZone db_timezone;
2385
2388
2390 *softbool mandatory;
2391
2393
2395 *softint maxlen;
2396 };
2397
2399
2401 public hashdecl SqlCommandInfo {
2403 string sql;
2404
2406 list<auto> args;
2407 };
2408
2414
2416 const DB_FUNCTIONS = "functions";
2418 const DB_MVIEWS = "materialized views";
2420 const DB_PACKAGES = "packages";
2422 const DB_PROCEDURES = "procedures";
2424 const DB_SEQUENCES = "sequences";
2426 const DB_TABLES = "tables";
2428 const DB_TYPES = "named types";
2430 const DB_VIEWS = "views";
2432 const DB_SYNONYMS = "synonyms";
2434
2435 /* @defgroup SqlTypeConstants SQL Type Constants
2436 These constants can be used for the \c "qore_type" values when creating columns to specify additional SQL column types
2437 */
2440 const VARCHAR = "string";
2441
2443 const NUMERIC = "number";
2444
2446 const CHAR = "char";
2447
2449 const BLOB = "blob";
2450
2452 const CLOB = "clob";
2454
2460 const SZ_NONE = 0;
2461
2463 const SZ_MAND = 1;
2464
2466 const SZ_OPT = 2;
2467
2469 const SZ_NUM = 3;
2471
2477
2479 const COP_AS = "as";
2480
2482
2484 const COP_CAST = "cast";
2485
2487
2489 const COP_PREPEND = "prepend";
2490
2492
2494 const COP_APPEND = "append";
2495
2497
2499 const COP_VALUE = "value";
2500
2502
2504 const COP_UPPER = "upper";
2505
2507
2509 const COP_LOWER = "lower";
2510
2512
2514 const COP_DISTINCT = "distinct";
2515
2517
2519 const COP_MIN = "min";
2520
2522
2524 const COP_MAX = "max";
2525
2527
2529 const COP_AVG = "avg";
2530
2532
2534 const COP_SUM = "sum";
2535
2537
2539 const COP_COUNT = "count";
2540
2542
2544 const COP_OVER = "over";
2545
2547
2549 const COP_MINUS = "minus";
2550
2552
2554 const COP_PLUS = "plus";
2555
2557
2559 const COP_DIVIDE = "divide";
2560
2562
2564 const COP_MULTIPLY = "multiply";
2565
2567
2569 const COP_YEAR = "year";
2570
2572
2574 const COP_YEAR_MONTH = "year_month";
2575
2577
2579 const COP_YEAR_DAY = "year_day";
2580
2582
2584 const COP_YEAR_HOUR = "year_hour";
2585
2587
2589 const COP_SEQ = "seq";
2590
2592
2594 const COP_SEQ_CURRVAL = "seq_currval";
2595
2597
2599 const COP_COALESCE = "coalesce";
2600
2602
2604 const COP_SUBSTR = "substr";
2605
2607
2611 const COP_LENGTH = "length";
2612
2614
2620 const COP_TRUNC_DATE = "truncate_date";
2621
2623
2627 const COP_CUME_DIST = "cume_dist";
2628
2630
2634 const COP_DENSE_RANK = "dense_rank";
2635
2637
2641 const COP_FIRST_VALUE = "first_value";
2642
2644
2648 const COP_LAST_VALUE = "last_value";
2649
2651
2655 const COP_NTILE = "ntile";
2656
2658
2662 const COP_PERCENT_RANK = "percent_rank";
2663
2665
2669 const COP_RANK = "rank";
2670
2672
2676 const COP_ROW_NUMBER = "row_number";
2677
2679 public hashdecl QueryInfo {
2681 object table;
2682
2684 *hash<auto> query_hash;
2685
2687 *hash<auto> query_options;
2688
2690 *hash<string, AbstractTable> join_map;
2691
2693 *hash<string, bool> subquery_column_map;
2694
2697
2699 *hash<auto> expression_map;
2700
2703
2706
2708 list<auto> args;
2709 };
2710
2712 const DefaultCopMap = ...;
2713
2715
2758
2766 hash<ColumnOperatorInfo> make_cop(string cop, auto column, auto arg);
2767
2768
2770
2782 hash<ColumnOperatorInfo> cop_as(auto column, string arg);
2783
2784
2786
2800 hash<ColumnOperatorInfo> cop_cast(auto column, string arg, auto arg1, auto arg2);
2801
2802
2804
2814 hash<ColumnOperatorInfo> cop_prepend(auto column, string arg);
2815
2816
2818
2828 hash<ColumnOperatorInfo> cop_append(auto column, string arg);
2829
2830
2832
2960 hash<ColumnOperatorInfo> cop_value(auto arg);
2961
2962
2964
2973 hash<ColumnOperatorInfo> cop_upper(auto column);
2974
2975
2977
2986 hash<ColumnOperatorInfo> cop_lower(auto column);
2987
2988
2990
2999 hash<ColumnOperatorInfo> cop_distinct(auto column);
3000
3001
3003
3012 hash<ColumnOperatorInfo> cop_min(auto column);
3013
3014
3016
3025 hash<ColumnOperatorInfo> cop_max(auto column);
3026
3027
3029
3038 hash<ColumnOperatorInfo> cop_avg(auto column);
3039
3040
3042
3051 hash<ColumnOperatorInfo> cop_sum(auto column);
3052
3053
3055
3062 hash<ColumnOperatorInfo> cop_count(auto column = '');
3063
3064
3066
3073 hash<ColumnOperatorInfo> cop_over(auto column, *string partitionby, *string orderby);
3074
3075
3077
3087 hash<ColumnOperatorInfo> cop_minus(auto column1, auto column2);
3088
3089
3091
3101 hash<ColumnOperatorInfo> cop_plus(auto column1, auto column2);
3102
3103
3105
3115 hash<ColumnOperatorInfo> cop_divide(auto column1, auto column2);
3116
3117
3119
3129 hash<ColumnOperatorInfo> cop_multiply(auto column1, auto column2);
3130
3131
3133
3142 hash<ColumnOperatorInfo> cop_year(auto column);
3143
3144
3146
3155 hash<ColumnOperatorInfo> cop_year_month(auto column);
3156
3157
3159
3168 hash<ColumnOperatorInfo> cop_year_day(auto column);
3169
3170
3172
3181 hash<ColumnOperatorInfo> cop_year_hour(auto column);
3182
3183
3185
3195 hash<ColumnOperatorInfo> cop_seq(string seq, *string as);
3196
3197
3199
3209 hash<ColumnOperatorInfo> cop_seq_currval(string seq, *string as);
3210
3211
3213
3225 hash<ColumnOperatorInfo> cop_coalesce(auto col1, auto col2);
3226
3227
3229
3240 hash<ColumnOperatorInfo> cop_substr(auto column, int start, *int count);
3241
3242
3244
3255 hash<ColumnOperatorInfo> cop_length(auto column);
3256
3257
3259
3273 hash<ColumnOperatorInfo> cop_trunc_date(auto column, string mask);
3274
3275
3276
3278
3306 hash<ColumnOperatorInfo> cop_cume_dist();
3307
3308
3310
3338 hash<ColumnOperatorInfo> cop_dense_rank();
3339
3340
3342
3370 hash<ColumnOperatorInfo> cop_first_value(any column);
3371
3372
3374
3402 hash<ColumnOperatorInfo> cop_last_value(any column);
3403
3404
3406
3436 hash<ColumnOperatorInfo> cop_ntile(int value);
3437
3438
3440
3468 hash<ColumnOperatorInfo> cop_percent_rank();
3469
3470
3472
3500 hash<ColumnOperatorInfo> cop_rank();
3501
3502
3504
3532 hash<ColumnOperatorInfo> cop_row_number();
3533
3534
3536
3588 const DT_YEAR = "Y";
3589
3591 const DT_MONTH = "M";
3592
3594 const DT_DAY = "D";
3595
3597 const DT_HOUR = "H";
3598
3600 const DT_MINUTE = "m";
3601
3603 const DT_SECOND = "S";
3604
3605 // let's simulate and enum here'
3606 const DT_ALL_VALUES = ( DT_YEAR, DT_MONTH, DT_DAY, DT_HOUR, DT_MINUTE, DT_SECOND );
3608
3614 const DefaultUopMap = ...;
3615
3617
3640
3648 hash<UpdateOperatorInfo> make_uop(string uop, auto arg, *hash<UpdateOperatorInfo> nest);
3649
3650
3652
3662 hash<UpdateOperatorInfo> uop_prepend(string arg, *hash<UpdateOperatorInfo> nest);
3663
3664
3666
3676 hash<UpdateOperatorInfo> uop_append(string arg, *hash<UpdateOperatorInfo> nest);
3677
3678
3680
3689 hash<UpdateOperatorInfo> uop_upper(*hash<UpdateOperatorInfo> nest);
3690
3691
3693
3702 hash<UpdateOperatorInfo> uop_lower(*hash<UpdateOperatorInfo> nest);
3703
3704
3706
3717 hash<UpdateOperatorInfo> uop_substr(int start, *int count, *hash<UpdateOperatorInfo> nest);
3718
3719
3721
3731 hash<UpdateOperatorInfo> uop_plus(auto arg, *hash<UpdateOperatorInfo> nest);
3732
3733
3735
3745 hash<UpdateOperatorInfo> uop_minus(auto arg, *hash<UpdateOperatorInfo> nest);
3746
3747
3749
3759 hash<UpdateOperatorInfo> uop_multiply(auto arg, *hash<UpdateOperatorInfo> nest);
3760
3761
3763
3773 hash<UpdateOperatorInfo> uop_divide(auto arg, *hash<UpdateOperatorInfo> nest);
3774
3775
3777
3786 hash<UpdateOperatorInfo> uop_seq(string seq);
3787
3788
3790
3799 hash<UpdateOperatorInfo> uop_seq_currval(string seq);
3800
3802
3810
3812 const JOP_INNER = "inner";
3813
3815
3817 const JOP_LEFT = "left";
3818
3820
3822 const JOP_RIGHT = "right";
3823
3825 const JopMap = {
3826 JOP_INNER: "inner",
3827 JOP_LEFT: "left outer",
3828 JOP_RIGHT: "right outer",
3829 };
3831
3842
3845 hash<string, hash<JoinOperatorInfo>> make_jop(string jop, AbstractTable table, *string alias, *hash jcols, *hash cond, *string ta, *hash<auto> opt);
3846
3847
3849
3853 hash<string, hash<JoinOperatorInfo>> make_jop(string jop, string table_name, *string alias, *hash jcols, *hash cond, *string ta, *hash<auto> opt);
3854
3855
3857
3876 hash<string, hash<JoinOperatorInfo>> join_inner(AbstractTable table, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
3877
3878
3880
3899 hash<string, hash<JoinOperatorInfo>> join_inner(Table table, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
3900
3901
3903
3922 hash<string, hash<JoinOperatorInfo>> join_inner(string table_name, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
3923
3924
3926
3948 hash<string, hash<JoinOperatorInfo>> join_inner(string ta, AbstractTable table, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
3949
3950
3952
3972 hash<string, hash<JoinOperatorInfo>> join_inner(string ta, Table table, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
3973
3974
3976
3998 hash<string, hash<JoinOperatorInfo>> join_inner_alias(string ta, string table_name, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
3999
4000
4002
4021 hash<string, hash<JoinOperatorInfo>> join_left(AbstractTable table, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
4022
4023
4025
4044 hash<string, hash<JoinOperatorInfo>> join_left(Table table, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
4045
4046
4048
4069 hash<string, hash<JoinOperatorInfo>> join_left(string table_name, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
4070
4071
4073
4093 hash<string, hash<JoinOperatorInfo>> join_left(string ta, AbstractTable table, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
4094
4095
4097
4117 hash<string, hash<JoinOperatorInfo>> join_left(string ta, Table table, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
4118
4119
4121
4143 hash<string, hash<JoinOperatorInfo>> join_left_alias(string ta, string table_name, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
4144
4145
4147
4166 hash<string, hash<JoinOperatorInfo>> join_right(AbstractTable table, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
4167
4168
4170
4189 hash<string, hash<JoinOperatorInfo>> join_right(Table table, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
4190
4191
4193
4214 hash<string, hash<JoinOperatorInfo>> join_right(string table_name, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
4215
4216
4218
4238 hash<string, hash<JoinOperatorInfo>> join_right(string ta, AbstractTable table, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
4239
4240
4242
4262 hash<string, hash<JoinOperatorInfo>> join_right(string ta, Table table, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
4263
4264
4266
4288 hash<string, hash<JoinOperatorInfo>> join_right_alias(string ta, string table_name, *string alias, *hash jcols, *hash cond, *hash<auto> opt);
4289
4291
4297
4299 const OP_LIKE = "like";
4300
4302
4304 const OP_LT = "<";
4305
4307
4309 const OP_LE = "<=";
4310
4312
4314 const OP_GT = ">";
4315
4317
4319 const OP_GE = ">=";
4320
4322
4324 const OP_NE = "!=";
4325
4327
4329 const OP_EQ = "=";
4330
4332
4334 const OP_CLT = "C<";
4335
4337
4339 const OP_CLE = "C<=";
4340
4342
4344 const OP_CGT = "C>";
4345
4347
4349 const OP_CGE = "C>=";
4350
4352
4354 const OP_CNE = "C!=";
4355
4357
4359 const OP_CEQ = "C=";
4360
4362
4364 const OP_BETWEEN = "between";
4365
4367
4369 const OP_IN = "in";
4370
4372
4374 const OP_NOT = "not";
4375
4377
4379 const OP_SUBSTR = "substr";
4380
4382
4384 const OP_OR = "or";
4385
4387
4389 const OP_IN_SELECT = "in_select";
4390
4393 // first the "AND" and "OR" "operators"
4394 DP_OP_AND: {
4395 "exp": AbstractDataProvider::GenericExpressions{DP_OP_AND},
4396 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4397 return "("
4398 + (foldl $1 + " and " + $2,
4399 (map info.table.getExpressionArg(\info, role, $1, AbstractDataProviderTypeMap."bool"), args))
4400 + ")";
4401 },
4402 },
4403 DP_OP_OR: {
4404 "exp": AbstractDataProvider::GenericExpressions{DP_OP_OR},
4405 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4406 return "("
4407 + (foldl $1 + " or " + $2,
4408 (map info.table.getExpressionArg(\info, role, $1, AbstractDataProviderTypeMap."bool"), args))
4409 + ")";
4410 },
4411 },
4412 OP_LIKE: {
4413 "exp": <DataProviderExpressionInfo>{
4414 "type": DET_Operator,
4415 "label": "like",
4416 "name": "like",
4417 "desc": "The value to bind as the 'like' value (ex: '%some string%')",
4418 "symbol": "like",
4419 "args": (
4420 DataProviderSignatureStringType,
4421 DataProviderSignatureStringValueType,
4422 ),
4423 "return_type": AbstractDataProviderTypeMap."bool",
4424 },
4425 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4426 return sprintf("%s like %s",
4427 info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."string"),
4428 info.table.getExpressionArg(\info, role, args[1], AbstractDataProviderTypeMap."string"));
4429 },
4430 },
4431 OP_LT: {
4432 "exp": AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_LT},
4433 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4434 return sprintf("%s < %s",
4435 info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."any"),
4436 info.table.getExpressionArg(\info, role, args[1], AbstractDataProviderTypeMap."any"));
4437 },
4438 },
4439 OP_LE: {
4440 "exp": AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_LE},
4441 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4442 return sprintf("%s <= %s",
4443 info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."any"),
4444 info.table.getExpressionArg(\info, role, args[1], AbstractDataProviderTypeMap."any"));
4445 },
4446 },
4447 OP_GT: {
4448 "exp": AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_GT},
4449 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4450 return sprintf("%s > %s",
4451 info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."any"),
4452 info.table.getExpressionArg(\info, role, args[1], AbstractDataProviderTypeMap."any"));
4453 },
4454 },
4455 OP_GE: {
4456 "exp": AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_GE},
4457 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4458 return sprintf("%s >= %s",
4459 info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."any"),
4460 info.table.getExpressionArg(\info, role, args[1], AbstractDataProviderTypeMap."any"));
4461 },
4462 },
4463 OP_NE: {
4464 "exp": AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_NE},
4465 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4466 bool null0 = (args[0] === NULL || !exists args[0]);
4467 bool null1 = (args[1] === NULL || !exists args[1]);
4468 if (null0 && null1) {
4469 return "1 = 0";
4470 }
4471 if (null0) {
4472 return sprintf("%s is not null",
4473 info.table.getExpressionArg(\info, role, args[1], AbstractDataProviderTypeMap."any"));
4474 }
4475 if (null1) {
4476 return sprintf("%s is not null",
4477 info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."any"));
4478 }
4479 string exp0 = info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."any");
4480 string exp1 = info.table.getExpressionArg(\info, role, args[1], AbstractDataProviderTypeMap."any");
4481 return sprintf("%s != %s", exp0, exp1);
4482 },
4483 },
4484 OP_EQ: {
4485 "exp": AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_EQ},
4486 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4487 bool null0 = (args[0] === NULL || !exists args[0]);
4488 bool null1 = (args[1] === NULL || !exists args[1]);
4489 if (null0 && null1) {
4490 return "1 = 1";
4491 }
4492 if (null0) {
4493 return sprintf("%s is null",
4494 info.table.getExpressionArg(\info, role, args[1], AbstractDataProviderTypeMap."any"));
4495 }
4496 if (null1) {
4497 return sprintf("%s is null",
4498 info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."any"));
4499 }
4500 string exp0 = info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."any");
4501 string exp1 = info.table.getExpressionArg(\info, role, args[1], AbstractDataProviderTypeMap."any");
4502 return sprintf("%s = %s", exp0, exp1);
4503 },
4504 },
4505 OP_BETWEEN: {
4506 "exp": AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_BETWEEN},
4507 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4508 return sprintf("%s between %s and %s",
4509 info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."any"),
4510 info.table.getExpressionArg(\info, role, args[1], AbstractDataProviderTypeMap."any"),
4511 info.table.getExpressionArg(\info, role, args[2], AbstractDataProviderTypeMap."any"));
4512 },
4513 },
4514 OP_IN: {
4515 "exp": AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_IN},
4516 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4517 string exp0 = info.table.getExpressionArg(\info, role, shift args, AbstractDataProviderTypeMap."any");
4518 *string ins = (foldl $1 + "," + $2, (map info.table.getExpressionArg(\info, role, $1,
4519 AbstractDataProviderTypeMap."any"), args));
4520 return exists ins ? sprintf("%s in (%s)", exp0, ins) : "1 != 1";
4521 },
4522 },
4523 OP_NOT: {
4524 "exp": AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_NOT},
4525 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4526 return sprintf("not (%s)", info.table.getExpressionArg(\info, role, args[0],
4527 AbstractDataProviderTypeMap."bool"));
4528 },
4529 },
4530 OP_SUBSTR: {
4531 "exp": <DataProviderExpressionInfo>{
4532 "type": DET_Operator,
4533 "label": "substr",
4534 "name": "substr",
4535 "desc": "returns a substring from a string; args: string, int start char, [int length]",
4536 "symbol": "substr",
4537 "args": (
4538 DataProviderSignatureStringType,
4539 DataProviderSignatureIntValueType,
4540 DataProviderSignatureOptionalIntValueType,
4541 ),
4542 "return_type": AbstractDataProviderTypeMap."string",
4543 },
4544 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4545 string exp0 = info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."string");
4546 string exp1 = info.table.getExpressionArg(\info, role, args[1], AbstractDataProviderTypeMap."int");
4547 if (!exists args[2]) {
4548 return sprintf("substring(%s from %s)", exp0, exp1);
4549 }
4550 return sprintf("substring(%s from %s for %s)", exp0, exp1,
4551 info.table.getExpressionArg(\info, role, args[2], AbstractDataProviderTypeMap."int"));
4552 },
4553 },
4554 OP_IN_SELECT: {
4555 "exp": <DataProviderExpressionInfo>{
4556 "type": DET_Operator,
4557 "label": "in_select",
4558 "name": "in_select",
4559 "desc": "check if a value is in a sub-select; args: value, table name for the subselect, subselect "
4560 "query hash",
4561 "symbol": "in_select",
4562 "args": (
4563 DataProviderSignatureAnyType, # any value, expression, or field reference
4564 DataProviderSignatureStringValueType, # table name
4565 DataProviderSignatureHashValueType, # query hash
4566 ),
4567 "return_type": AbstractDataProviderTypeMap."bool",
4568 },
4569 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4570 string exp0 = info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."any");
4571 object subtable = info.table.getSubtableFromString(args[1], info.query_options);
4572 list<auto> subargs;
4573 string subsql = subtable.getSelectSql(args[2], \subargs);
4574 args += subargs;
4575 return sprintf("%s in (%s)", exp0, subsql);
4576 },
4577 },
4578 COP_AS: {
4579 "exp": <DataProviderExpressionInfo>{
4580 "type": DET_Operator,
4581 "label": "as",
4582 "name": "as",
4583 "desc": "aliases a result; args: expression or value, string label",
4584 "symbol": "as",
4585 "role": ER_Field,
4586 "args": (
4587 DataProviderSignatureAnyType,
4588 DataProviderSignatureStringValueType,
4589 ),
4590 "return_type": AbstractDataProviderTypeMap."any",
4591 },
4592 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4593 string exp = info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."any");
4594 string arg = args[1];
4595 info.pseudo_column_map{arg} = exp;
4596 return sprintf("%s as %s", exp, info.table.getColumnSqlName(arg));
4597 },
4598 },
4599 COP_PREPEND: {
4600 "exp": <DataProviderExpressionInfo>{
4601 "type": DET_Operator,
4602 "label": COP_PREPEND,
4603 "name": COP_PREPEND,
4604 "desc": "prepends a string to another string; args: string to be prepended, string to prepend to the "
4605 "first string",
4606 "symbol": COP_PREPEND,
4607 "args": (
4608 DataProviderSignatureStringType,
4609 DataProviderSignatureStringType,
4610 ),
4611 "return_type": AbstractDataProviderTypeMap."string",
4612 },
4613 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4614 string exp0 = info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."string");
4615 string exp1 = info.table.getExpressionArg(\info, role, args[1], AbstractDataProviderTypeMap."string");
4616 return sprintf("%s || %s", exp1, exp0);
4617 },
4618 },
4619 COP_APPEND: {
4620 "exp": <DataProviderExpressionInfo>{
4621 "type": DET_Operator,
4622 "label": COP_APPEND,
4623 "name": COP_APPEND,
4624 "desc": "appends or catenates a string to another string; args: string to be appended, string to "
4625 "append or concatenate to the first string",
4626 "symbol": COP_APPEND,
4627 "args": (
4628 DataProviderSignatureStringType,
4629 DataProviderSignatureStringType,
4630 ),
4631 "return_type": AbstractDataProviderTypeMap."string",
4632 },
4633 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4634 string exp0 = info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."string");
4635 string exp1 = info.table.getExpressionArg(\info, role, args[1], AbstractDataProviderTypeMap."string");
4636 return sprintf("%s || %s", exp0, exp1);
4637 },
4638 },
4639 COP_UPPER: {
4640 "exp": <DataProviderExpressionInfo>{
4641 "type": DET_Operator,
4642 "label": COP_UPPER,
4643 "name": COP_UPPER,
4644 "desc": "converts a string to all upper case; arg: string",
4645 "symbol": COP_UPPER,
4646 "args": (
4647 DataProviderSignatureStringType,
4648 ),
4649 "return_type": AbstractDataProviderTypeMap."string",
4650 },
4651 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4652 return sprintf("upper(%s)", info.table.getExpressionArg(\info, role, args[0],
4653 AbstractDataProviderTypeMap."string"));
4654 },
4655 },
4656 COP_LOWER: {
4657 "exp": <DataProviderExpressionInfo>{
4658 "type": DET_Operator,
4659 "label": COP_LOWER,
4660 "name": COP_LOWER,
4661 "desc": "converts a string to all lower case; arg: string",
4662 "symbol": COP_LOWER,
4663 "args": (
4664 DataProviderSignatureStringType,
4665 ),
4666 "return_type": AbstractDataProviderTypeMap."string",
4667 },
4668 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4669 return sprintf("lower(%s)", info.table.getExpressionArg(\info, role, args[0],
4670 AbstractDataProviderTypeMap."string"));
4671 },
4672 },
4673 COP_DISTINCT: {
4674 "exp": <DataProviderExpressionInfo>{
4675 "type": DET_Operator,
4676 "label": COP_DISTINCT,
4677 "name": COP_DISTINCT,
4678 "desc": "indicates that only records with distinct values of the given field should be returned",
4679 "symbol": COP_DISTINCT,
4680 "role": ER_Field,
4681 "args": (
4682 DataProviderSignatureAnyType,
4683 ),
4684 "return_type": AbstractDataProviderTypeMap."any",
4685 },
4686 "code": string sub (reference<hash<QueryInfo>> info, int role, *list<auto> args) {
4687 return sprintf("distinct %s", info.table.getExpressionArg(\info, role, args[0],
4688 AbstractDataProviderTypeMap."any"));
4689 },
4690 },
4691 COP_MIN: {
4692 "exp": <DataProviderExpressionInfo>{
4693 "type": DET_Operator,
4694 "label": COP_MIN,
4695 "name": COP_MIN,
4696 "desc": "Returns the minimum value in the group",
4697 "symbol": COP_MIN,
4698 "role": ER_Field,
4699 "args": (
4700 DataProviderSignatureAnyType,
4701 ),
4702 "return_type": AbstractDataProviderTypeMap."any",
4703 },
4704 "code": string sub (reference<hash<QueryInfo>> info, int role, *list<auto> args) {
4705 return sprintf("min(%s)", info.table.getExpressionArg(\info, role, args[0],
4706 AbstractDataProviderTypeMap."any"));
4707 },
4708 "group": True,
4709 },
4710 COP_MAX: {
4711 "exp": <DataProviderExpressionInfo>{
4712 "type": DET_Operator,
4713 "label": COP_MAX,
4714 "name": COP_MAX,
4715 "desc": "Returns the maximum value in the group",
4716 "symbol": COP_MAX,
4717 "role": ER_Field,
4718 "args": (
4719 DataProviderSignatureAnyType,
4720 ),
4721 "return_type": AbstractDataProviderTypeMap."any",
4722 },
4723 "code": string sub (reference<hash<QueryInfo>> info, int role, *list<auto> args) {
4724 return sprintf("max(%s)", info.table.getExpressionArg(\info, role, args[0],
4725 AbstractDataProviderTypeMap."any"));
4726 },
4727 "group": True,
4728 },
4729 COP_AVG: {
4730 "exp": <DataProviderExpressionInfo>{
4731 "type": DET_Operator,
4732 "label": COP_AVG,
4733 "name": COP_AVG,
4734 "desc": "Returns the average of the given values in the group",
4735 "symbol": COP_AVG,
4736 "role": ER_Field,
4737 "args": (
4738 DataProviderSignatureAnyType,
4739 ),
4740 "return_type": AbstractDataProviderTypeMap."any",
4741 },
4742 "code": string sub (reference<hash<QueryInfo>> info, int role, *list<auto> args) {
4743 return sprintf("avg(%s)", info.table.getExpressionArg(\info, role, args[0],
4744 AbstractDataProviderTypeMap."any"));
4745 },
4746 "group": True,
4747 },
4748 COP_SUM: {
4749 "exp": <DataProviderExpressionInfo>{
4750 "type": DET_Operator,
4751 "label": COP_SUM,
4752 "name": COP_SUM,
4753 "desc": "Returns the sum of the given values",
4754 "symbol": COP_SUM,
4755 "role": ER_Field,
4756 "args": (
4757 DataProviderSignatureAnyType,
4758 ),
4759 "return_type": AbstractDataProviderTypeMap."any",
4760 },
4761 "code": string sub (reference<hash<QueryInfo>> info, int role, *list<auto> args) {
4762 return sprintf("sum(%s)", info.table.getExpressionArg(\info, role, args[0],
4763 AbstractDataProviderTypeMap."any"));
4764 },
4765 "group": True,
4766 },
4767 COP_COUNT: {
4768 "exp": <DataProviderExpressionInfo>{
4769 "type": DET_Operator,
4770 "label": COP_COUNT,
4771 "name": COP_COUNT,
4772 "desc": "Count the number of rows in the group",
4773 "symbol": COP_COUNT,
4774 "role": ER_Field,
4775 "args": (
4776 DataProviderSignatureAnyType,
4777 ),
4778 "return_type": AbstractDataProviderTypeMap."int",
4779 },
4780 "code": string sub (reference<hash<QueryInfo>> info, int role, *list<auto> args) {
4781 if (exists args[0] && args[0] != NULL) {
4782 return sprintf("count(%s)", info.table.getExpressionArg(\info, role, args[0],
4783 AbstractDataProviderTypeMap."any"));
4784 }
4785 return "count(1)";
4786 },
4787 },
4788 COP_MINUS: {
4789 "exp": <DataProviderExpressionInfo>{
4790 "type": DET_Operator,
4791 "label": COP_MINUS,
4792 "name": COP_MINUS,
4793 "desc": "Subtracts one number from another",
4794 "symbol": COP_MINUS,
4795 "args": (
4796 DataProviderSignatureAnyType,
4797 DataProviderSignatureAnyType,
4798 ),
4799 "return_type": AbstractDataProviderTypeMap."any",
4800 },
4801 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4802 string exp0 = info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."any");
4803 string exp1 = info.table.getExpressionArg(\info, role, args[1], AbstractDataProviderTypeMap."any");
4804 return sprintf("%s - %s", exp0, exp1);
4805 },
4806 },
4807 COP_PLUS: {
4808 "exp": <DataProviderExpressionInfo>{
4809 "type": DET_Operator,
4810 "label": COP_PLUS,
4811 "name": COP_PLUS,
4812 "desc": "Adds two numbers",
4813 "symbol": COP_PLUS,
4814 "args": (
4815 DataProviderSignatureAnyType,
4816 DataProviderSignatureAnyType,
4817 ),
4818 "return_type": AbstractDataProviderTypeMap."any",
4819 },
4820 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4821 string exp0 = info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."any");
4822 string exp1 = info.table.getExpressionArg(\info, role, args[1], AbstractDataProviderTypeMap."any");
4823 return sprintf("%s + %s", exp0, exp1);
4824 },
4825 },
4826 COP_DIVIDE: {
4827 "exp": <DataProviderExpressionInfo>{
4828 "type": DET_Operator,
4829 "label": COP_DIVIDE,
4830 "name": COP_DIVIDE,
4831 "desc": "Divides one number by another",
4832 "symbol": COP_DIVIDE,
4833 "args": (
4834 DataProviderSignatureAnyType,
4835 DataProviderSignatureAnyType,
4836 ),
4837 "return_type": AbstractDataProviderTypeMap."any",
4838 },
4839 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4840 string exp0 = info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."any");
4841 string exp1 = info.table.getExpressionArg(\info, role, args[1], AbstractDataProviderTypeMap."any");
4842 return sprintf("%s / %s", exp0, exp1);
4843 },
4844 },
4845 COP_MULTIPLY: {
4846 "exp": <DataProviderExpressionInfo>{
4847 "type": DET_Operator,
4848 "label": COP_MULTIPLY,
4849 "name": COP_MULTIPLY,
4850 "desc": "Multiplies two numbers",
4851 "symbol": COP_MULTIPLY,
4852 "args": (
4853 DataProviderSignatureAnyType,
4854 DataProviderSignatureAnyType,
4855 ),
4856 "return_type": AbstractDataProviderTypeMap."any",
4857 },
4858 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4859 string exp0 = info.table.getExpressionArg(\info, role, args[0], AbstractDataProviderTypeMap."any");
4860 string exp1 = info.table.getExpressionArg(\info, role, args[1], AbstractDataProviderTypeMap."any");
4861 return sprintf("%s * %s", exp0, exp1);
4862 },
4863 },
4864 COP_COALESCE: {
4865 "exp": <DataProviderExpressionInfo>{
4866 "type": DET_Operator,
4867 "label": COP_COALESCE,
4868 "name": COP_COALESCE,
4869 "desc": "Returns the value of the first expression with a value",
4870 "symbol": COP_COALESCE,
4871 "args": (
4872 DataProviderSignatureAnyType,
4873 ),
4874 "varargs": True,
4875 "return_type": AbstractDataProviderTypeMap."any",
4876 },
4877 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4878 return sprintf("coalesce(%s)", (foldl $1 + "," + $2,
4879 (map info.table.getExpressionArg(\info, role, $1, AbstractDataProviderTypeMap."any"), args)));
4880 }
4881 },
4882 COP_LENGTH: {
4883 "exp": <DataProviderExpressionInfo>{
4884 "type": DET_Operator,
4885 "label": COP_LENGTH,
4886 "name": COP_LENGTH,
4887 "desc": "Returns the length of the argument",
4888 "symbol": COP_LENGTH,
4889 "args": (
4890 DataProviderSignatureAnyType,
4891 ),
4892 "return_type": AbstractDataProviderTypeMap."int",
4893 },
4894 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4895 return sprintf("length(%s)", info.table.getExpressionArg(\info, role, args[0],
4896 AbstractDataProviderTypeMap."any"));
4897 },
4898 },
4899 COP_SEQ: {
4900 "exp": <DataProviderExpressionInfo>{
4901 "type": DET_Operator,
4902 "label": COP_SEQ,
4903 "name": COP_SEQ,
4904 "desc": "returns the next value in the given sequence; args: sequence name",
4905 "symbol": COP_SEQ,
4906 "args": (
4907 DataProviderSignatureStringValueType,
4908 ),
4909 "return_type": AbstractDataProviderTypeMap."int",
4910 },
4911 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4912 throw "SEQUENCE-ERROR", sprintf("cannot select sequence %y because this database does not support "
4913 "sequences", args[0]);
4914 }
4915 },
4917 "exp": <DataProviderExpressionInfo>{
4918 "type": DET_Operator,
4919 "label": COP_SEQ_CURRVAL,
4920 "name": COP_SEQ_CURRVAL,
4921 "desc": "returns the current value in the given sequence; args: sequence name",
4922 "symbol": COP_SEQ_CURRVAL,
4923 "args": (
4924 DataProviderSignatureStringValueType,
4925 ),
4926 "return_type": AbstractDataProviderTypeMap."int",
4927 },
4928 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4929 throw "SEQUENCE-ERROR", sprintf("cannot select the current value of sequence %y because this "
4930 "database does not support sequences", args[0]);
4931 }
4932 },
4933 COP_OVER: {
4934 "exp": <DataProviderExpressionInfo>{
4935 "type": DET_Operator,
4936 "label": COP_OVER,
4937 "name": COP_OVER,
4938 "desc": "returns the output of the SQL window given by the arguments; args: *string partiion by, "
4939 "*string order by",
4940 "symbol": COP_OVER,
4941 "args": (
4942 DataProviderSignatureFieldType,
4943 DataProviderSignatureOptionalStringValueType,
4944 DataProviderSignatureOptionalStringValueType,
4945 ),
4946 "role": ER_Field,
4947 "return_type": AbstractDataProviderTypeMap."any",
4948 },
4949 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4950 string column_name = args[0];
4951 *string partitionby = args[1];
4952 *string orderby = args[2];
4953 if (!exists partitionby && exists orderby) {
4954 throw "OVER-ERROR", "Argument 2 (partition by) must be given in case of usage of argument 3 "
4955 "(order by)";
4956 }
4957 string sql = column_name + " over (";
4958 Columns cols;
4959 if (exists partitionby) {
4960 if (!info.pseudo_column_map{partitionby}) {
4961 cols = info.table.describe();
4962 if (!exists cols{partitionby}) {
4963 throw "OVER-ERROR", sprintf("Argument 2 (partition by) %y is not an alias or an "
4964 "accessible column", partitionby);
4965 }
4966 }
4967 sql += sprintf("partition by %s", partitionby);
4968 }
4969 if (exists orderby) {
4970 if (!info.pseudo_column_map{orderby}) {
4971 if (!cols) {
4972 cols = info.table.describe();
4973 if (!exists cols{orderby}) {
4974 throw "OVER-ERROR", sprintf("Argument 3 (order by) %y is not an alias or an "
4975 "accessible column", orderby);
4976 }
4977 }
4978 }
4979 sql += sprintf(" order by %s", orderby);
4980 }
4981 sql += ")";
4982 return sql;
4983 }
4984 },
4986 "exp": <DataProviderExpressionInfo>{
4987 "type": DET_Operator,
4988 "label": COP_DENSE_RANK,
4989 "name": COP_DENSE_RANK,
4990 "desc": "Returns the rank of a row in an ordered group of rows as a number",
4991 "symbol": COP_DENSE_RANK,
4992 "args": (),
4993 "role": ER_Field,
4994 "return_type": AbstractDataProviderTypeMap."any",
4995 },
4996 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
4997 return "dense_rank()";
4998 },
4999 ),
5001 "exp": <DataProviderExpressionInfo>{
5002 "type": DET_Operator,
5003 "label": COP_FIRST_VALUE,
5004 "name": COP_FIRST_VALUE,
5005 "desc": "Returns the first value in an ordered group of rows",
5006 "symbol": COP_FIRST_VALUE,
5007 "args": (
5008 DataProviderSignatureFieldType,
5009 ),
5010 "role": ER_Field,
5011 "return_type": AbstractDataProviderTypeMap."any",
5012 },
5013 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
5014 return sprintf("first_value(%s)", args[0]);
5015 },
5016 ),
5018 "exp": <DataProviderExpressionInfo>{
5019 "type": DET_Operator,
5020 "label": COP_LAST_VALUE,
5021 "name": COP_LAST_VALUE,
5022 "desc": "Returns the last value in an ordered group of rows",
5023 "symbol": COP_LAST_VALUE,
5024 "args": (
5025 DataProviderSignatureFieldType,
5026 ),
5027 "role": ER_Field,
5028 "return_type": AbstractDataProviderTypeMap."any",
5029 },
5030 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
5031 return sprintf("last_value(%s)", args[0]);
5032 },
5033 ),
5034 COP_NTILE: (
5035 "exp": <DataProviderExpressionInfo>{
5036 "type": DET_Operator,
5037 "label": COP_NTILE,
5038 "name": COP_NTILE,
5039 "desc": "Returns the group number of an ordered group of rows",
5040 "symbol": COP_NTILE,
5041 "args": (
5042 DataProviderSignatureIntValueType,
5043 ),
5044 "role": ER_Field,
5045 "return_type": AbstractDataProviderTypeMap."int",
5046 },
5047 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
5048 return sprintf("ntile(%d)", args[0]);
5049 },
5050 ),
5052 "exp": <DataProviderExpressionInfo>{
5053 "type": DET_Operator,
5054 "label": COP_PERCENT_RANK,
5055 "name": COP_PERCENT_RANK,
5056 "desc": "Returns the percent rank of a row in an ordered group of rows",
5057 "symbol": COP_PERCENT_RANK,
5058 "args": (),
5059 "role": ER_Field,
5060 "return_type": AbstractDataProviderTypeMap."int",
5061 },
5062 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
5063 return "percent_rank()";
5064 },
5065 ),
5066 COP_RANK: (
5067 "exp": <DataProviderExpressionInfo>{
5068 "type": DET_Operator,
5069 "label": COP_PERCENT_RANK,
5070 "name": COP_PERCENT_RANK,
5071 "desc": "Returns the row number of a row in an ordered group of rows",
5072 "symbol": COP_PERCENT_RANK,
5073 "args": (),
5074 "role": ER_Field,
5075 "return_type": AbstractDataProviderTypeMap."int",
5076 },
5077 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
5078 return "rank()";
5079 },
5080 ),
5082 "exp": <DataProviderExpressionInfo>{
5083 "type": DET_Operator,
5084 "label": COP_ROW_NUMBER,
5085 "name": COP_ROW_NUMBER,
5086 "desc": "Returns the row number of a result set",
5087 "symbol": COP_ROW_NUMBER,
5088 "args": (),
5089 "role": ER_Field,
5090 "return_type": AbstractDataProviderTypeMap."int",
5091 },
5092 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
5093 return "row_number()";
5094 },
5095 ),
5096 };
5097
5100 OP_LIKE: {
5101 "code": string sub (reference<hash<QueryInfo>> info, string cn, auto arg) {
5102 info.args += arg;
5103 return sprintf("%s like %v", cn);
5104 },
5105 "name": "like",
5106 "args": (DataProviderSignatureStringType, DataProviderSignatureStringValueType),
5107 "return_type": AbstractDataProviderTypeMap."bool",
5108 "desc": "The value to bind as the 'like' value (ex: '%some string%')",
5109 },
5110 OP_LT: AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_LT} + (
5111 "code": string sub (reference<hash<QueryInfo>> info, string cn, auto arg) {
5112 info.args += arg;
5113 return sprintf("%s < %v", cn);
5114 },
5115 ),
5116 OP_LE: AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_LE} + (
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_GT: AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_GT} + (
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_GE: AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_GE} + (
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_NE: AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_NE} + (
5135 "code": string sub (reference<hash<QueryInfo>> info, string cn, auto arg) {
5136 if (arg === NULL || !exists arg)
5137 return sprintf("%s is not null", cn);
5138 info.args += arg;
5139 return sprintf("(%s != %v or %s is null)", cn, cn);
5140 },
5141 ),
5142 OP_EQ: AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_EQ} + (
5143 "code": string sub (reference<hash<QueryInfo>> info, string cn, auto arg) {
5144 if (arg === NULL || !exists arg)
5145 return sprintf("%s is null", cn);
5146 info.args += arg;
5147 return sprintf("%s = %v", cn);
5148 },
5149 ),
5150 OP_BETWEEN: AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_BETWEEN} + (
5151 "code": string sub (reference<hash<QueryInfo>> info, string cn, auto arg) {
5152 info.args += arg[0];
5153 info.args += arg[1];
5154 return sprintf("%s between %v and %v", cn);
5155 },
5156 ),
5157 OP_IN: AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_IN} + (
5158 "code": string sub (reference<hash<QueryInfo>> info, string cn, auto arg) {
5159 *string ins = (foldl $1 + "," + $2, (map info.table.getSqlValue($1), arg));
5160 return exists ins ? sprintf("%s in (%s)", cn, ins) : "1 != 1";
5161 },
5162 ),
5163 OP_IN_SELECT: {
5164 "code": string sub (reference<hash<QueryInfo>> info, string cn, auto arg,
5165 *hash<auto> opt) {
5166 object subtable;
5167 if (arg.table.typeCode() == NT_STRING) {
5168 subtable = info.table.getSubtableFromString(arg.table, opt);
5169 } else {
5170 subtable = arg.table;
5171 }
5172
5173 list<auto> subargs;
5174 string subsql = subtable.getSelectSql(arg.select_hash, \subargs);
5175 info.args += subargs;
5176 return sprintf("%s in (%s)", cn, subsql);
5177 },
5178 "withopt": True,
5179 },
5180 OP_NOT: AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_NOT} + (
5181 "recursive": True,
5182 "code": string sub (reference<hash<QueryInfo>> info, string cn, auto arg) {
5183 return sprintf("not (%s)", cn);
5184 },
5185 ),
5186 OP_CLT: (
5187 "argcolumn": True,
5188 "code": string sub (reference<hash<QueryInfo>> info, string cn, auto arg) {
5189 return sprintf("%s < %s", cn, arg);
5190 },
5191 "name": "column <",
5192 "type": AbstractDataProviderType::get(StringType),
5193 "desc": "a column name for less than comparisons; if the field value is less than the column argument's "
5194 "value, then the operation returns true; the other column must have a compatible type",
5195 ),
5196 OP_CLE: (
5197 "argcolumn": True,
5198 "code": string sub (reference<hash<QueryInfo>> info, string cn, auto arg) {
5199 return sprintf("%s <= %s", cn, arg);
5200 },
5201 "name": "column <=",
5202 "type": AbstractDataProviderType::get(StringType),
5203 "desc": "a column name for less than or equals comparisons; if the field value is less than or equal to "
5204 "the column argument's, then the operation returns true; the other column must have a compatible type",
5205 ),
5206 OP_CGT: (
5207 "argcolumn": True,
5208 "code": string sub (reference<hash<QueryInfo>> info, string cn, auto arg) {
5209 return sprintf("%s > %s", cn, arg);
5210 },
5211 "name": "column >",
5212 "type": AbstractDataProviderType::get(StringType),
5213 "desc": "a column name for less than comparisons; if the field value is less than the column argument's, "
5214 "then the operation returns true; the other column must have a compatible type",
5215 ),
5216 OP_CGE: (
5217 "argcolumn": True,
5218 "code": string sub (reference<hash<QueryInfo>> info, string cn, auto arg) {
5219 return sprintf("%s >= %s", cn, arg);
5220 },
5221 "name": "column >=",
5222 "type": AbstractDataProviderType::get(StringType),
5223 "desc": "a column name for greater than or equals comparisons; if the field value is greater than or "
5224 "equal to the column argument's, then the operation returns true; the other column must have a "
5225 "compatible type",
5226 ),
5227 OP_CNE: (
5228 "argcolumn": True,
5229 "code": string sub (reference<hash<QueryInfo>> info, string cn, auto arg) {
5230 return sprintf("%s != %s", cn, arg);
5231 },
5232 "name": "column !=",
5233 "type": AbstractDataProviderType::get(StringType),
5234 "desc": "a column name for not=equals comparisons; the other column must have a compatible type",
5235 ),
5236 OP_CEQ: (
5237 "argcolumn": True,
5238 "code": string sub (reference<hash<QueryInfo>> info, string cn, string arg) {
5239 return sprintf("%s = %s", cn, arg);
5240 },
5241 "name": "column =",
5242 "type": AbstractDataProviderType::get(StringType),
5243 "desc": "a value for equality comparisons; the other column must have a compatible type",
5244 ),
5245 OP_SUBSTR: (
5246 "code": string sub (reference<hash<QueryInfo>> info, string cn, auto arg) {
5247 info.args += arg[0]; // start
5248 if (!exists arg[1]) {
5249 info.args += arg[2]; # text
5250 return sprintf("substring(%s from %v) = %v", cn);
5251 }
5252 info.args += arg[1]; # count
5253 info.args += arg[2]; # text
5254 return sprintf("substring(%s from %v for %v) = %v", cn);
5255 },
5256 ),
5257 OP_OR: (
5258 "code": string sub (reference<hash<QueryInfo>> info, string cn, list<auto> arg) {
5259 return info.table.getOrClause(\info, arg);
5260 },
5261 ),
5262 };
5264
5289 hash<OperatorInfo> make_op(string op, auto arg);
5290
5291
5293
5302 hash<OperatorInfo> op_like(string str);
5303
5304
5306
5317 hash<OperatorInfo> op_lt(auto arg);
5318
5319
5321
5332 hash<OperatorInfo> op_le(auto arg);
5333
5334
5336
5347 hash<OperatorInfo> op_gt(auto arg);
5348
5349
5351
5362 hash<OperatorInfo> op_ge(auto arg);
5363
5364
5366
5379 hash<OperatorInfo> op_ne(auto arg);
5380
5381
5383
5396 hash<OperatorInfo> op_eq(auto arg);
5397
5398
5400
5412 hash<OperatorInfo> op_between(auto l, auto r);
5413
5414
5416
5425 hash<OperatorInfo> op_in();
5426
5427
5429
5436 hash<OperatorInfo> op_in_select(string table, hash<auto> select_hash);
5437
5438
5440
5447 hash<OperatorInfo> op_in_select(AbstractTable table, hash<auto> select_hash);
5448
5449
5451
5458 hash<OperatorInfo> op_in_select(Table table, hash<auto> select_hash);
5459
5460
5462
5473 hash<OperatorInfo> op_in(list<auto> args);
5474
5475
5477
5484 hash<OperatorInfo> op_not(hash arg);
5485
5486
5488
5499 hash<OperatorInfo> op_clt(string arg);
5500
5501
5503
5514 hash<OperatorInfo> op_cle(string arg);
5515
5516
5518
5529 hash<OperatorInfo> op_cgt(string arg);
5530
5531
5533
5544 hash<OperatorInfo> op_cge(string arg);
5545
5546
5548
5559 hash<OperatorInfo> op_cne(string arg);
5560
5561
5563
5574 hash<OperatorInfo> op_ceq(string arg);
5575
5576
5578
5589 hash<OperatorInfo> op_substr(int start, *int count, string text);
5590
5591
5593
5603 hash<OperatorInfo> op_substr(int start, string text);
5604
5605
5607
5624 hash<string, hash<OperatorInfo>> wop_or(hash h1, hash h2);
5625
5627
5635
5637 const IOP_SEQ = "seq";
5638
5640
5642 const IOP_SEQ_CURRVAL = "seq_currval";
5643
5645 const DefaultIopMap = {};
5647
5654
5661 hash<InsertOperatorInfo> make_iop(string iop, auto arg);
5662
5663
5665
5674 hash<InsertOperatorInfo> iop_seq(string arg);
5675
5676
5678
5687 hash<InsertOperatorInfo> iop_seq_currval(string arg);
5688
5690
5692 const SqlUtilDrivers = ...;
5693
5694
5695 // private variable to store the closure used to deserialize datasources (if any)
5696 extern code ds_get;
5697
5698 // private variable to store the closure used to serialize datasources (if any)
5699 extern code ds_do;
5700
5703
5704
5707
5708
5709 // private function used to deserialize datasources
5710 AbstractDatasource sqlutil_get_ds(string type, string config);
5711
5712
5713 // private function used to serialize datasources
5714 hash<auto> sqlutil_ds(AbstractDatasource ds);
5715
5716
5719
5720public:
5721
5722
5723protected:
5725 *hash h;
5726
5727public:
5728
5730 constructor(*hash nh);
5731
5732
5735
5736
5739
5740
5742
5757 auto memberGate(string k);
5758
5759
5761
5768
5769
5771 abstract auto take(string k);
5772
5774 renameKey(string old_name, string new_name);
5775
5776
5778 *hash<auto> getHash();
5779
5780
5782
5791 bool matchKeys(hash h1);
5792
5793
5795
5804 bool matchKeys(list<auto> l);
5805
5806
5808
5818
5819
5821
5830 bool partialMatchKeys(hash h1);
5831
5832
5834
5843 bool partialMatchKeys(list<auto> l);
5844
5845
5847
5857
5858
5860
5869 bool val();
5870
5871
5873
5880 list<string> keys();
5881
5882
5884
5891 list<auto> values();
5892
5893
5895
5903
5904
5906
5914
5915
5917
5925
5926
5928 bool empty();
5929
5930
5932
5939 int size();
5940
5941
5943
5952 bool hasKey(string k);
5953
5954
5956
5965 bool hasKeyValue(string k);
5966
5967
5969
5978 *string firstKey();
5979
5980
5982
5991 *string lastKey();
5992
5993
5995 abstract string getElementName();
5996 };
5997
6000
6001public:
6002
6003
6004protected:
6005 softlist l;
6006
6007public:
6008
6010 constructor(softlist nl);
6011
6012
6014
6025 abstract auto get(softint i);
6026
6028 add(auto val);
6029
6030
6032 auto take(int i);
6033
6034
6036 list<auto> getList();
6037
6038
6040
6049 bool val();
6050
6051
6053
6061
6062
6064 bool empty();
6065
6066
6068
6075 int size();
6076
6077
6079 abstract string getElementName();
6080
6081protected:
6082 checkIndex(int i);
6083public:
6084
6085 };
6086
6089
6090public:
6093
6094
6096 constructor(AbstractDatasource ds, hash tables, *hash<auto> opt);
6097
6098
6100 constructor(AbstractDatasource ds);
6101
6102
6104 add(string k, Table val);
6105
6106
6109
6110
6113
6114
6117
6118
6121
6122
6124 populate(AbstractDatasource ds, hash<auto> tables, *hash<auto> opt);
6125
6126
6128 populate(AbstractDatasource ds);
6129
6130
6132
6148 *list<auto> getDropAllForeignConstraintsOnTableSql(string name, *hash<auto> opt);
6149
6150
6152
6168
6169
6172
6173
6175 *AbstractTable getIfExists(AbstractDatasource ds, string name);
6176
6177
6179 AbstractTable get(AbstractDatasource ds, string name);
6180
6181
6183
6198 *string getRenameTableIfExistsSql(string old_name, string new_name, *hash<auto> opts);
6199
6200
6202
6213 bool tableRenamed(string old_name, string new_name, string old_sql_name);
6214
6215
6216protected:
6217 tableRenamedIntern(string old_name, string new_name, string oldsn);
6218public:
6219
6220
6222
6237 *string getDropConstraintIfExistsSql(string tname, string cname, *hash<auto> opts);
6238
6239
6240 list<auto> getCreateList();
6241
6242
6243 Qore::AbstractIterator createIterator();
6244
6245
6247
6255 list<auto> getDropList();
6256
6257
6259
6267
6268
6269protected:
6270 getDependencies(reference<hash> tdh, reference<hash> sdh, *reference<hash> th);
6271public:
6272
6273 };
6274
6277
6278public:
6280 constructor(*hash c) ;
6281
6282
6285
6286
6289
6290
6293
6294
6296
6312
6313
6315 Columns subset(softlist l);
6316
6317
6320
6321
6323 bool equal(Columns cols);
6324
6325
6327 AbstractIterator getSqlColumnNameIterator();
6328
6329 };
6330
6333
6334public:
6336 string name;
6337
6339 string ddl_name;
6340
6342protected:
6344public:
6345
6346
6349
6350
6352
6354 abstract string getDdlName(string name);
6355 };
6356
6359
6360public:
6363
6365 *string qore_type;
6366
6368 int size;
6369
6372
6374 *string def_val;
6375
6377 *string comment;
6378
6380 *int scale;
6381
6384
6386protected:
6388public:
6389
6390
6391 constructor(string n, string nt, *string qt, int sz, bool nul, *string dv, *string c, *int scale)
6392 ;
6393
6394
6396
6400 hash<GenericColumnInfo> getDescriptionHash();
6401
6402
6404
6407
6408
6411
6412
6414
6423 abstract list<auto> getAddColumnSql(AbstractTable t);
6424
6426 string getDropSql(string table_name);
6427
6428
6430
6443 list<auto> getModifySql(AbstractTable t, AbstractColumn c, *hash<auto> opt);
6444
6445
6447
6457 abstract string getRenameSql(AbstractTable t, string new_name);
6458
6461
6462
6464protected:
6465 abstract bool equalImpl(AbstractColumn c);
6466public:
6467
6469
6485protected:
6486 abstract list<auto> getModifySqlImpl(AbstractTable t, AbstractColumn c, *hash<auto> opt);
6487public:
6488 };
6489
6492
6493public:
6494 constructor(*hash c) ;
6495
6496
6499
6500
6503
6504
6507
6508
6511
6512
6514
6530
6531
6533
6534 };
6535
6538
6539public:
6541 string name;
6542
6545
6548
6549protected:
6552
6555
6556public:
6557
6559 constructor(string n, bool u, hash c);
6560
6561
6563 string getName();
6564
6565
6567 bool hasColumn(string cname);
6568
6569
6571 abstract string getCreateSql(string table_name, *hash<auto> opt);
6572
6574 string getDropSql(string table_name);
6575
6576
6579
6580
6583
6584
6586 abstract bool equalImpl(AbstractIndex ix);
6587
6589 abstract string getRenameSql(string table_name, string new_name);
6590
6593
6594
6597
6598
6601
6602
6605
6606
6609
6610
6613
6614
6616 *list<AbstractColumnConstraint> getAllSupportingConstraints();
6617
6618
6620 list<auto> getRecreateSql(AbstractDatasource ds, string table_name, *hash<auto> opt);
6621
6622 };
6623
6626
6627public:
6628 constructor(*hash c) ;
6629
6630
6633
6634
6637
6638
6641
6642
6644
6660
6661
6663
6664 };
6665
6668
6669public:
6670
6671
6672protected:
6674 string name;
6675
6676public:
6677
6679 constructor(string n);
6680
6681
6683 string getName();
6684
6685
6687 rename(string n);
6688
6689
6691 abstract string getCreateSql(string table_name, *hash<auto> opt);
6692
6694 string getDropSql(string table_name);
6695
6696
6698 abstract list<auto> getRenameSql(string table_name, string new_name);
6699
6701 string getDisableSql(string table_name);
6702
6703
6705 string getEnableSql(string table_name, *hash<auto> opt);
6706
6707
6710
6711
6713protected:
6715public:
6716
6718 abstract bool setIndexBase(string ix);
6719
6721 abstract clearIndex();
6722
6724 bool hasColumn(string cname);
6725
6726 };
6727
6730
6731public:
6733 string src;
6734
6736 constructor(string n, string n_src) ;
6737
6738
6740protected:
6742public:
6743
6744
6746 bool setIndexBase(string ix);
6747
6748
6751
6752 };
6753
6756
6757public:
6758protected:
6760 *string index;
6761
6762public:
6763
6765 constructor(string name, *hash<auto> cols, *string index) ;
6766
6767
6769 constructor(string name, Columns cols, *string index) ;
6770
6771
6773 bool setIndexBase(string ix);
6774
6775
6778
6779 };
6780
6783
6784public:
6785protected:
6787 *hash<string, hash<string, AbstractForeignConstraint>> sourceConstraints;
6788
6789public:
6790
6792 constructor(string name, *hash<auto> cols, *string index) ;
6793
6794
6796 constructor(string name, Columns cols, *string index) ;
6797
6798
6800
6805
6806
6808 hash<auto> getDisableReenableSql(AbstractDatasource ds, string table_name, *hash<auto> opts);
6809
6810
6813
6814
6816
6827
6828
6830 removeSourceConstraint(string tname, list<auto> cols);
6831
6832
6834 renameSourceConstraintTable(string old_name, string new_name);
6835
6836
6838 bool hasColumn(string cname);
6839
6840
6842 *string getIndex();
6843
6844
6846protected:
6848public:
6849
6850
6852 abstract string getCreateSql(string table_name, *hash<auto> opts);
6853 };
6854
6857
6858public:
6860 constructor(string n, *hash<auto> c, *string n_index) ;
6861
6862 };
6863
6866
6867public:
6868 constructor() ;
6869
6870
6871 constructor(string n, *hash<auto> c) ;
6872
6873 };
6874
6877
6878public:
6879 constructor(*hash<auto> c) ;
6880
6881
6884
6885
6888
6889
6892
6893
6895
6911
6912
6914 *hash<auto> findConstraintOn(string table, softlist<auto> cols);
6915
6916
6919
6920 };
6921
6924
6925public:
6927 string table;
6928
6931
6933 constructor(string t, Columns c);
6934
6935
6938
6939 };
6940
6943
6944public:
6947
6949
6950
6952protected:
6954public:
6955
6956 };
6957
6960
6961public:
6963 string name;
6964
6966 number start;
6967
6970
6972 *number max;
6973
6975 constructor(string n_name, number n_start = 1, number n_increment = 1, *softnumber n_max);
6976
6977
6979 abstract string getCreateSql(*hash<auto> opt);
6980
6982
6984 string getDropSql(*hash<auto> opt);
6985
6986
6988
6991 abstract softlist<auto> getRenameSql(string new_name, *hash<auto> opt);
6992 };
6993
6996
6997public:
6998 // ! potential object schema
6999 *string schema;
7000
7002 string name;
7003
7005 string src;
7006
7009
7011 constructor(string n_name, string n_src);
7012
7013
7015 abstract string getCreateSql(*hash<auto> opt);
7016
7018
7020 string getDropSql(*hash<auto> opt);
7021
7022
7024
7027 abstract softlist<auto> getRenameSql(string new_name, *hash<auto> opt);
7028 };
7029
7032
7033public:
7035 string name;
7036
7038 string type;
7039
7041 string src;
7042
7044
7048 constructor(string n, string n_type, string n_src);
7049
7050
7052 string getType();
7053
7054
7056
7058 string getDropSql(*hash<auto> opt);
7059
7060
7063
7064
7066 string getNormalizedSource(string src);
7067
7068
7070protected:
7072public:
7073 };
7074
7077
7078public:
7080
7084 constructor(string n, string n_type, string n_src) ;
7085
7086
7088 abstract list<auto> getCreateSql(*hash<auto> opt);
7089
7091
7094 abstract softlist<auto> getRenameSql(string new_name, *hash<auto> opt);
7095
7097 setName(string new_name);
7098
7099 };
7100
7103
7104public:
7105 constructor(*hash c) ;
7106
7107
7110
7111
7114
7115
7117
7133
7134
7136
7137 };
7138
7141
7142public:
7144 constructor(string n, string n_src) ;
7145
7146
7148 abstract list<auto> getCreateSql(string table_name, *hash<auto> opt);
7149
7151 abstract softlist<auto> getRenameSql(string table_name, string new_name);
7152
7154 abstract list<auto> getDropSql(string table_name);
7155 };
7156
7159
7160public:
7161 constructor(*hash c) ;
7162
7163
7166
7167
7170
7171
7173
7189
7190
7192
7193 };
7194};
abstract class for check constraints
Definition: SqlUtil.qm.dox.h:6729
string src
the source of the check clause
Definition: SqlUtil.qm.dox.h:6733
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:6755
*string index
the index supporting the constraint
Definition: SqlUtil.qm.dox.h:6760
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:6358
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:6362
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:6377
*string def_val
default value for column
Definition: SqlUtil.qm.dox.h:6374
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:6365
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:6371
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:6383
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:6368
*int scale
the scale for numeric columns
Definition: SqlUtil.qm.dox.h:6380
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:6782
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:6787
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:6667
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:6674
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:6332
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:6339
string name
the name of the object
Definition: SqlUtil.qm.dox.h:6336
constructor(string name)
creates the object from the name
the base class for foreign key constraint information
Definition: SqlUtil.qm.dox.h:6942
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:6946
base class for function or objects with code
Definition: SqlUtil.qm.dox.h:7031
string getNormalizedSource(string src)
returns normalized source for comparisons
string name
the name of the object
Definition: SqlUtil.qm.dox.h:7035
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:7041
string type
the type of object
Definition: SqlUtil.qm.dox.h:7038
string getType()
returns the type of object
base class for functions
Definition: SqlUtil.qm.dox.h:7076
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:5718
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:5725
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:6537
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:6554
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:6541
*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:6544
*AbstractColumnSupportingConstraint constraint
the AbstractColumnSupportingConstraint that this index supports, if any
Definition: SqlUtil.qm.dox.h:6551
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:6547
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:5999
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:6865
base class for sequences
Definition: SqlUtil.qm.dox.h:6959
*number max
the ending number
Definition: SqlUtil.qm.dox.h:6972
string name
the name of the sequence
Definition: SqlUtil.qm.dox.h:6963
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:6966
number increment
the increment
Definition: SqlUtil.qm.dox.h:6969
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:7140
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:6856
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:6995
bool updatable
Flag showing if is the view updatable with DML commands.
Definition: SqlUtil.qm.dox.h:7008
string name
the name of the sequence
Definition: SqlUtil.qm.dox.h:7002
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:7005
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:6276
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:6625
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:6923
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:6930
string table
the name of the target table
Definition: SqlUtil.qm.dox.h:6927
foreign constraint container class that throws an exception if an unknown constraint is accessed
Definition: SqlUtil.qm.dox.h:6876
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:7102
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:6491
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:6088
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:7158
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:2460
const SZ_NUM
the data type is numeric so takes an optional precision and scale
Definition: SqlUtil.qm.dox.h:2469
const SZ_MAND
the data type takes a mandatory size parameter
Definition: SqlUtil.qm.dox.h:2463
const SZ_OPT
the data type takes an optional size parameter
Definition: SqlUtil.qm.dox.h:2466
const CLOB
specifies a large variable-length character column (ie CLOB or TEXT, etc)
Definition: SqlUtil.qm.dox.h:2452
const DB_SYNONYMS
Feature: synonyms.
Definition: SqlUtil.qm.dox.h:2432
const DB_PACKAGES
Feature: packages.
Definition: SqlUtil.qm.dox.h:2420
const VARCHAR
Definition: SqlUtil.qm.dox.h:2440
const DB_MVIEWS
Feature: materialized views / snapshots.
Definition: SqlUtil.qm.dox.h:2418
const BLOB
specifies a large variable-length binary column (ie BLOB or BYTEA, etc)
Definition: SqlUtil.qm.dox.h:2449
const DB_PROCEDURES
Feature: procedures.
Definition: SqlUtil.qm.dox.h:2422
const DB_TABLES
Feature: tables.
Definition: SqlUtil.qm.dox.h:2426
const DB_VIEWS
Feature: views.
Definition: SqlUtil.qm.dox.h:2430
const CHAR
specifies a CHAR column
Definition: SqlUtil.qm.dox.h:2446
const NUMERIC
specifies a numeric column (equivalent to Qore::Type::Number)
Definition: SqlUtil.qm.dox.h:2443
const DB_FUNCTIONS
Feature: functions.
Definition: SqlUtil.qm.dox.h:2416
const DB_SEQUENCES
Feature: sequences.
Definition: SqlUtil.qm.dox.h:2424
const DB_TYPES
Feature: named types.
Definition: SqlUtil.qm.dox.h:2428
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:3588
const DT_MINUTE
Format unit: minute.
Definition: SqlUtil.qm.dox.h:3600
const DT_SECOND
Format unit: hour.
Definition: SqlUtil.qm.dox.h:3603
const DT_MONTH
Format unit: month.
Definition: SqlUtil.qm.dox.h:3591
const DT_HOUR
Format unit: hour.
Definition: SqlUtil.qm.dox.h:3597
const DT_DAY
Format unit: day.
Definition: SqlUtil.qm.dox.h:3594
const COP_MAX
to return the maximum value
Definition: SqlUtil.qm.dox.h:2524
const COP_OVER
the SQL "over" clause
Definition: SqlUtil.qm.dox.h:2544
const COP_SEQ_CURRVAL
to return the last value of a sequence issued in the same session
Definition: SqlUtil.qm.dox.h:2594
const COP_LENGTH
to get the length of a text field
Definition: SqlUtil.qm.dox.h:2611
const COP_RANK
Analytic (window) function: RANK.
Definition: SqlUtil.qm.dox.h:2669
const COP_VALUE
to append a constant value (SQL Literal) to use as an output column value
Definition: SqlUtil.qm.dox.h:2499
const COP_COALESCE
to return the first non-null argument in the list
Definition: SqlUtil.qm.dox.h:2599
const COP_MIN
to return the minimum value
Definition: SqlUtil.qm.dox.h:2519
const COP_YEAR_HOUR
to return a date value with year to hextern information
Definition: SqlUtil.qm.dox.h:2584
const COP_DIVIDE
the SQL "divide" operator
Definition: SqlUtil.qm.dox.h:2559
const COP_YEAR
to return a date value with year information only
Definition: SqlUtil.qm.dox.h:2569
const COP_COUNT
to return the row count
Definition: SqlUtil.qm.dox.h:2539
const COP_MULTIPLY
the SQL "multiply" operator
Definition: SqlUtil.qm.dox.h:2564
const COP_AVG
to return the average value
Definition: SqlUtil.qm.dox.h:2529
const COP_PLUS
the SQL "plus" operator
Definition: SqlUtil.qm.dox.h:2554
const COP_CUME_DIST
Analytic (window) function: CUME_DIST.
Definition: SqlUtil.qm.dox.h:2627
const COP_SUBSTR
to extract a substring from a column
Definition: SqlUtil.qm.dox.h:2604
const COP_SEQ
to return the next value of a sequence
Definition: SqlUtil.qm.dox.h:2589
const COP_APPEND
to append a string to a column on output
Definition: SqlUtil.qm.dox.h:2494
const COP_PERCENT_RANK
Analytic (window) function: PERCENT_RANK.
Definition: SqlUtil.qm.dox.h:2662
const COP_NTILE
Analytic (window) function: NTILE.
Definition: SqlUtil.qm.dox.h:2655
const COP_YEAR_MONTH
to return a date value with year to month information
Definition: SqlUtil.qm.dox.h:2574
const COP_PREPEND
to prepend a string to a column on output
Definition: SqlUtil.qm.dox.h:2489
const COP_LOWER
to return column value in lower case
Definition: SqlUtil.qm.dox.h:2509
const COP_AS
Definition: SqlUtil.qm.dox.h:2479
const COP_CAST
to convert column value into another datatype
Definition: SqlUtil.qm.dox.h:2484
const COP_ROW_NUMBER
Analytic (window) function: ROW_NUMBER.
Definition: SqlUtil.qm.dox.h:2676
const COP_YEAR_DAY
to return a date value with year to day information
Definition: SqlUtil.qm.dox.h:2579
const COP_UPPER
to return column value in upper case
Definition: SqlUtil.qm.dox.h:2504
const COP_DENSE_RANK
Analytic (window) function: DENSE_RANK.
Definition: SqlUtil.qm.dox.h:2634
const COP_TRUNC_DATE
to return the date with truncated value
Definition: SqlUtil.qm.dox.h:2620
const COP_MINUS
the SQL "minus" operator
Definition: SqlUtil.qm.dox.h:2549
const COP_LAST_VALUE
Analytic (window) function: LAST_VALUE.
Definition: SqlUtil.qm.dox.h:2648
const COP_FIRST_VALUE
Analytic (window) function: FIRST_VALUE.
Definition: SqlUtil.qm.dox.h:2641
const DefaultCopMap
a hash of default column operator descriptions
Definition: SqlUtil.qm.dox.h:2712
const COP_DISTINCT
to return distinct values
Definition: SqlUtil.qm.dox.h:2514
const COP_SUM
to return the sum value
Definition: SqlUtil.qm.dox.h:2534
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:5637
const DefaultIopMap
a hash of default insert operator descriptions (currently empty, all operators are driver-dependent)
Definition: SqlUtil.qm.dox.h:5645
const IOP_SEQ_CURRVAL
for using the last value of a sequence issued in the current session
Definition: SqlUtil.qm.dox.h:5642
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:3825
const JOP_INNER
Definition: SqlUtil.qm.dox.h:3812
const JOP_RIGHT
for right outer joins
Definition: SqlUtil.qm.dox.h:3822
const JOP_LEFT
for left outer joins
Definition: SqlUtil.qm.dox.h:3817
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:4319
const OP_NE
the SQL not equals operator (!= or <>) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4324
const OP_LE
the SQL less than or equals (<=) operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4309
const OP_EQ
the SQL equals operator (=) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4329
const OP_IN
the SQL "in" operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4369
const OP_NOT
the SQL "not" operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4374
const DefaultExpressionMap
Default expressions to be supported by all SqlUtil modules.
Definition: SqlUtil.qm.dox.h:4392
const DefaultOpMap
a hash of valid operators for use in Where Clauses
Definition: SqlUtil.qm.dox.h:5099
const OP_SUBSTR
the SQL "substr" operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4379
const OP_CGE
the SQL greater than or equals operator (>=) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4349
const OP_LT
the SQL less than (<) operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4304
const OP_CLE
the SQL less than or equals (<=) operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4339
const OP_BETWEEN
the SQL "between" operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4364
const OP_GT
the SQL greater than operator (>) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4314
const OP_CNE
the SQL not equals operator (!= or <>) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4354
const OP_CLT
the SQL less than (<) operator for use in Where Clauses when comparing two columns
Definition: SqlUtil.qm.dox.h:4334
const OP_OR
to combine SQL expressions with "or" for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4384
const OP_IN_SELECT
the SQL "in" operator with a select query for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4389
const OP_CGT
the SQL greater than operator (>) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4344
const OP_CEQ
the SQL equals operator (=) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4359
const OP_LIKE
Definition: SqlUtil.qm.dox.h:4299
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:3614
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:5692
column operator info hash as returned by all column operator functions
Definition: SqlUtil.qm.dox.h:2345
string cop
the column operator string code
Definition: SqlUtil.qm.dox.h:2346
auto arg
optional argument
Definition: SqlUtil.qm.dox.h:2348
auto column
column sopecifier, may be a string or a complex hash
Definition: SqlUtil.qm.dox.h:2347
generic column description hash in schema descriptions
Definition: SqlUtil.qm.dox.h:2315
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:2331
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:2333
auto default_value
the default value for the column
Definition: SqlUtil.qm.dox.h:2325
softint scale
for numeric data types, this value gives the scale
Definition: SqlUtil.qm.dox.h:2323
softint size
for data types requiring a size component, the size; for numeric columns this represents the precisio...
Definition: SqlUtil.qm.dox.h:2321
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:2327
*string comment
an optional comment for the column
Definition: SqlUtil.qm.dox.h:2329
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:2317
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:2319
*bool auto_increment
True for DBs that support an auto-increment column
Definition: SqlUtil.qm.dox.h:2335
insert operator info hash as returned by all insert operator functions
Definition: SqlUtil.qm.dox.h:2352
string _iop
the insert operator string code
Definition: SqlUtil.qm.dox.h:2353
any arg
optional argument
Definition: SqlUtil.qm.dox.h:2354
join operator info hash as returned by all join operator functions
Definition: SqlUtil.qm.dox.h:2365
*hash cond
additional conditions for the join clause for the table argument; see Where Clauses for more informat...
Definition: SqlUtil.qm.dox.h:2370
*string alias
optional alias for table in the query
Definition: SqlUtil.qm.dox.h:2368
*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:2371
auto table
the table to join with (either an AbstractTable object or a string table name)
Definition: SqlUtil.qm.dox.h:2367
*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:2369
*hash< auto > opt
optional join options (for example, to specify a partition for the join if supported)
Definition: SqlUtil.qm.dox.h:2372
string jop
the join operator string code
Definition: SqlUtil.qm.dox.h:2366
SQL operator info hash as returned by all operator functions.
Definition: SqlUtil.qm.dox.h:2339
auto arg
optional argument
Definition: SqlUtil.qm.dox.h:2341
string op
the operator string code
Definition: SqlUtil.qm.dox.h:2340
Query information.
Definition: SqlUtil.qm.dox.h:2679
*hash< auto > expression_map
The expression map.
Definition: SqlUtil.qm.dox.h:2699
*hash< string, AbstractTable > join_map
Tables in this join; table alias -> table.
Definition: SqlUtil.qm.dox.h:2690
*hash< auto > pseudo_column_map
Any valid pseudocolumns or aliases generated in th query.
Definition: SqlUtil.qm.dox.h:2696
*hash< auto > where_operator_map
The old-style backwards-compatible "where operator" map.
Definition: SqlUtil.qm.dox.h:2702
object table
The primary table object.
Definition: SqlUtil.qm.dox.h:2681
*hash< auto > query_hash
The original query hash.
Definition: SqlUtil.qm.dox.h:2684
*hash< auto > column_operator_map
Any custom column operator map.
Definition: SqlUtil.qm.dox.h:2705
list< auto > args
arguments to bind in the query generated
Definition: SqlUtil.qm.dox.h:2708
*hash< auto > query_options
Any query options.
Definition: SqlUtil.qm.dox.h:2687
*hash< string, bool > subquery_column_map
When executing a superquery, we can only reference colums in the subquery.
Definition: SqlUtil.qm.dox.h:2693
A hash describing SQL and arguments for an SQL DML command.
Definition: SqlUtil.qm.dox.h:2401
string sql
the SQL string for the update
Definition: SqlUtil.qm.dox.h:2403
list< auto > args
the arguments for the string
Definition: SqlUtil.qm.dox.h:2406
column data type options
Definition: SqlUtil.qm.dox.h:2376
*string number_format
optional format string for converting strings to numeric / decimal / number columns
Definition: SqlUtil.qm.dox.h:2387
*TimeZone data_timezone
the timezone when converting dates from external data to the DB's date
Definition: SqlUtil.qm.dox.h:2381
*softint maxlen
optional additional limit to the maximum length of the data
Definition: SqlUtil.qm.dox.h:2395
*TimeZone db_timezone
the timezone to use when sending date/time values to the DB
Definition: SqlUtil.qm.dox.h:2384
*softbool mandatory
optional flag to overrude any nullable attribute and require data for the column
Definition: SqlUtil.qm.dox.h:2390
*string date_format
optional format string for converting strings to dates for date / timestamp columns
Definition: SqlUtil.qm.dox.h:2378
update operator info hash as returned by all update operator functions
Definition: SqlUtil.qm.dox.h:2358
*hash nest
option nested operation hash
Definition: SqlUtil.qm.dox.h:2361
auto arg
optional argument
Definition: SqlUtil.qm.dox.h:2360
string uop
the update operator string code
Definition: SqlUtil.qm.dox.h:2359