From bf809f609847e23f5dd2060088a59d24b06a56f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=80=E6=BA=90=E6=B5=B7=E5=93=A5?= Date: Sun, 9 Apr 2023 10:49:04 +0800 Subject: [PATCH] update docs --- docs/.vitepress/config.ts | 2 +- docs/zh/querywrapper.md | 19 +++++++++++++++++++ .../coretest/AccountSqlTester.java | 1 + 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 4c0716c2..853018ef 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -102,7 +102,7 @@ export default defineConfig({ "script", {}, ` - if (location.protocol !== 'https:') { + if (location.protocol !== 'https:' && location.hostname != 'localhost') { location.href = 'https://' + location.hostname + location.pathname + location.search; } ` diff --git a/docs/zh/querywrapper.md b/docs/zh/querywrapper.md index 0f9d7cb3..9d9e31b6 100644 --- a/docs/zh/querywrapper.md +++ b/docs/zh/querywrapper.md @@ -347,6 +347,25 @@ ON tb_account.id = a.id WHERE tb_account.age >= ? ``` +## union, union all + +```java +QueryWrapper query = new QueryWrapper() + .select(ACCOUNT.ID) + .from(ACCOUNT) + .orderBy(ACCOUNT.ID.desc()) + .union(select(ARTICLE.ID).from(ARTICLE)) + .unionAll(select(ARTICLE.ID).from(ARTICLE)); +``` + +其查询生成的 Sql 如下: + +```sql +(SELECT id FROM tb_account ORDER BY id DESC) +UNION (SELECT id FROM tb_article) +UNION ALL (SELECT id FROM tb_article) +``` + ## limit... offset diff --git a/mybatis-flex-core/src/test/java/com/mybatisflex/coretest/AccountSqlTester.java b/mybatis-flex-core/src/test/java/com/mybatisflex/coretest/AccountSqlTester.java index 86f73df5..feb821e9 100644 --- a/mybatis-flex-core/src/test/java/com/mybatisflex/coretest/AccountSqlTester.java +++ b/mybatis-flex-core/src/test/java/com/mybatisflex/coretest/AccountSqlTester.java @@ -83,6 +83,7 @@ public class AccountSqlTester { QueryWrapper query = new QueryWrapper() .select(ACCOUNT.ID) .from(ACCOUNT) + .orderBy(ACCOUNT.ID.desc()) .union(select(ARTICLE.ID).from(ARTICLE)) .unionAll(select(ARTICLE.ID).from(ARTICLE));