Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select query does not work with sub-query #93

Open
pawit-metabase opened this issue Mar 25, 2022 · 0 comments
Open

Select query does not work with sub-query #93

pawit-metabase opened this issue Mar 25, 2022 · 0 comments
Labels

Comments

@pawit-metabase
Copy link
Contributor

pawit-metabase commented Mar 25, 2022

@camsaul

Example query:

(db/select [User :first-name :last-name]
            :id [:in {:select [:id] :from [User]}]
            {:order-by [:id]})

Error:

  act-msg: exception in actual: (db/select [User :first-name :last-name] :id [:in {:select [:id], :from [User]}] {:order-by [:id]})
    threw: class org.postgresql.util.PSQLException - ERROR: column "select" does not exist
  Position: 80
           org.postgresql.core.v3.QueryExecutorImpl$receiveErrorResponse (QueryExecutorImpl.java:2497)
           org.postgresql.core.v3.QueryExecutorImpl$processResults (QueryExecutorImpl.java:2233)
           org.postgresql.core.v3.QueryExecutorImpl$execute (QueryExecutorImpl.java:310)
           org.postgresql.jdbc.PgStatement$executeInternal (PgStatement.java:446)
           org.postgresql.jdbc.PgStatement$execute (PgStatement.java:370)
           org.postgresql.jdbc.PgPreparedStatement$executeWithFlags (PgPreparedStatement.java:149)
           org.postgresql.jdbc.PgPreparedStatement$executeQuery (PgPreparedStatement.java:108)
           clojure.java.jdbc$execute_query_with_params$invokeStatic (jdbc.clj:1079)
           on (jdbc.clj:1073)
           clojure.java.jdbc$db_query_with_resultset_STAR_$invokeStatic (jdbc.clj:1102)
           on (jdbc.clj:1082)
           clojure.java.jdbc$query$invokeStatic (jdbc.clj:1171)
           on (jdbc.clj:1133)
           toucan.db$query$invokeStatic (db.clj:308)
           toucan.db$query$doInvoke (db.clj:304)
           toucan.db$simple_select$invokeStatic (db.clj:414)
           on (db.clj:403)
           toucan.db$select$invokeStatic (db.clj:708)
           toucan.db$select$doInvoke (db.clj:702)

This issue was introduced in #87. A variant of this was reported in #88 and fixed in #89.

A workaround is to use an explicit {:where [:in :id {:select [:id] :from [User]}]} instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant