]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
docs(sql): fix Composite/Composed imprecision
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 3 Jul 2024 12:57:33 +0000 (14:57 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 3 Jul 2024 12:58:31 +0000 (14:58 +0200)
Close #862.

psycopg/psycopg/sql.py

index 282c138fcabe1436c5559df205e9e1bd55432313..c0b5b8e96ce0d8b63c6cb605b2f589b9d3252020 100644 (file)
@@ -39,15 +39,15 @@ class Composable(ABC):
     """
     Abstract base class for objects that can be used to compose an SQL string.
 
-    `!Composable` objects can be passed directly to
-    `~psycopg.Cursor.execute()`, `~psycopg.Cursor.executemany()`,
-    `~psycopg.Cursor.copy()` in place of the query string.
-
     `!Composable` objects can be joined using the ``+`` operator: the result
     will be a `Composed` instance containing the objects joined. The operator
     ``*`` is also supported with an integer argument: the result is a
     `!Composed` instance containing the left argument repeated as many times as
     requested.
+
+    `!SQL` and `!Composed` objects can be passed directly to
+    `~psycopg.Cursor.execute()`, `~psycopg.Cursor.executemany()`,
+    `~psycopg.Cursor.copy()` in place of the query string.
     """
 
     def __init__(self, obj: Any):
@@ -110,10 +110,14 @@ class Composed(Composable):
     """
     A `Composable` object made of a sequence of `!Composable`.
 
-    The object is usually created using `!Composable` operators and methods.
-    However it is possible to create a `!Composed` directly specifying a
-    sequence of objects as arguments: if they are not `!Composable` they will
-    be wrapped in a `Literal`.
+    The object is usually created using `!Composable` operators and methods
+    (such as the `SQL.format()` method). `!Composed` objects can be passed
+    directly to `~psycopg.Cursor.execute()`, `~psycopg.Cursor.executemany()`,
+    `~psycopg.Cursor.copy()` in place of the query string.
+
+    It is also possible to create a `!Composed` directly specifying a sequence
+    of objects as arguments: if they are not `!Composable` they will be wrapped
+    in a `Literal`.
 
     Example::
 
@@ -185,6 +189,10 @@ class SQL(Composable):
     statements; use other objects such as `Identifier` or `Literal` to
     represent variable parts.
 
+    `!SQL` objects can be passed directly to `~psycopg.Cursor.execute()`,
+    `~psycopg.Cursor.executemany()`, `~psycopg.Cursor.copy()` in place of the
+    query string.
+
     Example::
 
         >>> query = sql.SQL("SELECT {0} FROM {1}").format(