documentation-website/Writerside/topics/Migration-Guide-0-46-0.md
While Exposed provides migration support in the code itself (by using the @Deprecated annotation and ReplaceWith quickfix),
this document serves as a reference point for the migration steps necessary to switch to the new query DSL.
Exposed's query DSL has been refactored to bring it closer to the syntax of a standard SQL SELECT statement.
The slice() function has been deprecated in favor of a new select() function that accepts the same variable amount of columns and creates a Query instance.
If all columns should be selected, use selectAll() to create a Query instance.
The Query class now has the method where(), which can be chained to replace the old version of select { }.
Putting these changes together results in the following new DSL:
// Example 1
// before
TestTable
.slice(TestTable.columnA)
.select { TestTable.columnA eq 1 }
// after
TestTable
.select(TestTable.columnA)
.where { TestTable.columnA eq 1 }
// Example 2
// before
TestTable
.slice(TestTable.columnA)
.selectAll()
// after
TestTable
.select(TestTable.columnA)
// Example 3
// before
TestTable
.select { TestTable.columnA eq 1 }
// after
TestTable
.selectAll()
.where { TestTable.columnA eq 1 }
// Example 4 - no change
TestTable.selectAll()
To be consistent with these changes, the functions selectBatched() and selectAllBatched() have also been deprecated.
A new Query method, fetchBatchedResults(), should be used instead as a terminal operation on an existing Query:
// Example 1
// before
TestTable
.selectBatched(50) { TestTable.columnA eq 1 }
// after
TestTable
.selectAll()
.where { TestTable.columnA eq 1 }
.fetchBatchedResults(50)
// Example 2
// before
TestTable
.slice(TestTable.columnA)
.selectAllBatched(50)
// after
TestTable
.select(TestTable.columnA)
.fetchBatchedResults(50)
Lastly, adjustSlice() has been renamed to adjustSelect():
// before
val originalQuery = TestTable.select { TestTable.columnA eq 1 }
originalQuery.adjustSlice { slice(TestTable.columnA) }
// after
val originalQuery = TestTable.selectAll().where { TestTable.columnA eq 1 }
originalQuery.adjustSelect { select(TestTable.columnA) }
adjustSlice, then use the Alt+Enter quickfix with "Replace usages of '...' in whole project".sliceQuery.select: enter select\((\s*.+\s*)\)(\s*)\.select in the search bar (with the regex tab enabled) to find this method easilyselectselectBatchedselectAllBatchedselectAll():
select\((\s*.+\s*)\)(\s*)\.selectAll\(\) in the search bar (with the regex tab enabled)select\($1\) in the replace bar