-
Notifications
You must be signed in to change notification settings - Fork 700
/
Copy pathmigration-guide.html
80 lines (70 loc) · 9.06 KB
/
migration-guide.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<!DOCTYPE html SYSTEM "about:legacy-compat">
<html lang="en-US" data-preset="contrast" data-primary-color="#307FFF"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="UTF-8"><meta name="robots" content="noindex"><meta name="built-on" content="2025-01-15T14:46:39.939188423"><title>Migrating from 0.45.0 to 0.46.0 | Exposed</title><script type="application/json" id="virtual-toc-data">[{"id":"select-query-dsl","level":0,"title":"SELECT Query DSL","anchor":"#select-query-dsl"},{"id":"migration-steps","level":0,"title":"Migration Steps","anchor":"#migration-steps"}]</script><script type="application/json" id="topic-shortcuts"></script><link href="https://resources.jetbrains.com/writerside/apidoc/6.10.0-b267/app.css" rel="stylesheet"><link rel="icon" type="image/svg" sizes="16x16" href="images/exposed-logo.svg"><meta name="image" content=""><!-- Open Graph --><meta property="og:title" content="Migrating from 0.45.0 to 0.46.0 | Exposed"><meta property="og:description" content=""><meta property="og:image" content=""><meta property="og:site_name" content="Exposed Help"><meta property="og:type" content="website"><meta property="og:locale" content="en_US"><meta property="og:url" content="writerside-documentation/docs/0.58.0/migration-guide.html"><!-- End Open Graph --><!-- Twitter Card --><meta name="twitter:card" content="summary_large_image"><meta name="twitter:site" content=""><meta name="twitter:title" content="Migrating from 0.45.0 to 0.46.0 | Exposed"><meta name="twitter:description" content=""><meta name="twitter:creator" content=""><meta name="twitter:image:src" content=""><!-- End Twitter Card --><!-- Schema.org WebPage --><script type="application/ld+json">{
"@context": "http://schema.org",
"@type": "WebPage",
"@id": "writerside-documentation/docs/0.58.0/migration-guide.html#webpage",
"url": "writerside-documentation/docs/0.58.0/migration-guide.html",
"name": "Migrating from 0.45.0 to 0.46.0 | Exposed",
"description": "",
"image": "",
"inLanguage":"en-US"
}</script><!-- End Schema.org --><!-- Schema.org WebSite --><script type="application/ld+json">{
"@type": "WebSite",
"@id": "writerside-documentation/docs/#website",
"url": "writerside-documentation/docs/",
"name": "Exposed Help"
}</script><!-- End Schema.org --></head><body data-id="Migration-Guide" data-main-title="Migrating from 0.45.0 to 0.46.0" data-article-props="{"seeAlsoStyle":"links"}" data-template="article" data-breadcrumbs="Releases"><div class="wrapper"><main class="panel _main"><header class="panel__header"><div class="container"><h3>Exposed 0.58.0 Help</h3><div class="panel-trigger"></div></div></header><section class="panel__content"><div class="container"><article class="article" data-shortcut-switcher="inactive"><h1 data-toc="Migration-Guide" id="Migration-Guide.md">Migrating from 0.45.0 to 0.46.0</h1><p id="-dgcpq3_2">While Exposed provides migration support in the code itself (by using the <code class="code" id="-dgcpq3_3">@Deprecated</code> annotation and <code class="code" id="-dgcpq3_4">ReplaceWith</code> quickfix), this document serves as a reference point for the migration steps necessary to switch to the new query DSL.</p><section class="chapter"><h2 id="select-query-dsl" data-toc="select-query-dsl">SELECT Query DSL</h2><p id="-dgcpq3_5">Exposed's query DSL has been refactored to bring it closer to the syntax of a standard SQL <code class="code" id="-dgcpq3_6">SELECT</code> statement.</p><p id="-dgcpq3_7">The <code class="code" id="-dgcpq3_8">slice()</code> function has been deprecated in favor of a new <code class="code" id="-dgcpq3_9">select()</code> function that accepts the same variable amount of columns and creates a <code class="code" id="-dgcpq3_10">Query</code> instance. If all columns should be selected, use <code class="code" id="-dgcpq3_11">selectAll()</code> to create a <code class="code" id="-dgcpq3_12">Query</code> instance.</p><p id="-dgcpq3_13">The <code class="code" id="-dgcpq3_14">Query</code> class now has the method <code class="code" id="-dgcpq3_15">where()</code>, which can be chained to replace the old version of <code class="code" id="-dgcpq3_16">select { }</code>.</p><p id="-dgcpq3_17"><a href="#migration-steps" id="-dgcpq3_18" data-tooltip="Use Edit > Find > Find in Files... to find any use of adjustSlice, then use the Alt+Enter quickfix with "Replace usages of '...' in whole project". Repeat step 1 with all the deprecated methods in the following list: slice Query.select: enter…">Go to migration steps</a></p><p id="-dgcpq3_19">Putting these changes together results in the following new DSL:</p><div class="code-block" data-lang="kotlin">
// 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()
</div><p id="-dgcpq3_21">To be consistent with these changes, the functions <code class="code" id="-dgcpq3_22">selectBatched()</code> and <code class="code" id="-dgcpq3_23">selectAllBatched()</code> have also been deprecated. A new <code class="code" id="-dgcpq3_24">Query</code> method, <code class="code" id="-dgcpq3_25">fetchBatchedResults()</code>, should be used instead as a terminal operation on an existing <code class="code" id="-dgcpq3_26">Query</code>:</p><div class="code-block" data-lang="kotlin">
// 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)
</div><p id="-dgcpq3_28">Lastly, <code class="code" id="-dgcpq3_29">adjustSlice()</code> has been renamed to <code class="code" id="-dgcpq3_30">adjustSelect()</code>:</p><div class="code-block" data-lang="kotlin">
// 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) }
</div></section><section class="chapter"><h2 id="migration-steps" data-toc="migration-steps">Migration Steps</h2><ol class="list _decimal" id="-dgcpq3_32" type="1"><li class="list__item" id="-dgcpq3_33"><p>Use <span class="emphasis" id="-dgcpq3_34">Edit > Find > Find in Files...</span> to find any use of <code class="code" id="-dgcpq3_35">adjustSlice</code>, then use the <code class="code" id="-dgcpq3_36">Alt+Enter</code> quickfix with "Replace usages of '...' in whole project".</p></li><li class="list__item" id="-dgcpq3_37"><p>Repeat step 1 with all the deprecated methods in the following list: </p><ul class="list _bullet" id="-dgcpq3_38"><li class="list__item" id="-dgcpq3_39"><p><code class="code" id="-dgcpq3_40">slice</code></p></li><li class="list__item" id="-dgcpq3_41"><p><code class="code" id="-dgcpq3_42">Query.select</code>: enter <code class="code" id="-dgcpq3_43">select\((\s*.+\s*)\)(\s*)\.select</code> in the search bar (with the regex tab enabled) to find this method easily</p></li><li class="list__item" id="-dgcpq3_44"><p><code class="code" id="-dgcpq3_45">select</code></p></li><li class="list__item" id="-dgcpq3_46"><p><code class="code" id="-dgcpq3_47">selectBatched</code></p></li><li class="list__item" id="-dgcpq3_48"><p><code class="code" id="-dgcpq3_49">selectAllBatched</code></p></li></ul></li><li class="list__item" id="-dgcpq3_50"><p>Use <span class="emphasis" id="-dgcpq3_51">Edit > Find > Replace in Files...</span> to resolve any redundant/incompatible uses of <code class="code" id="-dgcpq3_52">selectAll()</code>: </p><ul class="list _bullet" id="-dgcpq3_53"><li class="list__item" id="-dgcpq3_54"><p>Enter <code class="code" id="-dgcpq3_55">select\((\s*.+\s*)\)(\s*)\.selectAll\(\)</code> in the search bar (with the regex tab enabled)</p></li><li class="list__item" id="-dgcpq3_56"><p>Enter <code class="code" id="-dgcpq3_57">select\($1\)</code> in the replace bar</p></li><li class="list__item" id="-dgcpq3_58"><p>Confirm the results and select "Replace All"</p></li></ul></li><li class="list__item" id="-dgcpq3_59"><p>Rebuild the project</p></li></ol></section><div class="last-modified">Last modified: 14 January 2025</div><div data-feedback-placeholder="true"></div><div class="navigation-links _bottom"><a href="breaking-changes.html" class="navigation-links__prev">Breaking Changes</a><a href="frequently-asked-questions.html" class="navigation-links__next">Frequently Asked Questions</a></div></article><div id="disqus_thread"></div></div></section></main></div><script src="https://resources.jetbrains.com/writerside/apidoc/6.10.0-b267/app.js"></script></body></html>