@@ -723,7 +723,7 @@ function ComputedValuesAfterCreateCollectionTestSuite() {
723
723
}
724
724
} ,
725
725
726
- testNowAllowedLet : function ( ) {
726
+ testNotAllowedLet : function ( ) {
727
727
try {
728
728
collection . properties ( {
729
729
computedValues : [
@@ -739,8 +739,67 @@ function ComputedValuesAfterCreateCollectionTestSuite() {
739
739
assertEqual ( errors . ERROR_BAD_PARAMETER . code , error . errorNum ) ;
740
740
}
741
741
} ,
742
+
743
+ testInteractionBetweenSchemaAndComputedValues : function ( ) {
744
+ const schema = {
745
+ rule : {
746
+ type : "object" ,
747
+ properties : {
748
+ value1 : {
749
+ type : "boolean" ,
750
+ } ,
751
+ } ,
752
+ required : [ "value1" ] ,
753
+ } ,
754
+ level : "moderate" ,
755
+ message : "Schema validation failed" ,
756
+ type : "json" ,
757
+ } ;
758
+
759
+ const computedValues = [
760
+ {
761
+ name : "value1" ,
762
+ expression : "RETURN CONCAT(@doc.value1, '+', @doc.value2)" ,
763
+ computeOn : [ "insert" , "update" , "replace" ] ,
764
+ overwrite : true ,
765
+ failOnWarning : false ,
766
+ keepNull : true ,
767
+ }
768
+ ] ;
769
+
770
+ collection . properties ( { schema, computedValues } ) ;
771
+
772
+ if ( isCluster ) {
773
+ // unfortunately there is no way to test when the new properties
774
+ // have been applied on the DB servers. all we can do is sleep
775
+ // and hope the delay is long enough
776
+ internal . sleep ( 5 ) ;
777
+ }
778
+
779
+ let colProperties = collection . properties ( ) ;
780
+ assertTrue ( colProperties . hasOwnProperty ( "schema" ) ) ;
781
+ assertEqual ( schema , colProperties . schema ) ;
782
+ assertTrue ( colProperties . hasOwnProperty ( "computedValues" ) ) ;
783
+ assertEqual ( computedValues , colProperties . computedValues ) ;
784
+
785
+ // update just the schema
786
+ collection . properties ( { schema } ) ;
787
+
788
+ if ( isCluster ) {
789
+ // unfortunately there is no way to test when the new properties
790
+ // have been applied on the DB servers. all we can do is sleep
791
+ // and hope the delay is long enough
792
+ internal . sleep ( 5 ) ;
793
+ }
794
+
795
+ colProperties = collection . properties ( ) ;
796
+ assertTrue ( colProperties . hasOwnProperty ( "schema" ) ) ;
797
+ assertEqual ( schema , colProperties . schema ) ;
798
+ assertTrue ( colProperties . hasOwnProperty ( "computedValues" ) ) ;
799
+ assertEqual ( computedValues , colProperties . computedValues ) ;
800
+ } ,
742
801
743
- testSchemaValidationWithComputedValuesoverwrite : function ( ) {
802
+ testSchemaValidationWithComputedValuesOverwrite : function ( ) {
744
803
collection . properties ( {
745
804
schema : {
746
805
"rule" : {
@@ -791,7 +850,7 @@ function ComputedValuesAfterCreateCollectionTestSuite() {
791
850
assertEqual ( res . length , 0 ) ;
792
851
} ,
793
852
794
- testSchemaValidationWithComputedValuesNooverwrite : function ( ) {
853
+ testSchemaValidationWithComputedValuesNoOverwrite : function ( ) {
795
854
collection . properties ( {
796
855
schema : {
797
856
"rule" : {
@@ -846,7 +905,7 @@ function ComputedValuesAfterCreateCollectionTestSuite() {
846
905
} ,
847
906
848
907
849
- testRedefineComputedValueUpdateoverwrite : function ( ) {
908
+ testRedefineComputedValueUpdateOverwrite : function ( ) {
850
909
collection . properties ( {
851
910
computedValues : [
852
911
{
@@ -921,7 +980,7 @@ function ComputedValuesAfterCreateCollectionTestSuite() {
921
980
} ) ;
922
981
} ,
923
982
924
- testRedefineComputedValueUpdateNooverwrite : function ( ) {
983
+ testRedefineComputedValueUpdateNoOverwrite : function ( ) {
925
984
collection . properties ( {
926
985
computedValues : [
927
986
{
0 commit comments