{"id":43919,"library":"sql-match","title":"sql-match","description":"A spec-compliant implementation of SQL LIKE pattern matching for Node.js (version 2.0.0). It supports % and _ wildcards with backslash escaping, matching JavaScript strings against SQL-like patterns. No external dependencies. Released as an ESM-only module since v2.0.0. Differentiators: lightweight, no dependencies, simple API with two functions (isSQLMatch, sqlToRegex) for direct comparison or reusable regex creation. Not actively maintained, but API stable.","status":"active","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/stevenvachon/sql-match","tags":["javascript","match","sql","wildcard"],"install":[{"cmd":"npm install sql-match","lang":"bash","label":"npm"},{"cmd":"yarn add sql-match","lang":"bash","label":"yarn"},{"cmd":"pnpm add sql-match","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only since v2.0.0. CommonJS require() will fail with ERR_REQUIRE_ESM.","wrong":"const { isSQLMatch } = require('sql-match')","symbol":"isSQLMatch","correct":"import { isSQLMatch } from 'sql-match'"},{"note":"Same ESM restriction as isSQLMatch.","wrong":"const sqlToRegex = require('sql-match').sqlToRegex","symbol":"sqlToRegex","correct":"import { sqlToRegex } from 'sql-match'"},{"note":"CommonJS require() returns undefined because there is no default export. Only named exports exist.","wrong":"const sqlMatch = require('sql-match')","symbol":"default import","correct":"import sqlMatch from 'sql-match'"}],"quickstart":{"code":"import { isSQLMatch, sqlToRegex } from 'sql-match';\n\n// Direct comparison\nconsole.log(isSQLMatch('string', 'string')); // true\nconsole.log(isSQLMatch('%ing', 'string'));   // true\nconsole.log(isSQLMatch('_tring', 'string')); // true\nconsole.log(isSQLMatch('%', 'anything'));    // true\nconsole.log(isSQLMatch('_', 'a'));           // true\nconsole.log(isSQLMatch('\\\\%', '%'));       // true (escaped literal %)\n\n// Reusable regex\nconst pattern = sqlToRegex('%ing');\nconsole.log(['string', 'stringing'].every(s => pattern.test(s))); // true","lang":"typescript","description":"Shows both direct string matching with isSQLMatch and reusable regex with sqlToRegex, including wildcards and escaping."},"warnings":[{"fix":"Use import { ... } from 'sql-match' or update Node to >=12 (for ESM support) and switch to dynamic import.","message":"Version 2.0.0 switched to ESM-only; CommonJS require() throws ERR_REQUIRE_ESM.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Use String.raw to avoid interpretation: isSQLMatch(String.raw`\\t`, 't') returns true.","message":"JavaScript string interpretation can cause unexpected escape sequences. For example, isSQLMatch('\\t', 't') returns true because '\\t' is interpreted as tab character in non-raw string.","severity":"gotcha","affected_versions":"*"},{"fix":"Use String.raw`\\\\` to match a single backslash.","message":"Matching a literal backslash requires four backslashes in non-raw strings: '\\\\\\\\' matches single backslash.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"search_vec":"'2.0.0':17 'activ':64 'api':50,67 'backslash':23 'comparison':58 'compliant':7 'creation':62 'depend':35,48 'differenti':45 'direct':57 'escap':24 'esm':40 'esm-on':39 'extern':34 'function':53 'implement':8 'issqlmatch':54 'javascript':26,69 'lightweight':46 'like':11,31 'maintain':65 'match':3,13,25,70 'modul':42 'node.js':15 'pattern':12,32 'regex':61 'releas':36 'reusabl':60 'simpl':49 'sinc':43 'spec':6 'spec-compli':5 'sql':2,10,30,71 'sql-like':29 'sql-match':1 'sqltoregex':55 'stabl':68 'string':27 'support':19 'two':52 'v2.0.0':44 'version':16 'wildcard':21,72","created_at":"2026-06-05T17:02:06.486966+00:00","updated_at":"2026-06-05T17:02:06.486966+00:00","problems":[{"fix":"Replace require('sql-match') with import { isSQLMatch } from 'sql-match'.","cause":"Using require() on an ESM-only module (v2.0.0+).","error":"ERR_REQUIRE_ESM"},{"fix":"Use import { isSQLMatch } from 'sql-match' instead of import sqlMatch from 'sql-match'.","cause":"Default import does not exist; only named exports are available.","error":"TypeError: sqlMatch is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/stevenvachon/sql-match#readme","github":"https://github.com/stevenvachon/sql-match","docs":null,"changelog":null,"pypi":null,"npm":"sql-match","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}