File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed
docs/src/piccolo/query_clauses Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -167,18 +167,29 @@ Rather than using the ``|`` and ``&`` characters, you can use the ``And`` and
167167WhereRaw
168168--------
169169
170- In certain situations you may want to have raw SQL in your where clause. For
171- example, there could be a Postgres function you need to call.
170+ In certain situations you may want to have raw SQL in your where clause.
172171
173172.. code-block :: python
174173
175174 from piccolo.columns.combination import WhereRaw
176175
177- b = Band
178- b.select().where(
176+ Band.select().where(
179177 WhereRaw(" name = 'Pythonistas'" )
180178 ).run_sync()
181179
180+ It's important to parameterise your SQL statements if the values come from an
181+ untrusted source, otherwise it could lead to a SQL injection attack.
182+
183+ .. code-block :: python
184+
185+ from piccolo.columns.combination import WhereRaw
186+
187+ value = " Could be dangerous"
188+
189+ Band.select().where(
190+ WhereRaw(" name = {} " , value)
191+ ).run_sync()
192+
182193 ``WhereRaw `` can be combined into complex queries, just as you'd expect:
183194
184195.. code-block :: python
You can’t perform that action at this time.
0 commit comments