Skip to content

Commit

Permalink
docs: EXPOSED-639 Add note about required imports with deleteWhere() (J…
Browse files Browse the repository at this point in the history
…etBrains#2303)

- Add required imports to deleteWhere() and deleteIgnoreWhere() sample code,
as well as note about their inclusion.
- Fix incorrect deleteAll() code block.
- Add qualifying named parameter to Join.delete() to be more clear.
  • Loading branch information
bog-walk authored Nov 13, 2024
1 parent 299d9c3 commit 92d0cd6
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions documentation-website/Writerside/topics/DSL-CRUD-operations.topic
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,14 @@
<chapter id="deleteWhere">
<title><code>deleteWhere</code></title>
<p>To delete records and return the count of deleted rows, use the <code>deleteWhere</code> function.</p>
<p>
Any <code>SqlExpressionBuilder</code> comparison operators or extension functions used in the <code>op</code>
parameter lambda block will require inclusion of an import statement like <code>import org.jetbrains.exposed.sql.SqlExpressionBuilder.*</code>.
</p>
<code-block lang="kotlin">
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
import org.jetbrains.exposed.sql.deleteWhere

StarWarsFilms.deleteWhere { StarWarsFilms.sequelId eq 8 }
</code-block>
</chapter>
Expand All @@ -250,16 +257,25 @@
<p>To delete records while ignoring any possible errors that occur during the process, use the
<code>deleteIgnoreWhere</code> function. The function will return the count of deleted rows.
</p>
<p>
Any <code>SqlExpressionBuilder</code> comparison operators or extension functions used in the <code>op</code>
parameter lambda block will require inclusion of an import statement like <code>import org.jetbrains.exposed.sql.SqlExpressionBuilder.*</code>.
</p>
<code-block lang="kotlin">
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
import org.jetbrains.exposed.sql.deleteIgnoreWhere

StarWarsFilms.deleteIgnoreWhere { StarWarsFilms.sequelId eq 8 }
</code-block>
</chapter>
<chapter id="deleteAll">
<title><code>deleteAll</code></title>
<p>To deletes all rows in a table and return the count of deleted rows, use the <code>deleteAll</code>
<p>To delete all rows in a table and return the count of deleted rows, use the <code>deleteAll</code>
function.</p>
<code-block lang="kotlin">
StarWarsFilms.deleteAll { StarWarsFilms.sequelId eq 8 }
import org.jetbrains.exposed.sql.deleteAll

StarWarsFilms.deleteAll()
</code-block>
</chapter>
<chapter id="join-delete">
Expand All @@ -269,8 +285,10 @@
the argument to the parameter <code>targetTable</code>.
</p>
<code-block lang="kotlin">
import org.jetbrains.exposed.sql.delete

val join = StarWarsFilms innerJoin Actors
join.delete(Actors) { Actors.sequelId greater 2 }
join.delete(targetTable = Actors) { Actors.sequelId greater 2 }
</code-block>
<tip>For more information on creating and using a <code>Join</code>, see <a href="DSL-Querying-data.topic#join-tables">Joining Tables</a>.</tip>
</chapter>
Expand Down

0 comments on commit 92d0cd6

Please sign in to comment.