@clickup/pg-microsharding
Version:
Microshards support for PostgreSQL
13 lines (11 loc) • 356 B
text/typescript
import escapeRegExp from "lodash/escapeRegExp";
import { ident } from "./quote";
/**
* Returns true if an SQL clause includes a properly quoted identifier (like
* index name).
*/
export function isNameInSql(name: string, sql: string): boolean {
return !!sql.match(
new RegExp("(\\W|^)" + escapeRegExp(ident(name).toString()) + "(\\W|$)"),
);
}