Rullst AcademyRullst Academy/Lesson
Applications with Rullst I · Lesson 08 / 14

Create: text stays data

An apostrophe in a title must not break the query.

Learning paths18 min

Let's discover together

  1. 1

    In POST, the handler receives JSON, validates and calls Store::create. SQL uses VALUES (?, ?); bind sends title and priority as values. Do not concatenate input into SQL: O'Brien is a common name, and other text may resemble commands.

  2. 2

    After INSERT, last_insert_rowid identifies the new record. The 201 response returns that id and normalized values, including done=false. A repeated title creates another record; this project defines neither title uniqueness nor submission deduplication.

  3. 3

    Inspect the test with an apostrophe, HTML markup and SQL-like text. After the call, the table still exists and the title remains text. This checks that parameterized path; it does not prove an entire app immune to injection or solve authorization.

  4. 4

    A single SQLite INSERT is atomic: the row is inserted or the statement fails. If a future action changes several tables as one unit, a transaction must cover every step. Do not call two independent writes one transaction.

Your application workbench

The kit includes a complete app to investigate and modify. The excerpt below explains this step; the editor contains the indicated file. Rullst Academy does not compile or run this server in your browser.

File to study and modify

src/store.rs

sqlx::query("INSERT INTO missions (title, priority) VALUES (?, ?)")
    .bind(&input.title)
    .bind(input.priority)
    .execute(&self.pool).await?

Extract the kit to a new folder and open a terminal beside Cargo.toml. Use Rust 1.96+; the first build may download dependencies and take time. Then open http://127.0.0.1:3010. Stop with Ctrl+C and run again after editing.

cargo test --locked
cargo run --locked
My files and GitHub

Download your draft and replace the indicated file in your extracted copy. The editor saves one file in this browser; your account saves assessments and XP. The ZIP excludes your edits. GitHub sends only the confirmed file; use Git manually for the whole app, excluding databases, backups and secrets.

Official links and next step

✦
YOUR MISSION

Trace a validated creation through a parameterized INSERT to a 201 response.

Now it's your turn

Discovery workshop

Decide before running

Trace a validated creation through a parameterized INSERT to a 201 response.
Build your answers and check when you are ready.
A moment to understand

What do two creations with the same title produce in this project?

I need a hint

POST has no title uniqueness or idempotency key. Know this limit before repeating an uncertain submission.

Loading your journey…

Take it with you

Create a title with an apostrophe and check response, listing and restart. Add a test with another unusual valid input. Explain how bind separates instruction and value without claiming to solve permissions.

At your own pace

My files and GitHub

Every lesson can become your own record: code, notes or a practice plan. Saving a file to GitHub is optional and does not change your XP.

Student guide

The editor and downloads open when this lesson is available to your account. Check access below or return to the track map.

Checking your access to this lesson…

Rullstpetbot

AI can make mistakes. Check the lesson material.