JetBrains / JetBrains/Exposed

Wrapping of SQL query with ColumnSet

Open
#1,108 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
9.3k
Forks
798
Avg merge
4d 2h
Merged PRs (30d)
26

Description

I would like to wrap some more complex SQLs with ColumnSet ~ be able to add where conditions, select of specific columns of that sql, etc..

Currently, I create database view with such SQL, then I have Table() describing it - it is usable, but harder to maintain, because I have to deploy/rebuild view when I change the SQL.

Expected sth like:

```
object TestView : Table() {
val col = integer("col")
override fun describe(s: Transaction, queryBuilder: QueryBuilder) {
queryBuilder.append("(select 1 col) testview") // some complex sql
}
}
```

**This works:**
```
TestView.selectAll().map { row -> println(row[TestView.col]) }
```
Result SQL: SELECT testview.col FROM (select 1 col) testview

**But e.g. this does not work:**
```
TestView.alias("foo").selectAll().map { row -> println(row[TestView.col]) }
```
Result SQL: SELECT foo.col FROM testview foo

**Does exist any solution for that?**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.