Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8418585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:22:34+00:00 2026-06-10T02:22:34+00:00

I am trying to create a very simple API with korma Users can query

  • 0

I am trying to create a very simple API with korma

Users can query a database like so:

localhost:8080/my_postgres_db/users.json?where[age]=50&limit=1  

Currently I am getting an error when trying to apply a where clause to an existing, composable, query.

clojure.lang.ArityException: Wrong number of args (2) passed to: core$where

The code in question:

(defn- comp-query [q [func arg]]
  (let [sql-fn (ns-resolve 'korma.core (-> func name symbol))]
    (sql-fn q arg)))

(defn compose-query [table col]
  (reduce comp-query (select* table) col))

Usage:

 (def clauses {:where {:column1 10} :fields "a,b" :limit 10 :offset 500})
 (-> (compose-query table clauses) select)

Everything behaves as expected, except for where clauses. I can combine limit, offset and fields in any way I choose and I get the expected results. Only when I have a :where key in my map do I run into the error.

Am I attempting something I shouldn’t? Is this bad clojure? Any help would be appreciated.

Note: I have read this SO question

Edit: from lein repl I can manually compose a query in the same fashion and it works

(where (select* "my_table") {:a 5})

Edit:
If I modify my compose-query function to this:

(defn compose-query [table col]
  ; remove where clause to process seperately
  (let [base (reduce comp-query (select* table) (dissoc col :where))]
    (if-let [where-clause (:where col)]
      (-> base (where where-clause))
      base)))

Everything works as expected.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:22:36+00:00Added an answer on June 10, 2026 at 2:22 am

    The problem here is that korma.core/where is not a function and needs to be handled specially. Where can’t be implemented as a function and still correctly handle things like (where query (or (= :hits 1) (> :hits 5)))

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a very simple login for only one or two users,
I'm trying to create a very simple PHP CLI application that can be run
I am trying to create a very simple Newsletter sign up that I can
I'm trying to create a very simple database abstraction, one part of it using
I'm trying to create a very simple WPF application. I'd like to have an
I am trying to create a very simple app like TuneIn with just one
I am trying to create very simple image browser with jQuery. I am doing
I am trying to create a very simple antlr grammar file which should parse
I'm trying to create a very simple chat application in Flex/.Net using FluorineFX but
I'm trying to create a very simple message board (author, text, and date written)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.