From b70ed124eb753091a6afe637d75e59ee9771c8eb Mon Sep 17 00:00:00 2001 From: Fabio Di Stasio Date: Wed, 25 Sep 2024 09:18:37 +0200 Subject: [PATCH 1/6] feat(translation): traditional chinese translation, closes #869 --- src/renderer/i18n/index.ts | 5 +- src/renderer/i18n/supported-locales.ts | 1 + src/renderer/i18n/zh-TW.ts | 569 +++++++++++++++++++++++++ 3 files changed, 574 insertions(+), 1 deletion(-) create mode 100644 src/renderer/i18n/zh-TW.ts diff --git a/src/renderer/i18n/index.ts b/src/renderer/i18n/index.ts index 1d36df6e..a24e4a0e 100644 --- a/src/renderer/i18n/index.ts +++ b/src/renderer/i18n/index.ts @@ -17,6 +17,8 @@ import { ruRU } from './ru-RU'; import { ukUA } from './uk-UA'; import { viVN } from './vi-VN'; import { zhCN } from './zh-CN'; +import { zhTW } from './zh-TW'; + const messages = { 'en-US': enUS, 'it-IT': itIT, @@ -34,7 +36,8 @@ const messages = { 'nl-NL': nlNL, 'ca-ES': caES, 'cs-CZ': csCZ, - 'uk-UA': ukUA + 'uk-UA': ukUA, + 'zh-TW': zhTW }; type NestedPartial = { diff --git a/src/renderer/i18n/supported-locales.ts b/src/renderer/i18n/supported-locales.ts index 25ae32de..f0adbf97 100644 --- a/src/renderer/i18n/supported-locales.ts +++ b/src/renderer/i18n/supported-locales.ts @@ -9,6 +9,7 @@ export const localesNames: Record = { 'vi-VN': 'Tiếng Việt', 'ja-JP': '日本語', 'zh-CN': '简体中文', + 'zh-TW': '繁體中文', 'ru-RU': 'Русский', 'id-ID': 'Bahasa Indonesia', 'ko-KR': '한국어', diff --git a/src/renderer/i18n/zh-TW.ts b/src/renderer/i18n/zh-TW.ts new file mode 100644 index 00000000..210784c2 --- /dev/null +++ b/src/renderer/i18n/zh-TW.ts @@ -0,0 +1,569 @@ +export const zhTW = { + general: { + // 通用術語 + edit: '編輯', + save: '保存', + close: '關閉', + delete: '刪除', + confirm: '確定', + cancel: '取消', + send: '發送', + refresh: '重新整理', + autoRefresh: '自動重新整理', + version: '版本', + donate: '捐贈', + run: '執行', + results: '結果', + size: '大小', + mimeType: 'MIME類型', + download: '下載', + add: '新增', + data: '資料', + properties: '屬性', + name: '名稱', + clear: '清除', + options: '選項', + insert: '插入', + discard: '丟棄', + stay: '等待', + author: '作者', + upload: '上傳', + browse: '瀏覽', + content: '內容', + cut: '剪下', + copy: '複製', + paste: '貼上', + duplicate: '副本', + tools: '工具', + seconds: '秒', + all: '全部', + new: '新', + select: '選擇', + change: '變更', + include: '包含', + includes: '包含', + completed: '已完成', + aborted: '中止', + disabled: '已禁用', + enable: '啟用', + disable: '禁用', + contributors: '貢獻者', + pin: '固定', + unpin: '取消固定', + folder: '檔案夾 | 檔案夾', + none: '無', + singleQuote: '單引號', + doubleQuote: '雙引號', + deleteConfirm: '您是否確認取消', + uploadFile: '上傳檔案', + format: '格式碼', // 格式碼 + history: '曆史', + filter: '過濾器', + manualValue: '手動值', + selectAll: '選擇全部', + pageNumber: '頁數', + directoryPath: '目錄路徑', + actionSuccessful: '{action} 成功', + outputFormat: '輸出格式', + singleFile: '單個 {ext} 檔案', + zipCompressedFile: 'ZIP 壓縮 {ext} 檔案', + copyName: '複製名稱', + search: '搜索', + title: '標題', + archive: '封存', + undo: '重做', + moveTo: '移動到' + }, + connection: { + // 資料庫連接 + connection: '連線', + connectionName: '連線名稱', + hostName: '主機名', + client: '資料庫類型', + port: '連線埠', + user: '使用者', + password: '密碼', + credentials: '憑證', + connect: '連線', + connected: '已連線', + disconnect: '斷開連線', + disconnected: '斷開連線', + ssl: 'SSL', + enableSsl: '啟用 SSL', + privateKey: '私鑰', + certificate: '證書', + caCertificate: 'CA 證書', + ciphers: '密碼', + untrustedConnection: '不受信任的連線', + passphrase: '密碼提示', + sshTunnel: 'SSH 通道', + enableSsh: '啟用 SSH', + connectionString: '連接字符串', + addConnection: '新增連線', + createConnection: '建立連線', + createNewConnection: '建立新連線', + askCredentials: '詢問憑據', + testConnection: '測試連線', + editConnection: '編輯連線', + deleteConnection: '刪除連線', + connectionSuccessfullyMade: '連線成功了!', + readOnlyMode: '唯讀模式', + allConnections: '所有連線', + searchForConnections: '搜索連線', + keepAliveInterval: '保持活躍間隔', + singleConnection: '單一連線' + }, + database: { + // 資料庫庫相關術語 + schema: '模式(schema)', + type: '類型', + insert: '插入', + indexes: '索引', + foreignKeys: '外鍵', + length: '長度', + unsigned: '無符號', + default: '預設', + comment: '註釋', + key: '鍵 | 鍵', + order: '排序', + expression: '表達式', + autoIncrement: '自動增量', + engine: '引擎', + field: '字段 | 字段', + approximately: '大約', + total: '總計', + table: '表 | 表', + view: '視圖 | 視圖', + definer: '定義者', + algorithm: '算法', + trigger: '觸發器 | 觸發器', + storedRoutine: '存儲例程 | 存儲例程', + scheduler: '調度器 | 調度器', + event: '事件', + parameters: '參數', + function: '函數 | 函數', + deterministic: '確定的', + context: '上下文', + export: '匯出', + import: '匯入', + returns: '回傳', + timing: '定時', + state: '狀態', + execution: '執行', + starts: '開始', + ends: '結束', + variables: '變數', + processes: '進程', + database: '資料庫', + array: '數據', + structure: '結構', + row: '行 | 行', + cell: '單元格 | 單元格', + triggerFunction: '觸發器函數 | 觸發器函數', + routine: '例程 | 例程', + drop: 'Drop', + commit: '提交', + rollback: '回滾', + ddl: '資料定義語言', + collation: '排序規則', + resultsTable: '結果表', + unableEditFieldWithoutPrimary: '無法編輯結果集中一個沒有主鍵的字段', + editCell: '編輯單元格', + deleteRows: '刪除行 | 刪除 {count} 行', + confirmToDeleteRows: '您是否確認要刪除一行? | 您是否確認要刪除 {count} 行?', + addNewRow: '新增行', + numberOfInserts: '插入的數量', + affectedRows: '受影響的行', + createNewDatabase: '建立新資料庫', + databaseName: '資料庫名稱', + serverDefault: '預設伺服器', + deleteDatabase: '刪除資料庫', + editDatabase: '編輯資料庫', + clearChanges: '清除變更', + addNewField: '新增新字段', + manageIndexes: '管理索引', + manageForeignKeys: '管理外鍵', + allowNull: '允許 NULL', + zeroFill: 'zeroFill', + customValue: '自定義值', + onUpdate: '在更新', + deleteField: '刪除字段', + createNewIndex: '建立新索引', + addToIndex: '新增到索引', + createNewTable: '建立新表', + emptyTable: '清空表', + duplicateTable: '重複表', + deleteTable: '刪除表', + exportTable: '導出表', + emptyConfirm: '您是否確認清空', + thereAreNoIndexes: '沒有索引', + thereAreNoForeign: '沒有外鍵', + createNewForeign: '建立新外鍵', + referenceTable: '參考表', + referenceField: '參考字段', + foreignFields: '外鍵字段', + invalidDefault: '無效預設值', + onDelete: '在刪除', + selectStatement: '選擇語句', + triggerStatement: '觸發器語句', + sqlSecurity: 'SQL 安全', + updateOption: '更新選項', + deleteView: '刪除視圖', + createNewView: '建立新視圖', + deleteTrigger: '刪除觸發器', + createNewTrigger: '建立新觸發器', + currentUser: '當前使用者', + routineBody: '例程主體', + dataAccess: '數據訪問', + thereAreNoParameters: '沒有參數', + createNewParameter: '建立新參數', + createNewRoutine: '建立新存儲例程', + deleteRoutine: '刪除存儲例程', + functionBody: '函數體', + createNewFunction: '建立新函數', + deleteFunction: '刪除函數', + schedulerBody: '調度器主體', + createNewScheduler: '建立新調度器', + deleteScheduler: '刪除調度器', + preserveOnCompletion: '完成時保留', + tableFiller: '表填充器', + fakeDataLanguage: '僞造的數據語言', + queryDuration: '查詢持續時間', + setNull: '設定 NULL', + processesList: '進程列表', + processInfo: '進程信息', + manageUsers: '管理使用者', + createNewSchema: '建立新模式(schema)', + schemaName: '模式名稱', + editSchema: '編輯模式', + deleteSchema: '刪除模式', + noSchema: '沒有模式', + runQuery: '運行查詢', + thereAreNoTableFields: '沒有表的字段', + newTable: '新表', + newView: '新視圖', + newTrigger: '新觸發器', + newRoutine: '新例程', + newFunction: '新函數', + newScheduler: '新調度器', + newTriggerFunction: '新觸發器函數', + thereAreNoQueriesYet: '目前還沒有任何查詢', + searchForQueries: '搜索查詢', + killProcess: '終止進程', + exportSchema: '導出模式(schema)', + importSchema: '導入模式(schema)', + newInsertStmtEvery: '每條新的 INSERT 語句', + processingTableExport: '處理 {table}', + fetchingTableExport: '正在獲取 {table} 數據', + writingTableExport: '正在寫入 {table} 數據', + checkAllTables: '檢查所有表', + uncheckAllTables: '不檢查所有表', + killQuery: '終止查詢', + insertRow: '插入單行 | 插入多行', + commitMode: '提交模式', + autoCommit: '自動提交', + manualCommit: '手動提交', + importQueryErrors: '警告: 發生了 {n} 個錯誤 | 警告: 發生了 {n} 個錯誤', + executedQueries: '{n} 個查詢已執行 | {n} 個查詢已執行', + disableFKChecks: '禁用外鍵檢查', + formatQuery: '格式查詢', + queryHistory: '查詢曆史', + clearQuery: '清除查詢', + fillCell: '填充單元格', + executeSelectedQuery: '執行所選查詢', + noResultsPresent: '沒有結果', + sqlExportOptions: 'SQL 導出選項', + targetTable: '目標表', + switchDatabase: '切換資料庫', + searchForElements: '搜索元素', + searchForSchemas: '搜索模式(schema)', + savedQueries: '已保存的查詢' + }, + application: { + // 應用程式相關術語 + settings: '設定', + console: '控製臺', + general: '常規', + themes: '主題', + update: '更新', + about: '關於', + language: '語言', + shortcuts: '捷徑', + key: '按鍵 | 按鍵', // 鍵盤按鍵 + event: '事件', + light: '明亮', + dark: '暗黑', + autoCompletion: '自動完成', + application: '應用程式', + editor: '編輯器', + changelog: '變更日誌', + small: '小', + medium: '中', + large: '大', + appearance: '外觀', + color: '顔色', + label: '標簽', + icon: '圖示', + fileName: '檔案名稱', + choseFile: '選擇檔案', + data: '數據', + password: '密碼', + required: '依賴', + madeWithJS: '使用 💛 和 JavaScript 製作!', + checkForUpdates: '檢查更新', + noUpdatesAvailable: '無可用更新', + checkingForUpdate: '正在檢查更新', + checkFailure: '檢查失敗,請稍後再試', + updateAvailable: '可用更新', + downloadingUpdate: '正在下載更新', + updateDownloaded: '已下載更新', + restartToInstall: '重啟 Antares 以進行安裝', + includeBetaUpdates: '包含測試版更新', + notificationsTimeout: '通知超時', + openNewTab: '打開一個新標簽', + unsavedChanges: '未保存的變更', + discardUnsavedChanges: '您有一些未保存的變更, 關閉此標簽將放棄這些變更.', + applicationTheme: '應用程式主題', + editorTheme: '編輯器主題', + wrapLongLines: '將長行換行顯示', + markdownSupported: '支援 Markdown', + plantATree: '種植一棵樹', + dataTabPageSize: '資料標簽的頁面大小', + noOpenTabs: '沒有打開的標簽, 請在左側欄上導航或:', + restorePreviousSession: '恢複上一個會話', + closeTab: '關閉標簽', + goToDownloadPage: '轉到下載頁面', + disableBlur: '禁用模糊', + missingOrIncompleteTranslation: '有缺失或不完整的翻譯?', + findOutHowToContribute: '了解如何做出貢獻', + reportABug: '報告錯誤', + nextTab: '下一個標簽', + previousTab: '上一個標簽', + selectTabNumber: '選擇標簽編號 {param}', + toggleConsole: '切換控製臺', + addShortcut: '新增捷徑', + editShortcut: '編輯捷徑', + deleteShortcut: '刪除捷徑', + restoreDefaults: '恢複預設', + restoreDefaultsQuestion: '是否確認恢複預設值?', + registerAShortcut: '註冊捷徑', + invalidShortcutMessage: '無效組合,請繼續鍵入', + shortcutAlreadyExists: '捷徑已存在', + saveContent: '保存內容', + openAllConnections: '打開所有連接', + openSettings: '打開設定', + openScratchpad: '打開草稿欄', + runOrReload: '運行或重新加載', + openFilter: '打開過濾器', + nextResultsPage: '下一個結果頁', + previousResultsPage: '上一個結果頁', + editFolder: '編輯檔案夾', + folderName: '檔案夾名稱', + deleteFolder: '刪除檔案夾', + editConnectionAppearance: '編輯連接的外觀', + defaultCopyType: '預設複製類型', + showTableSize: '在側邊欄顯示表大小', + showTableSizeDescription: '僅限 MySQL/MariaDB. 啓用此選項可能會影響許多表的模式(schema)的性能.', + switchSearchMethod: '切換搜索方法', + phpArray: 'PHP 陣列', + closeAllTabs: '關閉所有標簽', + closeOtherTabs: '關閉其他標簽', + closeTabsToLeft: '關閉左側的標簽', + closeTabsToRight: '關閉右側的標簽', + csvFieldDelimiter: '字段分隔符', + csvLinesTerminator: '行終止符', + csvStringDelimiter: '字符串分隔符', + csvIncludeHeader: '包含頁眉', + csvExportOptions: 'CSV 導出選項', + exportData: '導出數據', + exportDataExplanation: '將保存的連接導出到 Antares. 係統將要求您輸入密碼以加密導出的檔案.', + importData: '導入數據', + importDataExplanation: '導入包含連接的 .antares 檔案. 您需要輸入在導出過程中定義的密碼.', + includeConnectionPasswords: '包含連接密碼', + includeFolders: '包含檔案夾', + encryptionPassword: '加密密碼', + encryptionPasswordError: '加密密碼的長度必須至少為 8 個字符.', + ignoreDuplicates: '忽略重複', + wrongImportPassword: '錯誤的導入密碼', + wrongFileFormat: '錯誤的檔案格式', + dataImportSuccess: '數據已成功導入', + note: '筆記 | 筆記', + thereAreNoNotesYet: '目前還沒有筆記', + addNote: '新增筆記', + editNote: '編輯筆記', + saveAsNote: '另存為筆記', + showArchivedNotes: '顯示歸檔筆記', + hideArchivedNotes: '隱藏歸檔筆記', + tag: '筆記標簽', // Note tag, + saveFile: '保存檔案', + saveFileAs: '將檔案另存為', + openFile: '打開檔案', + openNotes: '打開筆記' + }, + faker: { + // Faker.js 方法,用於隨機生成的內容 + address: '地址', + commerce: '商業', + company: '公司', + database: '資料庫', + date: '日期', + finance: '財務', + git: 'Git', + hacker: '駭客', + internet: '網際網路', + lorem: 'Lorem', + name: '姓名', + music: '音樂', + phone: '電話', + random: '隨機', + system: '系統', + time: '時間', + vehicle: '車輛', + zipCode: '郵政編碼', + zipCodeByState: '各州的郵政編碼', + city: '城市', + cityPrefix: '城市前綴', + citySuffix: '城市字尾', + streetName: '街道名稱', + streetAddress: '街道地址', + streetSuffix: '街道字尾', + streetPrefix: '街道前綴', + secondaryAddress: '次要地址', + county: '縣', + country: '國家', + countryCode: '國家代碼', + state: '州', + stateAbbr: '州簡稱', + latitude: '緯度', + longitude: '經度', + direction: '\'方向\'', + cardinalDirection: '方位', + ordinalDirection: '順序方向', + nearbyGPSCoordinate: '附近的 GPS 坐標', + timeZone: '時區', + color: '顔色', + department: '部門', + productName: '産品名稱', + price: '價格', + productAdjective: '産品形容詞', + productMaterial: '産品材料', + product: '産品', + productDescription: '産品說明', + suffixes: '字尾', + companyName: '公司名稱', + companySuffix: '公司字尾', + catchPhrase: '流行語', + bs: 'BS', + catchPhraseAdjective: '流行語形容詞', + catchPhraseDescriptor: '流行語說明', + catchPhraseNoun: '流行語名詞', + bsAdjective: 'BS 形容詞', + bsBuzz: 'BS 嗡嗡聲', + bsNoun: 'BS 名稱', + column: '列', + type: '類型', + collation: '排序規則', + engine: '引擎', + past: '過去', + now: '現在', + future: '未來', + between: '之間', + recent: '最近', + soon: '很快', + month: '月', + weekday: '工作日', + account: '帳戶', + accountName: '帳戶名稱', + routingNumber: '路由編號', + mask: '掩碼', + amount: '金額', + transactionType: '交易類型', + currencyCode: '貨幣代碼', + currencyName: '貨幣名稱', + currencySymbol: '貨幣符號', + bitcoinAddress: '位元幣地址', + litecoinAddress: '萊特幣地址', + creditCardNumber: '信用卡號碼', + creditCardCVV: '信用卡CVV', + ethereumAddress: '以太坊地址', + iban: 'Iban', + bic: 'Bic', + transactionDescription: '交易描述', + branch: '分支', + commitEntry: '提交條目', + commitMessage: '提交信息', + commitSha: '提交 SHA', + shortSha: '短的 SHA', + abbreviation: '縮寫', + adjective: '形容詞', + noun: '名詞', + verb: '動詞', + ingverb: '英式動詞', + phrase: '短語', + avatar: '頭像', + email: '電子信箱', + exampleEmail: '示例電子郵件', + userName: '使用者名', + protocol: '協議', + url: '統一資源定位地址', + domainName: '域名', + domainSuffix: '域名字尾', + domainWord: '域詞', + ip: 'Ip', + ipv6: 'Ipv6', + userAgent: '使用者代理', + mac: 'Mac', + password: '密碼', + word: '單詞', + words: '單詞', + sentence: '句子', + slug: 'Slug', + sentences: '句子', + paragraph: '段落', + paragraphs: '段落', + text: '文本', + lines: '行', + genre: '類型', + firstName: '名', + lastName: '姓氏', + middleName: '中間名', + findName: '全名', + jobTitle: '職位名稱', + gender: '性別', + prefix: '前綴', + suffix: '字尾', + title: '頭銜', + jobDescriptor: '工作描述', + jobArea: '工作領域', + jobType: '工作類型', + phoneNumber: '電話號碼', + phoneNumberFormat: '電話號碼格式', + phoneFormats: '電話格式', + number: '號碼', + float: 'Float', + arrayElement: '陣列元素', + arrayElements: '陣列元素', + objectElement: '物件元素', + uuid: 'Uuid', + boolean: '布林', + image: '鏡像', + locale: '區域', + alpha: '阿爾法', + alphaNumeric: 'α 數字', + hexaDecimal: '十六進製', + fileName: '檔案名', + commonFileName: '普通檔案名', + mimeType: 'MIME類型', + commonFileType: '常見檔案類型', + commonFileExt: '常見檔案擴展名', + fileType: '檔案類型', + fileExt: '檔案擴展名', + directoryPath: '目錄路徑', + filePath: '檔案路徑', + semver: 'Semver', + manufacturer: '製造商', + model: '型號', + fuel: 'Fuel', + vin: 'Vin' + } +}; From c111b2c0f5a9b005a8cb7fdf163c32a09fd47240 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 25 Sep 2024 07:19:17 +0000 Subject: [PATCH 2/6] docs: update README.md [skip ci] --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ec4546ef..ff511cac 100644 --- a/README.md +++ b/README.md @@ -152,6 +152,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d Bagus Indrayana
Bagus Indrayana

💻 Naoki Ishikawa
Naoki Ishikawa

🌍 Filipe Azevedo
Filipe Azevedo

💻 + CHANG, CHIH WEI
CHANG, CHIH WEI

🌍 From c5cb5863585bc6948a16da90a2f44adc19a284f0 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 25 Sep 2024 07:19:18 +0000 Subject: [PATCH 3/6] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index e5cf7807..a4ae2cca 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -293,6 +293,15 @@ "contributions": [ "code" ] + }, + { + "login": "zwei-c", + "name": "CHANG, CHIH WEI", + "avatar_url": "https://avatars.githubusercontent.com/u/55912811?v=4", + "profile": "https://github.com/zwei-c", + "contributions": [ + "translation" + ] } ], "contributorsPerLine": 7, From ebd1a7544594eb4498560cc64de4b94146ee8439 Mon Sep 17 00:00:00 2001 From: mirrorb <630773165@qq.com> Date: Fri, 27 Sep 2024 17:43:54 +0800 Subject: [PATCH 4/6] feat(PostgreSQL): table and field comments --- src/common/customizations/postgresql.ts | 1 + src/main/libs/clients/PostgreSQLClient.ts | 48 +++++++++++++++++------ 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/src/common/customizations/postgresql.ts b/src/common/customizations/postgresql.ts index 7c5ad703..571f0c4b 100644 --- a/src/common/customizations/postgresql.ts +++ b/src/common/customizations/postgresql.ts @@ -62,6 +62,7 @@ export const customizations: Customizations = { indexes: true, foreigns: true, nullable: true, + comment: true, tableArray: true, procedureSql: '$procedure$\r\n\r\n$procedure$', procedureContext: true, diff --git a/src/main/libs/clients/PostgreSQLClient.ts b/src/main/libs/clients/PostgreSQLClient.ts index f71dbcf7..6fac21d9 100644 --- a/src/main/libs/clients/PostgreSQLClient.ts +++ b/src/main/libs/clients/PostgreSQLClient.ts @@ -494,16 +494,27 @@ export class PostgreSQLClient extends BaseClient { column_default: string; character_set_name: string; collation_name: string; + column_comment: string; } /* eslint-enable camelcase */ - const { rows } = await this - .select('*') - .schema('information_schema') - .from('columns') - .where({ table_schema: `= '${schema}'`, table_name: `= '${table}'` }) - .orderBy({ ordinal_position: 'ASC' }) - .run(); + // Table columns + const { rows } = await this.raw>(` + WITH comments AS ( + SELECT attr.attname AS column, des.description AS comment, pgc.relname + FROM pg_attribute AS attr, pg_description AS des, pg_class AS pgc + WHERE pgc.oid = attr.attrelid + AND des.objoid = pgc.oid + AND pg_table_is_visible(pgc.oid) + AND attr.attnum = des.objsubid + ) + SELECT cols.*, comments.comment AS column_comment + FROM "information_schema"."columns" AS cols + LEFT JOIN comments ON comments.column = cols.column_name AND comments.relname = cols.table_name + WHERE cols.table_schema = '${schema}' + AND cols.table_name = '${table}' + ORDER BY "ordinal_position" ASC + `); return rows.map(field => { let type = field.data_type; @@ -532,7 +543,7 @@ export class PostgreSQLClient extends BaseClient { collation: field.collation_name, autoIncrement: false, onUpdate: null, - comment: '' + comment: field.column_comment }; }); } @@ -869,6 +880,7 @@ export class PostgreSQLClient extends BaseClient { const newIndexes: string[] = []; const manageIndexes: string[] = []; const newForeigns: string[] = []; + const modifyComment: string[] = []; let sql = `CREATE TABLE "${schema}"."${options.name}"`; @@ -884,6 +896,8 @@ export class PostgreSQLClient extends BaseClient { ${field.nullable ? 'NULL' : 'NOT NULL'} ${field.default !== null ? `DEFAULT ${field.default || '\'\''}` : ''} ${field.onUpdate ? `ON UPDATE ${field.onUpdate}` : ''}`); + if (field.comment != null) + modifyComment.push(`COMMENT ON COLUMN "${schema}"."${options.name}"."${field.name}" IS '${field.comment}'`); }); // ADD INDEX @@ -904,8 +918,12 @@ export class PostgreSQLClient extends BaseClient { newForeigns.push(`CONSTRAINT "${foreign.constraintName}" FOREIGN KEY ("${foreign.field}") REFERENCES "${schema}"."${foreign.refTable}" ("${foreign.refField}") ON UPDATE ${foreign.onUpdate} ON DELETE ${foreign.onDelete}`); }); - sql = `${sql} (${[...newColumns, ...newIndexes, ...newForeigns].join(', ')})`; - if (manageIndexes.length) sql = `${sql}; ${manageIndexes.join(';')}`; + sql = `${sql} (${[...newColumns, ...newIndexes, ...newForeigns].join(', ')}); `; + if (manageIndexes.length) sql = `${sql} ${manageIndexes.join(';')}; `; + // TABLE COMMENT + if (options.comment) sql = `${sql} COMMENT ON TABLE "${schema}"."${options.name}" IS '${options.comment}'; `; + // FIELDS COMMENT + if (modifyComment.length) sql = `${sql} ${modifyComment.join(';')}; `; return await this.raw(sql); } @@ -930,6 +948,7 @@ export class PostgreSQLClient extends BaseClient { const renameColumns: string[] = []; const createSequences: string[] = []; const manageIndexes: string[] = []; + const modifyComment: string[] = []; // ADD FIELDS additions.forEach(addition => { @@ -943,6 +962,8 @@ export class PostgreSQLClient extends BaseClient { ${addition.nullable ? 'NULL' : 'NOT NULL'} ${addition.default !== null ? `DEFAULT ${addition.default || '\'\''}` : ''} ${addition.onUpdate ? `ON UPDATE ${addition.onUpdate}` : ''}`); + if (addition.comment != null) + modifyComment.push(`COMMENT ON COLUMN "${schema}"."${table}"."${addition.name}" IS '${addition.comment}'`); }); // ADD INDEX @@ -995,6 +1016,8 @@ export class PostgreSQLClient extends BaseClient { if (change.orgName !== change.name) renameColumns.push(`ALTER TABLE "${schema}"."${table}" RENAME COLUMN "${change.orgName}" TO "${change.name}"`); + if (change.comment != null) + modifyComment.push(`COMMENT ON COLUMN "${schema}"."${table}"."${change.name}" IS '${change.comment}'`); }); // CHANGE INDEX @@ -1042,8 +1065,11 @@ export class PostgreSQLClient extends BaseClient { if (alterColumns.length) sql += `ALTER TABLE "${schema}"."${table}" ${alterColumns.join(', ')}; `; if (createSequences.length) sql = `${createSequences.join(';')}; ${sql}`; if (manageIndexes.length) sql = `${manageIndexes.join(';')}; ${sql}`; + // TABLE COMMENT + if (options.comment) sql = `${sql} COMMENT ON TABLE ${schema}.${table} IS '${options.comment}'; `; + // FIELDS COMMENT + if (modifyComment.length) sql = `${sql} ${modifyComment.join(';')}; `; if (options.name) sql += `ALTER TABLE "${schema}"."${table}" RENAME TO "${options.name}"; `; - // RENAME if (renameColumns.length) sql = `${renameColumns.join(';')}; ${sql}`; From a02913f4e53523b7f2b216874b687474075e560f Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Sat, 28 Sep 2024 13:46:02 +0000 Subject: [PATCH 5/6] docs: update README.md [skip ci] --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ff511cac..28cc42c8 100644 --- a/README.md +++ b/README.md @@ -153,6 +153,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d Naoki Ishikawa
Naoki Ishikawa

🌍 Filipe Azevedo
Filipe Azevedo

💻 CHANG, CHIH WEI
CHANG, CHIH WEI

🌍 + GaoChun
GaoChun

💻 From 0d3ef398229c9485d10c08bf433cb87e9bb86918 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Sat, 28 Sep 2024 13:46:03 +0000 Subject: [PATCH 6/6] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index a4ae2cca..f48ad6c1 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -302,6 +302,15 @@ "contributions": [ "translation" ] + }, + { + "login": "mirrorb", + "name": "GaoChun", + "avatar_url": "https://avatars.githubusercontent.com/u/34116207?v=4", + "profile": "https://github.com/mirrorb", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 7,