Luminus error: Parameter Mismatch: :id parameter data not found

I am trying to delete an entry in my sqlite3 database by calling it from a template and I am using a fixed number for testing:

  <form action="/delete/2">
  <button class="button is-small is-link is-light">delete</button>


(defn delete [req]
  (let [id (if (get-in req [:path-params :id]) (get-in req [:path-params :id]) 2)]
    (db/delrow id)))

(defn home-routes []
  [ "" 
   {:middleware [middleware/wrap-csrf
   ["/" {:get home-page}]
   ["/delete/:id" delete]])

and queries.sql

-- :name delrow :! :n
-- :doc deletes a row from rent given the id

The problem is that I get this error all the time: Parameter Mismatch: :id parameter data not found.
any ideas?

I think that where you call db/delrow you need to pass a map with the: id i.e. {:id id}

I tried to call db/delrow with (db/delrow {:id id} but it returned a 500 error. And when I looked into it it sems to be a “not supported on type: java.lang.Integer” error.
If that is what you meant.

Yes, that’s what I was suggesting. Could it be that id in your database is not an integer but a string? Maybe try passing “2” instead of 2?

it did not change anytihng, gives the same error.

the strange thing is that if I pass the follwing:

<li><a href="/btable/stora salen/166/187">test</a></li>


["/btable/:block/:area1/:area2" btable]

the I can access the variables by the following code:

(get-in req [:path-params :area1])

but not with the id case…

ok, now I did the following change:

(defn delete [req]
  (let [id (get-in req [:path-params :id])]
    (db/delrow {:id id})))

And it seems to work. thanks Jim_Megas for pointing in the right direction.

1 Like

A possibly helpful note for the future: instead of the if you had in there before, you could do:

user=> (get-in {} [:path-params :id] 2)

Both get and get-in have an arity that accepts a default value to return if the requested key is not present. Note that a value of nil is considered “present”:

user=> (get-in {:path-params {:id nil}} [:path-params :id] 2)

(but you’re not going to get nil from a query/path/form parameter – you’ll either get the actual value, a string unless you have any coercion in place, or you won’t get the parameter at all)

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.