npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dbgate-plugin-postgres-autoquote

v0.2.0

Published

PostgreSQL driver for DbGate that quotes PascalCase identifiers automatically. ![icon](https://cdn.jsdelivr.net/npm/[email protected]/icon.svg)

Readme

dbgate-plugin-postgres-autoquote

在 DBGate 查詢 PostgreSQL 時,自動替 PascalCase 表名與欄位名稱加上雙引號。可以沿用原有的自動補全,直接輸入名稱;外掛會在送出查詢前,核對資料庫中的名稱並補上引號。

以 DBGate 7.3.1 與 PostgreSQL 17 驗證。其他版本尚未驗證。

安裝

  1. 在 DBGate 的 Plugins 搜尋 dbgate-plugin-postgres-autoquote 並安裝。
  2. 重新啟動 DBGate。
  3. 將要使用的連線 driver 設為 PostgreSQL(自動補引號)。

原有連線設定可繼續使用。停用時,將 driver 切回 PostgreSQL;移除外掛前,也請先切回原 driver。

使用範例

資料庫中有 "SampleItem" 表,包含 "SampleId" 與 "ItemNumber" 欄位時,可以輸入:

select *
from SampleItem item
where item.SampleId = 1001
  and item.ItemNumber in (10, 20);

外掛核對名稱後,送出的查詢為:

select *
from "SampleItem" item
where item."SampleId" = 1001
  and item."ItemNumber" in (10, 20);

編輯器與 SQL 歷史保留原文。字串、註解、參數、已加引號的名稱與 alias 保持原樣;PostgreSQL 語法錯誤直接顯示原始訊息。

支援範圍

  • SELECT、INSERT、UPDATE、DELETE、MERGE,包含 RETURNING 與 ON CONFLICT。
  • WITH、遞迴與寫入 CTE、子查詢、衍生表、UNION、window function、DISTINCT ON。
  • JOIN、USING、AS 別名與省略 AS 的寫法;依同一條連線的 search_path 與 temp table 核對名稱。

若表中還有 "IsArchived" 欄位,更新資料時可以輸入:

update SampleItem as item
set IsArchived = true
where item.SampleId = 1001;

外掛只補引號。PostgreSQL 不允許 SET item.IsArchived = ...,請在 SET 左側使用 IsArchived,其他子句仍可使用表別名。

只處理以 ASCII 大寫字母開頭、與資料庫實際名稱相符的表名、schema 與欄位。明確 alias 和 CTE 名稱保留原有大小寫規則;衍生表與 CTE 的隱含輸出欄位會沿用內層查詢確認的名稱。

找不到表或欄位、欄位重名及語法錯誤,由 PostgreSQL 回傳原生訊息。外掛不猜測拼字、不新增限定詞、不重試寫入。

限制

DDL、COPY、DO、函式本體、動態 SQL、函式/型別/constraint 名稱不套用自動補引號。未支援的語法角色或無法確認改寫位置時,外掛會停止並提示限制;已明確引用且不需修改的語句保留原文。

JSON_TABLE、CTE 的 SEARCH/CYCLE、ROWS FROM 內的欄位定義、複合欄位及無法確認的 FROM 函式輸出,目前尚未支援改寫。若涉及需要處理的名稱,會提示限制。

自動補引號的 SQL 上限為 256 KiB,解析期限為 1.5 秒;名稱資訊準備期限為 5 秒。名稱資訊逾時會關閉連線,未提交交易將 rollback,需重新連線。每次查詢核對同一個 session 的 metadata,仍可能受並行 DDL 影響。

外掛沿用資料庫角色的權限與 DBGate 原有交易行為。AWS IAM 連線須使用主機欄位,並啟用 TLS 憑證驗證。

手動安裝

關閉 DBGate,將套件解開到 workspace 的 plugins/dbgate-plugin-postgres-autoquote。桌面版預設位置為 ~/.dbgate/plugins/dbgate-plugin-postgres-autoquote;自訂 workspace 請使用對應目錄。

若解開 npm 的 .tgz,將 package 資料夾改為 dbgate-plugin-postgres-autoquote。保留完整套件,重新啟動後選用新 driver。

開發

需要 Node.js 20 以上。

npm ci --ignore-scripts
npm test
npm run build
npm run preview -- examples/query.sql examples/catalog.json

授權

GPL-3.0。衍生自 DBGate 的 PostgreSQL driver;來源、授權與修改範圍見 UPSTREAM.md。