@@ -12,4 +12,52 @@ Type Validation
12
12
:depth: 1
13
13
:class: singlecol
14
14
15
- Content on this page will be addressed in DOCSP-44965.
15
+ Definition
16
+ ----------
17
+
18
+ The {+intellij-full+} examines the document fields in queries to ensure
19
+ the data types are valid. For example, if you use a document field in an
20
+ equality comparison, or an insert or update operation, the
21
+ plugin examines the field to ensure the type is valid.
22
+
23
+ If the type is invalid, the plugin shows a warning that indicates
24
+ the type cannot be assigned.
25
+
26
+ To resolve the warning, change the field value to match the expected
27
+ type. If the field is dynamically typed and strict typing rules aren't
28
+ applied, you can ignore the invalid type warning.
29
+
30
+ Example
31
+ -------
32
+
33
+ In the following example Java code snippet, the ``trip_status`` field
34
+ type is ``String``, but the ``Filters`` operation attempts to perform
35
+ an equality comparison with an ``Integer`` value ``1324324``:
36
+
37
+ .. code-block:: java
38
+ :copyable: false
39
+ :emphasize-lines: 3
40
+
41
+ public List<Document> findCompletedTripsByDriver( String driverId ) {
42
+ return trips.find( Filters.and(
43
+ Filters.eq( fieldName: "trip_status", value: 1324324 )
44
+ Filters.eq( fieldName: "driver_id", driverId )
45
+ )).into( new ArrayList<> () );
46
+ }
47
+
48
+ Because ``value`` is an ``Integer`` but ``trip_status`` is a ``String``
49
+ in the MongoDB documents, the plugin shows a warning about the invalid
50
+ type:
51
+
52
+ ``"Integer" (type of provided value) can not be assigned to "String"
53
+ (type of "trip_status")``
54
+
55
+ To resolve the invalid type, change the value to a ``String``. For
56
+ example: ``"start"``.
57
+
58
+ Learn More
59
+ ----------
60
+
61
+ - :ref:`intellij-connect`
62
+ - :ref:`intellij-autocomplete`
63
+ - :ref:`intellij-index-warning`
0 commit comments