@nymphjs/driver-sqlite3 1.0.0-beta.109 → 1.0.0-beta.110
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/SQLite3Driver.d.ts +2 -1
- package/dist/SQLite3Driver.js +533 -251
- package/dist/SQLite3Driver.js.map +1 -1
- package/package.json +5 -5
- package/src/SQLite3Driver.ts +629 -255
package/dist/SQLite3Driver.js
CHANGED
|
@@ -514,17 +514,51 @@ export default class SQLite3Driver extends NymphDriver {
|
|
|
514
514
|
const etypes = await this.getEtypes();
|
|
515
515
|
for (const etype of etypes) {
|
|
516
516
|
// Export entities.
|
|
517
|
-
const dataIterator = this.queryArray(`SELECT e
|
|
517
|
+
const dataIterator = this.queryArray(`SELECT e."guid", e."tags", e."cdate", e."mdate", e."user", e."group", e."acUser", e."acGroup", e."acOther", e."acRead", e."acWrite", e."acFull", d."name", d."value", json(d."json") as "json", d."string", d."number" FROM ${SQLite3Driver.escape(`${this.prefix}entities_${etype}`)} e LEFT JOIN ${SQLite3Driver.escape(`${this.prefix}data_${etype}`)} d USING ("guid") ORDER BY e."guid";`)[Symbol.iterator]();
|
|
518
518
|
let datum = dataIterator.next();
|
|
519
519
|
while (!datum.done) {
|
|
520
520
|
const guid = datum.value.guid;
|
|
521
521
|
const tags = datum.value.tags.slice(1, -1);
|
|
522
522
|
const cdate = datum.value.cdate;
|
|
523
523
|
const mdate = datum.value.mdate;
|
|
524
|
+
const user = datum.value.user;
|
|
525
|
+
const group = datum.value.group;
|
|
526
|
+
const acUser = datum.value.acUser;
|
|
527
|
+
const acGroup = datum.value.acGroup;
|
|
528
|
+
const acOther = datum.value.acOther;
|
|
529
|
+
const acRead = datum.value.acRead?.slice(1, -1).split(',');
|
|
530
|
+
const acWrite = datum.value.acWrite?.slice(1, -1).split(',');
|
|
531
|
+
const acFull = datum.value.acFull?.slice(1, -1).split(',');
|
|
524
532
|
let currentEntityExport = [];
|
|
525
533
|
currentEntityExport.push(`{${guid}}<${etype}>[${tags}]`);
|
|
526
534
|
currentEntityExport.push(`\tcdate=${JSON.stringify(cdate)}`);
|
|
527
535
|
currentEntityExport.push(`\tmdate=${JSON.stringify(mdate)}`);
|
|
536
|
+
if (this.nymph.tilmeld != null) {
|
|
537
|
+
if (user != null) {
|
|
538
|
+
currentEntityExport.push(`\tuser=${JSON.stringify(['nymph_entity_reference', user, 'User'])}`);
|
|
539
|
+
}
|
|
540
|
+
if (group != null) {
|
|
541
|
+
currentEntityExport.push(`\tgroup=${JSON.stringify(['nymph_entity_reference', group, 'Group'])}`);
|
|
542
|
+
}
|
|
543
|
+
if (acUser != null) {
|
|
544
|
+
currentEntityExport.push(`\tacUser=${JSON.stringify(acUser)}`);
|
|
545
|
+
}
|
|
546
|
+
if (acGroup != null) {
|
|
547
|
+
currentEntityExport.push(`\tacGroup=${JSON.stringify(acGroup)}`);
|
|
548
|
+
}
|
|
549
|
+
if (acOther != null) {
|
|
550
|
+
currentEntityExport.push(`\tacOther=${JSON.stringify(acOther)}`);
|
|
551
|
+
}
|
|
552
|
+
if (acRead != null) {
|
|
553
|
+
currentEntityExport.push(`\tacRead=${JSON.stringify(acRead)}`);
|
|
554
|
+
}
|
|
555
|
+
if (acWrite != null) {
|
|
556
|
+
currentEntityExport.push(`\tacWrite=${JSON.stringify(acWrite)}`);
|
|
557
|
+
}
|
|
558
|
+
if (acFull != null) {
|
|
559
|
+
currentEntityExport.push(`\tacFull=${JSON.stringify(acFull)}`);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
528
562
|
if (datum.value.name != null) {
|
|
529
563
|
// This do will keep going and adding the data until the
|
|
530
564
|
// next entity is reached. datum will end on the next entity.
|
|
@@ -619,17 +653,38 @@ export default class SQLite3Driver extends NymphDriver {
|
|
|
619
653
|
if (curQuery) {
|
|
620
654
|
curQuery += typeIsOr ? ' OR ' : ' AND ';
|
|
621
655
|
}
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
656
|
+
if (curVar === 'cdate' ||
|
|
657
|
+
curVar === 'mdate' ||
|
|
658
|
+
(this.nymph.tilmeld != null &&
|
|
659
|
+
(curVar === 'user' ||
|
|
660
|
+
curVar === 'group' ||
|
|
661
|
+
curVar === 'acUser' ||
|
|
662
|
+
curVar === 'acGroup' ||
|
|
663
|
+
curVar === 'acOther' ||
|
|
664
|
+
curVar === 'acRead' ||
|
|
665
|
+
curVar === 'acWrite' ||
|
|
666
|
+
curVar === 'acFull'))) {
|
|
667
|
+
curQuery +=
|
|
626
668
|
(xor(typeIsNot, clauseNot) ? 'NOT ' : '') +
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
669
|
+
'(' +
|
|
670
|
+
ieTable +
|
|
671
|
+
'.' +
|
|
672
|
+
SQLite3Driver.escape(curVar) +
|
|
673
|
+
' IS NOT NULL)';
|
|
674
|
+
}
|
|
675
|
+
else {
|
|
676
|
+
const name = `param${++count.i}`;
|
|
677
|
+
curQuery +=
|
|
678
|
+
ieTable +
|
|
679
|
+
'."guid" ' +
|
|
680
|
+
(xor(typeIsNot, clauseNot) ? 'NOT ' : '') +
|
|
681
|
+
'IN (SELECT "guid" FROM ' +
|
|
682
|
+
SQLite3Driver.escape(this.prefix + 'data_' + etype) +
|
|
683
|
+
' WHERE "name"=@' +
|
|
684
|
+
name +
|
|
685
|
+
')';
|
|
686
|
+
params[name] = curVar;
|
|
687
|
+
}
|
|
633
688
|
}
|
|
634
689
|
break;
|
|
635
690
|
case 'truthy':
|
|
@@ -638,21 +693,24 @@ export default class SQLite3Driver extends NymphDriver {
|
|
|
638
693
|
if (curQuery) {
|
|
639
694
|
curQuery += typeIsOr ? ' OR ' : ' AND ';
|
|
640
695
|
}
|
|
641
|
-
if (curVar === 'cdate'
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
696
|
+
if (curVar === 'cdate' ||
|
|
697
|
+
curVar === 'mdate' ||
|
|
698
|
+
(this.nymph.tilmeld != null &&
|
|
699
|
+
(curVar === 'user' ||
|
|
700
|
+
curVar === 'group' ||
|
|
701
|
+
curVar === 'acUser' ||
|
|
702
|
+
curVar === 'acGroup' ||
|
|
703
|
+
curVar === 'acOther' ||
|
|
704
|
+
curVar === 'acRead' ||
|
|
705
|
+
curVar === 'acWrite' ||
|
|
706
|
+
curVar === 'acFull'))) {
|
|
650
707
|
curQuery +=
|
|
651
708
|
(xor(typeIsNot, clauseNot) ? 'NOT ' : '') +
|
|
652
709
|
'(' +
|
|
653
710
|
ieTable +
|
|
654
|
-
'.
|
|
655
|
-
|
|
711
|
+
'.' +
|
|
712
|
+
SQLite3Driver.escape(curVar) +
|
|
713
|
+
' IS NOT NULL)';
|
|
656
714
|
}
|
|
657
715
|
else {
|
|
658
716
|
const name = `param${++count.i}`;
|
|
@@ -671,31 +729,58 @@ export default class SQLite3Driver extends NymphDriver {
|
|
|
671
729
|
break;
|
|
672
730
|
case 'equal':
|
|
673
731
|
case '!equal':
|
|
674
|
-
if (curValue[0] === 'cdate'
|
|
732
|
+
if (curValue[0] === 'cdate' ||
|
|
733
|
+
curValue[0] === 'mdate' ||
|
|
734
|
+
(this.nymph.tilmeld != null &&
|
|
735
|
+
(curValue[0] === 'acUser' ||
|
|
736
|
+
curValue[0] === 'acGroup' ||
|
|
737
|
+
curValue[0] === 'acOther'))) {
|
|
675
738
|
if (curQuery) {
|
|
676
739
|
curQuery += typeIsOr ? ' OR ' : ' AND ';
|
|
677
740
|
}
|
|
678
|
-
const
|
|
741
|
+
const value = `param${++count.i}`;
|
|
679
742
|
curQuery +=
|
|
680
743
|
(xor(typeIsNot, clauseNot) ? 'NOT ' : '') +
|
|
681
744
|
ieTable +
|
|
682
|
-
'.
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
745
|
+
'.' +
|
|
746
|
+
SQLite3Driver.escape(curValue[0]) +
|
|
747
|
+
'=@' +
|
|
748
|
+
value;
|
|
749
|
+
params[value] = Number(curValue[1]);
|
|
686
750
|
}
|
|
687
|
-
else if (
|
|
751
|
+
else if (this.nymph.tilmeld != null &&
|
|
752
|
+
(curValue[0] === 'user' || curValue[0] === 'group')) {
|
|
688
753
|
if (curQuery) {
|
|
689
754
|
curQuery += typeIsOr ? ' OR ' : ' AND ';
|
|
690
755
|
}
|
|
691
|
-
const
|
|
756
|
+
const value = `param${++count.i}`;
|
|
692
757
|
curQuery +=
|
|
693
758
|
(xor(typeIsNot, clauseNot) ? 'NOT ' : '') +
|
|
694
759
|
ieTable +
|
|
695
|
-
'.
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
760
|
+
'.' +
|
|
761
|
+
SQLite3Driver.escape(curValue[0]) +
|
|
762
|
+
'=@' +
|
|
763
|
+
value;
|
|
764
|
+
params[value] = `${curValue[1]}`;
|
|
765
|
+
}
|
|
766
|
+
else if (this.nymph.tilmeld != null &&
|
|
767
|
+
(curValue[0] === 'acRead' ||
|
|
768
|
+
curValue[0] === 'acWrite' ||
|
|
769
|
+
curValue[0] === 'acFull')) {
|
|
770
|
+
if (curQuery) {
|
|
771
|
+
curQuery += typeIsOr ? ' OR ' : ' AND ';
|
|
772
|
+
}
|
|
773
|
+
const value = `param${++count.i}`;
|
|
774
|
+
curQuery +=
|
|
775
|
+
(xor(typeIsNot, clauseNot) ? 'NOT ' : '') +
|
|
776
|
+
ieTable +
|
|
777
|
+
'.' +
|
|
778
|
+
SQLite3Driver.escape(curValue[0]) +
|
|
779
|
+
'=@' +
|
|
780
|
+
value;
|
|
781
|
+
params[value] = Array.isArray(curValue[1])
|
|
782
|
+
? ',' + curValue[1].join(',') + ','
|
|
783
|
+
: '';
|
|
699
784
|
}
|
|
700
785
|
else if (typeof curValue[1] === 'number') {
|
|
701
786
|
if (curQuery) {
|
|
@@ -768,31 +853,63 @@ export default class SQLite3Driver extends NymphDriver {
|
|
|
768
853
|
break;
|
|
769
854
|
case 'contain':
|
|
770
855
|
case '!contain':
|
|
771
|
-
if (curValue[0] === 'cdate'
|
|
856
|
+
if (curValue[0] === 'cdate' ||
|
|
857
|
+
curValue[0] === 'mdate' ||
|
|
858
|
+
(this.nymph.tilmeld != null &&
|
|
859
|
+
(curValue[0] === 'acUser' ||
|
|
860
|
+
curValue[0] === 'acGroup' ||
|
|
861
|
+
curValue[0] === 'acOther'))) {
|
|
772
862
|
if (curQuery) {
|
|
773
863
|
curQuery += typeIsOr ? ' OR ' : ' AND ';
|
|
774
864
|
}
|
|
775
|
-
const
|
|
865
|
+
const value = `param${++count.i}`;
|
|
776
866
|
curQuery +=
|
|
777
867
|
(xor(typeIsNot, clauseNot) ? 'NOT ' : '') +
|
|
778
868
|
ieTable +
|
|
779
|
-
'.
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
869
|
+
'.' +
|
|
870
|
+
SQLite3Driver.escape(curValue[0]) +
|
|
871
|
+
'=@' +
|
|
872
|
+
value;
|
|
873
|
+
params[value] = Number(curValue[1]);
|
|
874
|
+
}
|
|
875
|
+
else if (this.nymph.tilmeld != null &&
|
|
876
|
+
(curValue[0] === 'user' || curValue[0] === 'group')) {
|
|
877
|
+
if (curQuery) {
|
|
878
|
+
curQuery += typeIsOr ? ' OR ' : ' AND ';
|
|
879
|
+
}
|
|
880
|
+
const value = `param${++count.i}`;
|
|
881
|
+
curQuery +=
|
|
882
|
+
(xor(typeIsNot, clauseNot) ? 'NOT ' : '') +
|
|
883
|
+
ieTable +
|
|
884
|
+
'.' +
|
|
885
|
+
SQLite3Driver.escape(curValue[0]) +
|
|
886
|
+
'=@' +
|
|
887
|
+
value;
|
|
888
|
+
params[value] = `${curValue[1]}`;
|
|
783
889
|
}
|
|
784
|
-
else if (
|
|
890
|
+
else if (this.nymph.tilmeld != null &&
|
|
891
|
+
(curValue[0] === 'acRead' ||
|
|
892
|
+
curValue[0] === 'acWrite' ||
|
|
893
|
+
curValue[0] === 'acFull')) {
|
|
785
894
|
if (curQuery) {
|
|
786
895
|
curQuery += typeIsOr ? ' OR ' : ' AND ';
|
|
787
896
|
}
|
|
788
|
-
const
|
|
897
|
+
const id = `param${++count.i}`;
|
|
789
898
|
curQuery +=
|
|
790
899
|
(xor(typeIsNot, clauseNot) ? 'NOT ' : '') +
|
|
791
900
|
ieTable +
|
|
792
|
-
'.
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
901
|
+
'.' +
|
|
902
|
+
SQLite3Driver.escape(curValue[0]) +
|
|
903
|
+
' LIKE @' +
|
|
904
|
+
id +
|
|
905
|
+
" ESCAPE '\\'";
|
|
906
|
+
params[id] =
|
|
907
|
+
'%,' +
|
|
908
|
+
curValue[1]
|
|
909
|
+
.replace('\\', '\\\\')
|
|
910
|
+
.replace('%', '\\%')
|
|
911
|
+
.replace('_', '\\_') +
|
|
912
|
+
',%';
|
|
796
913
|
}
|
|
797
914
|
else {
|
|
798
915
|
const containTableSuffix = makeTableSuffix();
|
|
@@ -830,12 +947,21 @@ export default class SQLite3Driver extends NymphDriver {
|
|
|
830
947
|
break;
|
|
831
948
|
case 'search':
|
|
832
949
|
case '!search':
|
|
833
|
-
if (curValue[0] === 'cdate' ||
|
|
950
|
+
if (curValue[0] === 'cdate' ||
|
|
951
|
+
curValue[0] === 'mdate' ||
|
|
952
|
+
(this.nymph.tilmeld != null &&
|
|
953
|
+
(curValue[0] === 'user' ||
|
|
954
|
+
curValue[0] === 'group' ||
|
|
955
|
+
curValue[0] === 'acUser' ||
|
|
956
|
+
curValue[0] === 'acGroup' ||
|
|
957
|
+
curValue[0] === 'acOther' ||
|
|
958
|
+
curValue[0] === 'acRead' ||
|
|
959
|
+
curValue[0] === 'acWrite' ||
|
|
960
|
+
curValue[0] === 'acFull'))) {
|
|
834
961
|
if (curQuery) {
|
|
835
962
|
curQuery += typeIsOr ? ' OR ' : ' AND ';
|
|
836
963
|
}
|
|
837
964
|
curQuery += (xor(typeIsNot, clauseNot) ? 'NOT ' : '') + '(0)';
|
|
838
|
-
break;
|
|
839
965
|
}
|
|
840
966
|
else {
|
|
841
967
|
if (curQuery) {
|
|
@@ -953,35 +1079,31 @@ export default class SQLite3Driver extends NymphDriver {
|
|
|
953
1079
|
break;
|
|
954
1080
|
case 'match':
|
|
955
1081
|
case '!match':
|
|
956
|
-
if (curValue[0] === 'cdate'
|
|
1082
|
+
if (curValue[0] === 'cdate' ||
|
|
1083
|
+
curValue[0] === 'mdate' ||
|
|
1084
|
+
(this.nymph.tilmeld != null &&
|
|
1085
|
+
(curValue[0] === 'user' ||
|
|
1086
|
+
curValue[0] === 'group' ||
|
|
1087
|
+
curValue[0] === 'acUser' ||
|
|
1088
|
+
curValue[0] === 'acGroup' ||
|
|
1089
|
+
curValue[0] === 'acOther' ||
|
|
1090
|
+
curValue[0] === 'acRead' ||
|
|
1091
|
+
curValue[0] === 'acWrite' ||
|
|
1092
|
+
curValue[0] === 'acFull'))) {
|
|
957
1093
|
if (curQuery) {
|
|
958
1094
|
curQuery += typeIsOr ? ' OR ' : ' AND ';
|
|
959
1095
|
}
|
|
960
|
-
const
|
|
961
|
-
curQuery +=
|
|
962
|
-
(xor(typeIsNot, clauseNot) ? 'NOT ' : '') +
|
|
963
|
-
'(' +
|
|
964
|
-
ieTable +
|
|
965
|
-
'."cdate" REGEXP @' +
|
|
966
|
-
cdate +
|
|
967
|
-
')';
|
|
968
|
-
params[cdate] = curValue[1];
|
|
969
|
-
break;
|
|
970
|
-
}
|
|
971
|
-
else if (curValue[0] === 'mdate') {
|
|
972
|
-
if (curQuery) {
|
|
973
|
-
curQuery += typeIsOr ? ' OR ' : ' AND ';
|
|
974
|
-
}
|
|
975
|
-
const mdate = `param${++count.i}`;
|
|
1096
|
+
const value = `param${++count.i}`;
|
|
976
1097
|
curQuery +=
|
|
977
1098
|
(xor(typeIsNot, clauseNot) ? 'NOT ' : '') +
|
|
978
1099
|
'(' +
|
|
979
1100
|
ieTable +
|
|
980
|
-
'.
|
|
981
|
-
|
|
1101
|
+
'.' +
|
|
1102
|
+
SQLite3Driver.escape(curValue[0]) +
|
|
1103
|
+
' REGEXP @' +
|
|
1104
|
+
value +
|
|
982
1105
|
')';
|
|
983
|
-
params[
|
|
984
|
-
break;
|
|
1106
|
+
params[value] = curValue[1];
|
|
985
1107
|
}
|
|
986
1108
|
else {
|
|
987
1109
|
if (curQuery) {
|
|
@@ -1006,35 +1128,31 @@ export default class SQLite3Driver extends NymphDriver {
|
|
|
1006
1128
|
break;
|
|
1007
1129
|
case 'imatch':
|
|
1008
1130
|
case '!imatch':
|
|
1009
|
-
if (curValue[0] === 'cdate'
|
|
1131
|
+
if (curValue[0] === 'cdate' ||
|
|
1132
|
+
curValue[0] === 'mdate' ||
|
|
1133
|
+
(this.nymph.tilmeld != null &&
|
|
1134
|
+
(curValue[0] === 'user' ||
|
|
1135
|
+
curValue[0] === 'group' ||
|
|
1136
|
+
curValue[0] === 'acUser' ||
|
|
1137
|
+
curValue[0] === 'acGroup' ||
|
|
1138
|
+
curValue[0] === 'acOther' ||
|
|
1139
|
+
curValue[0] === 'acRead' ||
|
|
1140
|
+
curValue[0] === 'acWrite' ||
|
|
1141
|
+
curValue[0] === 'acFull'))) {
|
|
1010
1142
|
if (curQuery) {
|
|
1011
1143
|
curQuery += typeIsOr ? ' OR ' : ' AND ';
|
|
1012
1144
|
}
|
|
1013
|
-
const
|
|
1014
|
-
curQuery +=
|
|
1015
|
-
(xor(typeIsNot, clauseNot) ? 'NOT ' : '') +
|
|
1016
|
-
'(' +
|
|
1017
|
-
ieTable +
|
|
1018
|
-
'."cdate" REGEXP @' +
|
|
1019
|
-
cdate +
|
|
1020
|
-
')';
|
|
1021
|
-
params[cdate] = curValue[1];
|
|
1022
|
-
break;
|
|
1023
|
-
}
|
|
1024
|
-
else if (curValue[0] === 'mdate') {
|
|
1025
|
-
if (curQuery) {
|
|
1026
|
-
curQuery += typeIsOr ? ' OR ' : ' AND ';
|
|
1027
|
-
}
|
|
1028
|
-
const mdate = `param${++count.i}`;
|
|
1145
|
+
const value = `param${++count.i}`;
|
|
1029
1146
|
curQuery +=
|
|
1030
1147
|
(xor(typeIsNot, clauseNot) ? 'NOT ' : '') +
|
|
1031
|
-
'(' +
|
|
1148
|
+
'(lower(' +
|
|
1032
1149
|
ieTable +
|
|
1033
|
-
'.
|
|
1034
|
-
|
|
1035
|
-
')'
|
|
1036
|
-
|
|
1037
|
-
|
|
1150
|
+
'.' +
|
|
1151
|
+
SQLite3Driver.escape(curValue[0]) +
|
|
1152
|
+
') REGEXP lower(@' +
|
|
1153
|
+
value +
|
|
1154
|
+
'))';
|
|
1155
|
+
params[value] = curValue[1];
|
|
1038
1156
|
}
|
|
1039
1157
|
else {
|
|
1040
1158
|
if (curQuery) {
|
|
@@ -1059,35 +1177,31 @@ export default class SQLite3Driver extends NymphDriver {
|
|
|
1059
1177
|
break;
|
|
1060
1178
|
case 'like':
|
|
1061
1179
|
case '!like':
|
|
1062
|
-
if (curValue[0] === 'cdate'
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
'
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
" ESCAPE '\\')";
|
|
1074
|
-
params[cdate] = curValue[1];
|
|
1075
|
-
break;
|
|
1076
|
-
}
|
|
1077
|
-
else if (curValue[0] === 'mdate') {
|
|
1180
|
+
if (curValue[0] === 'cdate' ||
|
|
1181
|
+
curValue[0] === 'mdate' ||
|
|
1182
|
+
(this.nymph.tilmeld != null &&
|
|
1183
|
+
(curValue[0] === 'user' ||
|
|
1184
|
+
curValue[0] === 'group' ||
|
|
1185
|
+
curValue[0] === 'acUser' ||
|
|
1186
|
+
curValue[0] === 'acGroup' ||
|
|
1187
|
+
curValue[0] === 'acOther' ||
|
|
1188
|
+
curValue[0] === 'acRead' ||
|
|
1189
|
+
curValue[0] === 'acWrite' ||
|
|
1190
|
+
curValue[0] === 'acFull'))) {
|
|
1078
1191
|
if (curQuery) {
|
|
1079
1192
|
curQuery += typeIsOr ? ' OR ' : ' AND ';
|
|
1080
1193
|
}
|
|
1081
|
-
const
|
|
1194
|
+
const value = `param${++count.i}`;
|
|
1082
1195
|
curQuery +=
|
|
1083
1196
|
(xor(typeIsNot, clauseNot) ? 'NOT ' : '') +
|
|
1084
1197
|
'(' +
|
|
1085
1198
|
ieTable +
|
|
1086
|
-
'.
|
|
1087
|
-
|
|
1199
|
+
'.' +
|
|
1200
|
+
SQLite3Driver.escape(curValue[0]) +
|
|
1201
|
+
' LIKE @' +
|
|
1202
|
+
value +
|
|
1088
1203
|
" ESCAPE '\\')";
|
|
1089
|
-
params[
|
|
1090
|
-
break;
|
|
1204
|
+
params[value] = curValue[1];
|
|
1091
1205
|
}
|
|
1092
1206
|
else {
|
|
1093
1207
|
if (curQuery) {
|
|
@@ -1112,35 +1226,31 @@ export default class SQLite3Driver extends NymphDriver {
|
|
|
1112
1226
|
break;
|
|
1113
1227
|
case 'ilike':
|
|
1114
1228
|
case '!ilike':
|
|
1115
|
-
if (curValue[0] === 'cdate'
|
|
1229
|
+
if (curValue[0] === 'cdate' ||
|
|
1230
|
+
curValue[0] === 'mdate' ||
|
|
1231
|
+
(this.nymph.tilmeld != null &&
|
|
1232
|
+
(curValue[0] === 'user' ||
|
|
1233
|
+
curValue[0] === 'group' ||
|
|
1234
|
+
curValue[0] === 'acUser' ||
|
|
1235
|
+
curValue[0] === 'acGroup' ||
|
|
1236
|
+
curValue[0] === 'acOther' ||
|
|
1237
|
+
curValue[0] === 'acRead' ||
|
|
1238
|
+
curValue[0] === 'acWrite' ||
|
|
1239
|
+
curValue[0] === 'acFull'))) {
|
|
1116
1240
|
if (curQuery) {
|
|
1117
1241
|
curQuery += typeIsOr ? ' OR ' : ' AND ';
|
|
1118
1242
|
}
|
|
1119
|
-
const
|
|
1120
|
-
curQuery +=
|
|
1121
|
-
(xor(typeIsNot, clauseNot) ? 'NOT ' : '') +
|
|
1122
|
-
'(' +
|
|
1123
|
-
ieTable +
|
|
1124
|
-
'."cdate" LIKE @' +
|
|
1125
|
-
cdate +
|
|
1126
|
-
" ESCAPE '\\')";
|
|
1127
|
-
params[cdate] = curValue[1];
|
|
1128
|
-
break;
|
|
1129
|
-
}
|
|
1130
|
-
else if (curValue[0] === 'mdate') {
|
|
1131
|
-
if (curQuery) {
|
|
1132
|
-
curQuery += typeIsOr ? ' OR ' : ' AND ';
|
|
1133
|
-
}
|
|
1134
|
-
const mdate = `param${++count.i}`;
|
|
1243
|
+
const value = `param${++count.i}`;
|
|
1135
1244
|
curQuery +=
|
|
1136
1245
|
(xor(typeIsNot, clauseNot) ? 'NOT ' : '') +
|
|
1137
|
-
'(' +
|
|
1246
|
+
'(lower(' +
|
|
1138
1247
|
ieTable +
|
|
1139
|
-
'.
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1248
|
+
'.' +
|
|
1249
|
+
SQLite3Driver.escape(curValue[0]) +
|
|
1250
|
+
') LIKE lower(@' +
|
|
1251
|
+
value +
|
|
1252
|
+
") ESCAPE '\\')";
|
|
1253
|
+
params[value] = curValue[1];
|
|
1144
1254
|
}
|
|
1145
1255
|
else {
|
|
1146
1256
|
if (curQuery) {
|
|
@@ -1165,31 +1275,29 @@ export default class SQLite3Driver extends NymphDriver {
|
|
|
1165
1275
|
break;
|
|
1166
1276
|
case 'gt':
|
|
1167
1277
|
case '!gt':
|
|
1168
|
-
if (curValue[0] === 'cdate'
|
|
1278
|
+
if (curValue[0] === 'cdate' ||
|
|
1279
|
+
curValue[0] === 'mdate' ||
|
|
1280
|
+
(this.nymph.tilmeld != null &&
|
|
1281
|
+
(curValue[0] === 'user' ||
|
|
1282
|
+
curValue[0] === 'group' ||
|
|
1283
|
+
curValue[0] === 'acUser' ||
|
|
1284
|
+
curValue[0] === 'acGroup' ||
|
|
1285
|
+
curValue[0] === 'acOther' ||
|
|
1286
|
+
curValue[0] === 'acRead' ||
|
|
1287
|
+
curValue[0] === 'acWrite' ||
|
|
1288
|
+
curValue[0] === 'acFull'))) {
|
|
1169
1289
|
if (curQuery) {
|
|
1170
1290
|
curQuery += typeIsOr ? ' OR ' : ' AND ';
|
|
1171
1291
|
}
|
|
1172
|
-
const
|
|
1173
|
-
curQuery +=
|
|
1174
|
-
(xor(typeIsNot, clauseNot) ? 'NOT ' : '') +
|
|
1175
|
-
ieTable +
|
|
1176
|
-
'."cdate">@' +
|
|
1177
|
-
cdate;
|
|
1178
|
-
params[cdate] = Number(curValue[1]);
|
|
1179
|
-
break;
|
|
1180
|
-
}
|
|
1181
|
-
else if (curValue[0] === 'mdate') {
|
|
1182
|
-
if (curQuery) {
|
|
1183
|
-
curQuery += typeIsOr ? ' OR ' : ' AND ';
|
|
1184
|
-
}
|
|
1185
|
-
const mdate = `param${++count.i}`;
|
|
1292
|
+
const value = `param${++count.i}`;
|
|
1186
1293
|
curQuery +=
|
|
1187
1294
|
(xor(typeIsNot, clauseNot) ? 'NOT ' : '') +
|
|
1188
1295
|
ieTable +
|
|
1189
|
-
'.
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1296
|
+
'.' +
|
|
1297
|
+
SQLite3Driver.escape(curValue[0]) +
|
|
1298
|
+
'>@' +
|
|
1299
|
+
value;
|
|
1300
|
+
params[value] = Number(curValue[1]);
|
|
1193
1301
|
}
|
|
1194
1302
|
else {
|
|
1195
1303
|
if (curQuery) {
|
|
@@ -1214,31 +1322,29 @@ export default class SQLite3Driver extends NymphDriver {
|
|
|
1214
1322
|
break;
|
|
1215
1323
|
case 'gte':
|
|
1216
1324
|
case '!gte':
|
|
1217
|
-
if (curValue[0] === 'cdate'
|
|
1325
|
+
if (curValue[0] === 'cdate' ||
|
|
1326
|
+
curValue[0] === 'mdate' ||
|
|
1327
|
+
(this.nymph.tilmeld != null &&
|
|
1328
|
+
(curValue[0] === 'user' ||
|
|
1329
|
+
curValue[0] === 'group' ||
|
|
1330
|
+
curValue[0] === 'acUser' ||
|
|
1331
|
+
curValue[0] === 'acGroup' ||
|
|
1332
|
+
curValue[0] === 'acOther' ||
|
|
1333
|
+
curValue[0] === 'acRead' ||
|
|
1334
|
+
curValue[0] === 'acWrite' ||
|
|
1335
|
+
curValue[0] === 'acFull'))) {
|
|
1218
1336
|
if (curQuery) {
|
|
1219
1337
|
curQuery += typeIsOr ? ' OR ' : ' AND ';
|
|
1220
1338
|
}
|
|
1221
|
-
const
|
|
1222
|
-
curQuery +=
|
|
1223
|
-
(xor(typeIsNot, clauseNot) ? 'NOT ' : '') +
|
|
1224
|
-
ieTable +
|
|
1225
|
-
'."cdate">=@' +
|
|
1226
|
-
cdate;
|
|
1227
|
-
params[cdate] = Number(curValue[1]);
|
|
1228
|
-
break;
|
|
1229
|
-
}
|
|
1230
|
-
else if (curValue[0] === 'mdate') {
|
|
1231
|
-
if (curQuery) {
|
|
1232
|
-
curQuery += typeIsOr ? ' OR ' : ' AND ';
|
|
1233
|
-
}
|
|
1234
|
-
const mdate = `param${++count.i}`;
|
|
1339
|
+
const value = `param${++count.i}`;
|
|
1235
1340
|
curQuery +=
|
|
1236
1341
|
(xor(typeIsNot, clauseNot) ? 'NOT ' : '') +
|
|
1237
1342
|
ieTable +
|
|
1238
|
-
'.
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1343
|
+
'.' +
|
|
1344
|
+
SQLite3Driver.escape(curValue[0]) +
|
|
1345
|
+
'>=@' +
|
|
1346
|
+
value;
|
|
1347
|
+
params[value] = Number(curValue[1]);
|
|
1242
1348
|
}
|
|
1243
1349
|
else {
|
|
1244
1350
|
if (curQuery) {
|
|
@@ -1263,31 +1369,29 @@ export default class SQLite3Driver extends NymphDriver {
|
|
|
1263
1369
|
break;
|
|
1264
1370
|
case 'lt':
|
|
1265
1371
|
case '!lt':
|
|
1266
|
-
if (curValue[0] === 'cdate'
|
|
1372
|
+
if (curValue[0] === 'cdate' ||
|
|
1373
|
+
curValue[0] === 'mdate' ||
|
|
1374
|
+
(this.nymph.tilmeld != null &&
|
|
1375
|
+
(curValue[0] === 'user' ||
|
|
1376
|
+
curValue[0] === 'group' ||
|
|
1377
|
+
curValue[0] === 'acUser' ||
|
|
1378
|
+
curValue[0] === 'acGroup' ||
|
|
1379
|
+
curValue[0] === 'acOther' ||
|
|
1380
|
+
curValue[0] === 'acRead' ||
|
|
1381
|
+
curValue[0] === 'acWrite' ||
|
|
1382
|
+
curValue[0] === 'acFull'))) {
|
|
1267
1383
|
if (curQuery) {
|
|
1268
1384
|
curQuery += typeIsOr ? ' OR ' : ' AND ';
|
|
1269
1385
|
}
|
|
1270
|
-
const
|
|
1271
|
-
curQuery +=
|
|
1272
|
-
(xor(typeIsNot, clauseNot) ? 'NOT ' : '') +
|
|
1273
|
-
ieTable +
|
|
1274
|
-
'."cdate"<@' +
|
|
1275
|
-
cdate;
|
|
1276
|
-
params[cdate] = Number(curValue[1]);
|
|
1277
|
-
break;
|
|
1278
|
-
}
|
|
1279
|
-
else if (curValue[0] === 'mdate') {
|
|
1280
|
-
if (curQuery) {
|
|
1281
|
-
curQuery += typeIsOr ? ' OR ' : ' AND ';
|
|
1282
|
-
}
|
|
1283
|
-
const mdate = `param${++count.i}`;
|
|
1386
|
+
const value = `param${++count.i}`;
|
|
1284
1387
|
curQuery +=
|
|
1285
1388
|
(xor(typeIsNot, clauseNot) ? 'NOT ' : '') +
|
|
1286
1389
|
ieTable +
|
|
1287
|
-
'.
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1390
|
+
'.' +
|
|
1391
|
+
SQLite3Driver.escape(curValue[0]) +
|
|
1392
|
+
'<@' +
|
|
1393
|
+
value;
|
|
1394
|
+
params[value] = Number(curValue[1]);
|
|
1291
1395
|
}
|
|
1292
1396
|
else {
|
|
1293
1397
|
if (curQuery) {
|
|
@@ -1312,31 +1416,29 @@ export default class SQLite3Driver extends NymphDriver {
|
|
|
1312
1416
|
break;
|
|
1313
1417
|
case 'lte':
|
|
1314
1418
|
case '!lte':
|
|
1315
|
-
if (curValue[0] === 'cdate'
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
'
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
break;
|
|
1327
|
-
}
|
|
1328
|
-
else if (curValue[0] === 'mdate') {
|
|
1419
|
+
if (curValue[0] === 'cdate' ||
|
|
1420
|
+
curValue[0] === 'mdate' ||
|
|
1421
|
+
(this.nymph.tilmeld != null &&
|
|
1422
|
+
(curValue[0] === 'user' ||
|
|
1423
|
+
curValue[0] === 'group' ||
|
|
1424
|
+
curValue[0] === 'acUser' ||
|
|
1425
|
+
curValue[0] === 'acGroup' ||
|
|
1426
|
+
curValue[0] === 'acOther' ||
|
|
1427
|
+
curValue[0] === 'acRead' ||
|
|
1428
|
+
curValue[0] === 'acWrite' ||
|
|
1429
|
+
curValue[0] === 'acFull'))) {
|
|
1329
1430
|
if (curQuery) {
|
|
1330
1431
|
curQuery += typeIsOr ? ' OR ' : ' AND ';
|
|
1331
1432
|
}
|
|
1332
|
-
const
|
|
1433
|
+
const value = `param${++count.i}`;
|
|
1333
1434
|
curQuery +=
|
|
1334
1435
|
(xor(typeIsNot, clauseNot) ? 'NOT ' : '') +
|
|
1335
1436
|
ieTable +
|
|
1336
|
-
'.
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1437
|
+
'.' +
|
|
1438
|
+
SQLite3Driver.escape(curValue[0]) +
|
|
1439
|
+
'<=@' +
|
|
1440
|
+
value;
|
|
1441
|
+
params[value] = Number(curValue[1]);
|
|
1340
1442
|
}
|
|
1341
1443
|
else {
|
|
1342
1444
|
if (curQuery) {
|
|
@@ -1374,21 +1476,56 @@ export default class SQLite3Driver extends NymphDriver {
|
|
|
1374
1476
|
if (curQuery) {
|
|
1375
1477
|
curQuery += typeIsOr ? ' OR ' : ' AND ';
|
|
1376
1478
|
}
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1479
|
+
if (this.nymph.tilmeld != null &&
|
|
1480
|
+
(curValue[0] === 'user' || curValue[0] === 'group')) {
|
|
1481
|
+
const guid = `param${++count.i}`;
|
|
1482
|
+
curQuery +=
|
|
1483
|
+
(xor(typeIsNot, clauseNot) ? 'NOT ' : '') +
|
|
1484
|
+
ieTable +
|
|
1485
|
+
'.' +
|
|
1486
|
+
SQLite3Driver.escape(curValue[0]) +
|
|
1487
|
+
'=@' +
|
|
1488
|
+
guid;
|
|
1489
|
+
params[guid] = curQguid;
|
|
1490
|
+
}
|
|
1491
|
+
else if (this.nymph.tilmeld != null &&
|
|
1492
|
+
(curValue[0] === 'acRead' ||
|
|
1493
|
+
curValue[0] === 'acWrite' ||
|
|
1494
|
+
curValue[0] === 'acFull')) {
|
|
1495
|
+
const guid = `param${++count.i}`;
|
|
1496
|
+
curQuery +=
|
|
1497
|
+
(xor(typeIsNot, clauseNot) ? 'NOT ' : '') +
|
|
1498
|
+
ieTable +
|
|
1499
|
+
'.' +
|
|
1500
|
+
SQLite3Driver.escape(curValue[0]) +
|
|
1501
|
+
' LIKE @' +
|
|
1502
|
+
guid +
|
|
1503
|
+
" ESCAPE '\\'";
|
|
1504
|
+
params[guid] =
|
|
1505
|
+
'%,' +
|
|
1506
|
+
curQguid
|
|
1507
|
+
.replace('\\', '\\\\')
|
|
1508
|
+
.replace('%', '\\%')
|
|
1509
|
+
.replace('_', '\\_') +
|
|
1510
|
+
',%';
|
|
1511
|
+
}
|
|
1512
|
+
else {
|
|
1513
|
+
const name = `param${++count.i}`;
|
|
1514
|
+
const guid = `param${++count.i}`;
|
|
1515
|
+
curQuery +=
|
|
1516
|
+
(xor(typeIsNot, clauseNot) ? 'NOT ' : '') +
|
|
1517
|
+
'EXISTS (SELECT "guid" FROM ' +
|
|
1518
|
+
SQLite3Driver.escape(this.prefix + 'references_' + etype) +
|
|
1519
|
+
' WHERE "guid"=' +
|
|
1520
|
+
ieTable +
|
|
1521
|
+
'."guid" AND "name"=@' +
|
|
1522
|
+
name +
|
|
1523
|
+
' AND "reference"=@' +
|
|
1524
|
+
guid +
|
|
1525
|
+
')';
|
|
1526
|
+
params[name] = curValue[0];
|
|
1527
|
+
params[guid] = curQguid;
|
|
1528
|
+
}
|
|
1392
1529
|
break;
|
|
1393
1530
|
case 'selector':
|
|
1394
1531
|
case '!selector':
|
|
@@ -1408,34 +1545,100 @@ export default class SQLite3Driver extends NymphDriver {
|
|
|
1408
1545
|
const [qrefOptions, ...qrefSelectors] = curValue[1];
|
|
1409
1546
|
const QrefEntityClass = qrefOptions.class;
|
|
1410
1547
|
etypes.push(QrefEntityClass.ETYPE);
|
|
1411
|
-
const qrefQuery = this.makeEntityQuery({
|
|
1412
|
-
...qrefOptions,
|
|
1413
|
-
sort: qrefOptions.sort ?? null,
|
|
1414
|
-
return: 'guid',
|
|
1415
|
-
class: QrefEntityClass,
|
|
1416
|
-
}, qrefSelectors, QrefEntityClass.ETYPE, count, params, false, makeTableSuffix(), etypes, 'r' + referenceTableSuffix + '."reference"');
|
|
1417
1548
|
if (curQuery) {
|
|
1418
1549
|
curQuery += typeIsOr ? ' OR ' : ' AND ';
|
|
1419
1550
|
}
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
referenceTableSuffix +
|
|
1429
|
-
'."guid"=' +
|
|
1430
|
-
ieTable +
|
|
1431
|
-
'."guid" AND r' +
|
|
1551
|
+
if (this.nymph.tilmeld != null &&
|
|
1552
|
+
(curValue[0] === 'user' || curValue[0] === 'group')) {
|
|
1553
|
+
const qrefQuery = this.makeEntityQuery({
|
|
1554
|
+
...qrefOptions,
|
|
1555
|
+
sort: qrefOptions.sort ?? null,
|
|
1556
|
+
return: 'guid',
|
|
1557
|
+
class: QrefEntityClass,
|
|
1558
|
+
}, qrefSelectors, QrefEntityClass.ETYPE, count, params, false, makeTableSuffix(), etypes, 'r' +
|
|
1432
1559
|
referenceTableSuffix +
|
|
1433
|
-
'.
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1560
|
+
'.' +
|
|
1561
|
+
SQLite3Driver.escape(curValue[0]));
|
|
1562
|
+
curQuery +=
|
|
1563
|
+
(xor(typeIsNot, clauseNot) ? 'NOT ' : '') +
|
|
1564
|
+
'EXISTS (SELECT "guid" FROM ' +
|
|
1565
|
+
SQLite3Driver.escape(this.prefix + 'entities_' + etype) +
|
|
1566
|
+
' r' +
|
|
1567
|
+
referenceTableSuffix +
|
|
1568
|
+
' WHERE r' +
|
|
1569
|
+
referenceTableSuffix +
|
|
1570
|
+
'."guid"=' +
|
|
1571
|
+
ieTable +
|
|
1572
|
+
'."guid" AND EXISTS (' +
|
|
1573
|
+
qrefQuery.query +
|
|
1574
|
+
'))';
|
|
1575
|
+
}
|
|
1576
|
+
else if (this.nymph.tilmeld != null &&
|
|
1577
|
+
(curValue[0] === 'acRead' ||
|
|
1578
|
+
curValue[0] === 'acWrite' ||
|
|
1579
|
+
curValue[0] === 'acFull')) {
|
|
1580
|
+
const qrefQuery = this.makeEntityQuery({
|
|
1581
|
+
...qrefOptions,
|
|
1582
|
+
sort: qrefOptions.sort ?? null,
|
|
1583
|
+
return: 'guid',
|
|
1584
|
+
class: QrefEntityClass,
|
|
1585
|
+
}, qrefSelectors, QrefEntityClass.ETYPE, count, params, false, makeTableSuffix(), etypes, 'r' + referenceTableSuffix + '."ref"');
|
|
1586
|
+
const splitTableSuffix = makeTableSuffix();
|
|
1587
|
+
curQuery +=
|
|
1588
|
+
(xor(typeIsNot, clauseNot) ? 'NOT ' : '') +
|
|
1589
|
+
`EXISTS (SELECT "guid", "ref" FROM (
|
|
1590
|
+
WITH RECURSIVE "spl${splitTableSuffix}" AS (
|
|
1591
|
+
SELECT
|
|
1592
|
+
"guid",
|
|
1593
|
+
SUBSTR(${SQLite3Driver.escape(curValue[0])}, 1, INSTR(${SQLite3Driver.escape(curValue[0])}, ',') - 1) AS "ref",
|
|
1594
|
+
SUBSTR(${SQLite3Driver.escape(curValue[0])}, INSTR(${SQLite3Driver.escape(curValue[0])}, ',') + 1) AS "remainder"
|
|
1595
|
+
FROM ${SQLite3Driver.escape(this.prefix + 'entities_' + etype)}
|
|
1596
|
+
UNION ALL
|
|
1597
|
+
SELECT
|
|
1598
|
+
"guid",
|
|
1599
|
+
SUBSTR("remainder", 1, INSTR("remainder", ',') - 1) AS "ref",
|
|
1600
|
+
SUBSTR("remainder", INSTR("remainder", ',') + 1) AS "remainder"
|
|
1601
|
+
FROM "spl${splitTableSuffix}" WHERE "remainder" != ''
|
|
1602
|
+
)
|
|
1603
|
+
SELECT "guid", "ref" FROM "spl${splitTableSuffix}" WHERE "ref" != ''
|
|
1604
|
+
) ` +
|
|
1605
|
+
' r' +
|
|
1606
|
+
referenceTableSuffix +
|
|
1607
|
+
' WHERE r' +
|
|
1608
|
+
referenceTableSuffix +
|
|
1609
|
+
'."guid"=' +
|
|
1610
|
+
ieTable +
|
|
1611
|
+
'."guid" AND EXISTS (' +
|
|
1612
|
+
qrefQuery.query +
|
|
1613
|
+
'))';
|
|
1614
|
+
}
|
|
1615
|
+
else {
|
|
1616
|
+
const qrefQuery = this.makeEntityQuery({
|
|
1617
|
+
...qrefOptions,
|
|
1618
|
+
sort: qrefOptions.sort ?? null,
|
|
1619
|
+
return: 'guid',
|
|
1620
|
+
class: QrefEntityClass,
|
|
1621
|
+
}, qrefSelectors, QrefEntityClass.ETYPE, count, params, false, makeTableSuffix(), etypes, 'r' + referenceTableSuffix + '."reference"');
|
|
1622
|
+
const qrefName = `param${++count.i}`;
|
|
1623
|
+
curQuery +=
|
|
1624
|
+
(xor(typeIsNot, clauseNot) ? 'NOT ' : '') +
|
|
1625
|
+
'EXISTS (SELECT "guid" FROM ' +
|
|
1626
|
+
SQLite3Driver.escape(this.prefix + 'references_' + etype) +
|
|
1627
|
+
' r' +
|
|
1628
|
+
referenceTableSuffix +
|
|
1629
|
+
' WHERE r' +
|
|
1630
|
+
referenceTableSuffix +
|
|
1631
|
+
'."guid"=' +
|
|
1632
|
+
ieTable +
|
|
1633
|
+
'."guid" AND r' +
|
|
1634
|
+
referenceTableSuffix +
|
|
1635
|
+
'."name"=@' +
|
|
1636
|
+
qrefName +
|
|
1637
|
+
' AND EXISTS (' +
|
|
1638
|
+
qrefQuery.query +
|
|
1639
|
+
'))';
|
|
1640
|
+
params[qrefName] = curValue[0];
|
|
1641
|
+
}
|
|
1439
1642
|
break;
|
|
1440
1643
|
}
|
|
1441
1644
|
}
|
|
@@ -1518,6 +1721,14 @@ export default class SQLite3Driver extends NymphDriver {
|
|
|
1518
1721
|
${eTable}."tags",
|
|
1519
1722
|
${eTable}."cdate",
|
|
1520
1723
|
${eTable}."mdate",
|
|
1724
|
+
${eTable}."user",
|
|
1725
|
+
${eTable}."group",
|
|
1726
|
+
${eTable}."acUser",
|
|
1727
|
+
${eTable}."acGroup",
|
|
1728
|
+
${eTable}."acOther",
|
|
1729
|
+
${eTable}."acRead",
|
|
1730
|
+
${eTable}."acWrite",
|
|
1731
|
+
${eTable}."acFull",
|
|
1521
1732
|
${dTable}."name",
|
|
1522
1733
|
${dTable}."value",
|
|
1523
1734
|
json(${dTable}."json") as "json",
|
|
@@ -1579,6 +1790,14 @@ export default class SQLite3Driver extends NymphDriver {
|
|
|
1579
1790
|
${eTable}."tags",
|
|
1580
1791
|
${eTable}."cdate",
|
|
1581
1792
|
${eTable}."mdate",
|
|
1793
|
+
${eTable}."user",
|
|
1794
|
+
${eTable}."group",
|
|
1795
|
+
${eTable}."acUser",
|
|
1796
|
+
${eTable}."acGroup",
|
|
1797
|
+
${eTable}."acOther",
|
|
1798
|
+
${eTable}."acRead",
|
|
1799
|
+
${eTable}."acWrite",
|
|
1800
|
+
${eTable}."acFull",
|
|
1582
1801
|
${dTable}."name",
|
|
1583
1802
|
${dTable}."value",
|
|
1584
1803
|
json(${dTable}."json") as "json",
|
|
@@ -1602,6 +1821,14 @@ export default class SQLite3Driver extends NymphDriver {
|
|
|
1602
1821
|
${eTable}."tags",
|
|
1603
1822
|
${eTable}."cdate",
|
|
1604
1823
|
${eTable}."mdate",
|
|
1824
|
+
${eTable}."user",
|
|
1825
|
+
${eTable}."group",
|
|
1826
|
+
${eTable}."acUser",
|
|
1827
|
+
${eTable}."acGroup",
|
|
1828
|
+
${eTable}."acOther",
|
|
1829
|
+
${eTable}."acRead",
|
|
1830
|
+
${eTable}."acWrite",
|
|
1831
|
+
${eTable}."acFull",
|
|
1605
1832
|
${dTable}."name",
|
|
1606
1833
|
${dTable}."value",
|
|
1607
1834
|
json(${dTable}."json") as "json",
|
|
@@ -1645,6 +1872,14 @@ export default class SQLite3Driver extends NymphDriver {
|
|
|
1645
1872
|
: [],
|
|
1646
1873
|
cdate: Number(row.cdate),
|
|
1647
1874
|
mdate: Number(row.mdate),
|
|
1875
|
+
user: row.user,
|
|
1876
|
+
group: row.group,
|
|
1877
|
+
acUser: row.acUser,
|
|
1878
|
+
acGroup: row.acGroup,
|
|
1879
|
+
acOther: row.acOther,
|
|
1880
|
+
acRead: row.acRead?.slice(1, -1).split(',') ?? [],
|
|
1881
|
+
acWrite: row.acWrite?.slice(1, -1).split(',') ?? [],
|
|
1882
|
+
acFull: row.acFull?.slice(1, -1).split(',') ?? [],
|
|
1648
1883
|
}), (row) => ({
|
|
1649
1884
|
name: row.name,
|
|
1650
1885
|
svalue: row.value === 'N'
|
|
@@ -2191,6 +2426,47 @@ export default class SQLite3Driver extends NymphDriver {
|
|
|
2191
2426
|
this.store.transactionsStarted++;
|
|
2192
2427
|
return this.nymph;
|
|
2193
2428
|
}
|
|
2429
|
+
async removeTilmeldOldRows(etype) {
|
|
2430
|
+
await this.startTransaction('nymph-remove-tilmeld-rows');
|
|
2431
|
+
try {
|
|
2432
|
+
for (let name of [
|
|
2433
|
+
'user',
|
|
2434
|
+
'group',
|
|
2435
|
+
'acUser',
|
|
2436
|
+
'acGroup',
|
|
2437
|
+
'acOther',
|
|
2438
|
+
'acRead',
|
|
2439
|
+
'acWrite',
|
|
2440
|
+
'acFull',
|
|
2441
|
+
]) {
|
|
2442
|
+
this.queryRun(`DELETE FROM ${SQLite3Driver.escape(`${this.prefix}data_${etype}`)} WHERE "name"=@name;`, {
|
|
2443
|
+
etypes: [etype],
|
|
2444
|
+
params: {
|
|
2445
|
+
name,
|
|
2446
|
+
},
|
|
2447
|
+
});
|
|
2448
|
+
this.queryRun(`DELETE FROM ${SQLite3Driver.escape(`${this.prefix}references_${etype}`)} WHERE "name"=@name;`, {
|
|
2449
|
+
etypes: [etype],
|
|
2450
|
+
params: {
|
|
2451
|
+
name,
|
|
2452
|
+
},
|
|
2453
|
+
});
|
|
2454
|
+
this.queryRun(`DELETE FROM ${SQLite3Driver.escape(`${this.prefix}tokens_${etype}`)} WHERE "name"=@name;`, {
|
|
2455
|
+
etypes: [etype],
|
|
2456
|
+
params: {
|
|
2457
|
+
name,
|
|
2458
|
+
},
|
|
2459
|
+
});
|
|
2460
|
+
}
|
|
2461
|
+
}
|
|
2462
|
+
catch (e) {
|
|
2463
|
+
this.nymph.config.debugError('sqlite3', `Remove tilmeld rows error: "${e}"`);
|
|
2464
|
+
await this.rollback('nymph-remove-tilmeld-rows');
|
|
2465
|
+
throw e;
|
|
2466
|
+
}
|
|
2467
|
+
await this.commit('nymph-remove-tilmeld-rows');
|
|
2468
|
+
return true;
|
|
2469
|
+
}
|
|
2194
2470
|
async needsMigration() {
|
|
2195
2471
|
const table = this.queryGet("SELECT `name` FROM `sqlite_master` WHERE `type`='table' AND `name` LIKE @prefix LIMIT 1;", {
|
|
2196
2472
|
params: {
|
|
@@ -2245,6 +2521,12 @@ export default class SQLite3Driver extends NymphDriver {
|
|
|
2245
2521
|
this.addTilmeldColumnsAndIndexes(etype);
|
|
2246
2522
|
}
|
|
2247
2523
|
}
|
|
2524
|
+
else if (migrationType === 'tilmeldRemoveOldRows') {
|
|
2525
|
+
const etypes = await this.getEtypes();
|
|
2526
|
+
for (let etype of etypes) {
|
|
2527
|
+
await this.removeTilmeldOldRows(etype);
|
|
2528
|
+
}
|
|
2529
|
+
}
|
|
2248
2530
|
}
|
|
2249
2531
|
}
|
|
2250
2532
|
//# sourceMappingURL=SQLite3Driver.js.map
|