Registry / database / sql-language-server

sql-language-server

JSON →
library1.7.1jsnpmunverified

sql-language-server is an implementation of the Language Server Protocol (LSP) providing intelligent features for various SQL dialects, including linting, autocompletion, and schema introspection. It is designed to be run as a standalone server process, enabling integration with code editors and IDEs (like VS Code) that support LSP. The current stable version is 1.7.1, with minor releases appearing to follow a monthly or bi-monthly cadence, indicating active development. Key differentiators include its pluggable architecture for different SQL database clients (e.g., PostgreSQL, SQLite, BigQuery) and its focus on robust parsing and error handling, making it a valuable tool for SQL development workflows. It ships with TypeScript types, facilitating its use in TypeScript-based environments.

npm install sql-language-server
INSTALL
IMPORT
SIG · SQL-LANGUAGE-SERVE
S
sql-language-server
databasejavascriptv1.7.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Config
import type { Config } from 'sql-language-server'
Primarily an executable server. This type defines configuration options sent from the client to the server and is used for type checking client-side configurations. Direct programmatic import of server logic is not the primary use case.
SQLOption
import type { SQLOption } from 'sql-language-server'
Primarily an executable server. This type defines specific SQL-related options within the server configuration. Used for type checking client-side configurations rather than direct library usage.
LSP_SERVER_NAME
import { LSP_SERVER_NAME } from 'sql-language-server'
Primarily an executable server. This constant provides the name identifier for the language server. While exported, the main interaction is running the server, not importing this constant into an application.

Demonstrates how to install the SQL Language Server globally and run it via standard I/O. Includes a commented example of how an LSP client in a VS Code extension might programmatically start and connect to the server process.

npm install -g sql-language-server # To run the language server, typically it's invoked by an LSP-enabled editor # or manually via standard I/O (stdio) for debugging/testing: sql-language-server --stdio # Example of how an LSP client (e.g., in a VS Code extension) might start it: // In a client-side extension's activate() function: // import * as path from 'path'; // import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind } from 'vscode-languageclient/node'; // let serverModule = context.asAbsolutePath(path.join('node_modules', 'sql-language-server', 'lib', 'main.js')); // let debugOptions = { execArgv: ['--nolazy', '--inspect=6009'] }; // let serverOptions: ServerOptions = { // run: { module: serverModule, transport: TransportKind.stdio }, // debug: { module: serverModule, transport: TransportKind.stdio, options: debugOptions } // }; // let clientOptions: LanguageClientOptions = { // documentSelector: [{ scheme: 'file', language: 'sql' }], // synchronize: { fileEvents: workspace.createFileSystemWatcher('**/.sql') } // }; // let client = new LanguageClient('sqlLanguageServer', 'SQL Language Server', serverOptions, clientOptions); // client.start();
sql-language-server --version
Debug
Known issues
breakingUpgrading `vscode-languageserver` to version `8.0.0-next.8` in v1.2.1 may introduce breaking changes or require compatibility adjustments for host environments or custom LSP clients relying on older `vscode-languageserver` API contracts.
fix
Review the `vscode-languageserver` changelog for `8.0.0-next.8` and update any custom client or host code that directly interacts with the LSP client/server libraries to ensure compatibility with the new API.
affects: >=1.2.1
gotchaPrior to v1.3.0, the server could be inadvertently booted twice in certain integration scenarios, leading to unexpected behavior or resource consumption issues.
fix
Upgrade to v1.3.0 or newer to benefit from the fix addressing the double-boot issue. Ensure proper lifecycle management of the server process within your LSP host environment.
affects: <1.3.0
gotchaOlder versions (pre-1.2.1) had issues correctly parsing SQL identifiers enclosed in double quotes, leading to incorrect linting or autocompletion.
fix
Upgrade to v1.2.1 or newer to resolve issues with double-quoted identifiers. Ensure your SQL parser configuration is up-to-date with the latest version's parsing capabilities.
affects: <1.2.1
gotchaVersion 1.3.3 introduced a change to 'not throw an error when it's failed to parse'. While this improves resilience, it might mask underlying syntax issues if clients rely on explicit parse errors for strict validation.
fix
Implement robust client-side validation or interpret diagnostics provided by the language server. Do not assume the absence of an error throw implies completely successful parsing in all contexts; instead, rely on the diagnostic messages provided by the LSP.
affects: >=1.3.3
Errors
Common errors & fixes
Error: Column 'column_name' not found in table 'table_name'
The language server's internal schema cache is outdated or incorrect for the current database connection or SQL dialect being used.
fix
Ensure the `sql-language-server` is correctly configured with the database connection details (e.g., PostgreSQL, SQLite). Manually trigger a schema refresh or restart the language server if the database schema has recently changed.
Failed to resolve root path config
The language server could not correctly determine its root directory or configuration files, often due to an incorrect working directory or misconfigured client-side settings.
fix
Ensure the language server is launched from the correct working directory that contains your SQL project. Verify client-side LSP configurations that specify the `rootPath` or `workspaceFolders` are pointing to valid directories.
Syntax error near 'IS NOT NULL' operation.
Older versions of the parser had a bug in correctly handling the right-hand side of `IS NOT NULL` operations.
fix
Upgrade to `sql-language-server` version 1.6.0 or newer, which contains a fix for this specific parsing error. If upgrading isn't an option, rephrase the SQL query to avoid the problematic `IS NOT NULL` pattern if possible.
Upgrade
Version history
1.7.1latest on npm
Audit
Dependencies
vscode-languageserverrequiredCore dependency for implementing the Language Server Protocol.
pg-clientoptionalUsed for connecting to PostgreSQL databases for schema introspection and completion. Optional if not using PostgreSQL.
sqlite3optionalUsed for connecting to SQLite databases for schema introspection and completion. Optional if not using SQLite.
Agent activity
16 hits · last 30 days
node
12
Meta
2
OpenAI (training)
1
Resources