]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
sqlalchemy/dialects/postgresql/pgjson:
authornathan <nathan.alexander.rice@gmail.com>
Wed, 11 Dec 2013 15:27:10 +0000 (10:27 -0500)
committernathan <nathan.alexander.rice@gmail.com>
Wed, 11 Dec 2013 15:27:10 +0000 (10:27 -0500)
 - Updated documentation for JSON class

lib/sqlalchemy/dialects/postgresql/pgjson.py

index b41446dae50950bbb2eed833a25deab4344029b0..a29d0bbcc096458a3b384f91854ec02788d13169 100644 (file)
@@ -31,15 +31,23 @@ class JSON(sqltypes.TypeEngine):
                 data = {"key1": "value1", "key2": "value2"}
             )
 
-    :class:`.JSON` provides two operations:
+    :class:`.JSON` provides several operations:
 
     * Index operations::
 
-        data_table.c.data['some key'] == 'some value'
+        data_table.c.data['some key']
 
-    * Path Index operations::
+    * Index operations returning text (required for text comparison or casting)::
 
-        data_table.c.data.get_path("'{key_1, key_2, ..., key_n}'"]
+        data_table.c.data.get_item_as_text('some key') == 'some value'
+
+    * Path index operations::
+
+        data_table.c.data.get_path("{key_1, key_2, ..., key_n}")
+
+    * Path index operations returning text (required for text comparison or casting)::
+
+        data_table.c.data.get_path("{key_1, key_2, ..., key_n}") == 'some value'
 
     Please be aware that when used with the SQLAlchemy ORM, you will need to
     replace the JSON object present on an attribute with a new object in order
@@ -85,9 +93,8 @@ class JSON(sqltypes.TypeEngine):
 
         def get_path_as_text(self, other):
             """Text expression.  Get the value at a given path, as text.
-            Paths are of the form '{key_1, key_2, ..., key_n}' (quotes are
-            required).  Use this when you need to cast the type of the
-            returned value."""
+            Paths are of the form {key_1, key_2, ..., key_n}.  Use this when
+            you need to cast the type of the returned value."""
             return self.expr.op('#>>', precedence=5)(other)
 
         def _adapt_expression(self, op, other_comparator):