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|$)"),
  );
}
