]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
docs: Fix substr function starting index in hybrid_property example (#12482)
authorkrave1986 <krave@qq.com>
Thu, 3 Apr 2025 18:55:36 +0000 (02:55 +0800)
committerFederico Caselli <cfederico87@gmail.com>
Thu, 3 Apr 2025 18:56:25 +0000 (20:56 +0200)
(cherry picked from commit 0c1824c666c55ae19051feb4970060385c674bb3)

doc/build/orm/mapped_attributes.rst

index d0610f4e0fa6da4f69e1a5409517d64e8f6d574a..b114680132e332588091a8200a9bc174c0eab567 100644 (file)
@@ -234,7 +234,7 @@ logic::
             """Produce a SQL expression that represents the value
             of the _email column, minus the last twelve characters."""
 
-            return func.substr(cls._email, 0, func.length(cls._email) - 12)
+            return func.substr(cls._email, 1, func.length(cls._email) - 12)
 
 Above, accessing the ``email`` property of an instance of ``EmailAddress``
 will return the value of the ``_email`` attribute, removing or adding the
@@ -249,7 +249,7 @@ attribute, a SQL function is rendered which produces the same effect:
     {execsql}SELECT address.email AS address_email, address.id AS address_id
     FROM address
     WHERE substr(address.email, ?, length(address.email) - ?) = ?
-    (0, 12, 'address')
+    (1, 12, 'address')
     {stop}
 
 Read more about Hybrids at :ref:`hybrids_toplevel`.