Take a field and a value intended to be saved on that field, and return placeholder SQL and accompanying params. Check for raw values, fields with get_placeholder_sql(), and compilable defined in that order. When field is None, consider the value raw and use
(self, field, get_placeholder_sql, val)
| 1684 | returning_params = () |
| 1685 | |
| 1686 | def field_as_sql(self, field, get_placeholder_sql, val): |
| 1687 | """ |
| 1688 | Take a field and a value intended to be saved on that field, and |
| 1689 | return placeholder SQL and accompanying params. Check for raw values, |
| 1690 | fields with get_placeholder_sql(), and compilable defined in that |
| 1691 | order. |
| 1692 | |
| 1693 | When field is None, consider the value raw and use it as the |
| 1694 | placeholder, with no corresponding parameters returned. |
| 1695 | """ |
| 1696 | if field is None: |
| 1697 | # A field value of None means the value is raw. |
| 1698 | sql, params = val, [] |
| 1699 | elif get_placeholder_sql is not None: |
| 1700 | # Some fields (e.g. geo fields) need special munging before |
| 1701 | # they can be inserted. |
| 1702 | sql, params = get_placeholder_sql(val, self, self.connection) |
| 1703 | elif hasattr(val, "as_sql"): |
| 1704 | # This is an expression, let's compile it. |
| 1705 | sql, params = self.compile(val) |
| 1706 | else: |
| 1707 | # Return the common case for the placeholder |
| 1708 | sql, params = "%s", [val] |
| 1709 | |
| 1710 | # The following hook is only used by Oracle Spatial, which sometimes |
| 1711 | # needs to yield 'NULL' and () as its placeholder and params instead |
| 1712 | # of '%s' and (None,). The 'NULL' placeholder is produced earlier by |
| 1713 | # OracleOperations.get_geom_placeholder(). The following line removes |
| 1714 | # the corresponding None parameter. See ticket #10888. |
| 1715 | params = self.connection.ops.modify_insert_params(sql, params) |
| 1716 | |
| 1717 | return sql, params |
| 1718 | |
| 1719 | def prepare_value(self, field, value): |
| 1720 | """ |
no test coverage detected