From 30bde57e67ddcac8f8279b8ad34aa85f4fe5673a Mon Sep 17 00:00:00 2001 From: Kyriakos Barbounakis Date: Fri, 5 Apr 2024 08:45:46 +0300 Subject: [PATCH] add object name validator as property (#84) * add object name validator as property * 2.11.3 --- package-lock.json | 4 ++-- package.json | 2 +- src/formatter.d.ts | 2 ++ src/formatter.js | 10 +++++++++- src/index.d.ts | 1 + 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index ca45ad0..b5ddb6e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@themost/query", - "version": "2.11.2", + "version": "2.11.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@themost/query", - "version": "2.11.2", + "version": "2.11.3", "license": "BSD-3-Clause", "dependencies": { "@themost/events": "^1.0.5", diff --git a/package.json b/package.json index 94fe7e5..554e800 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@themost/query", - "version": "2.11.2", + "version": "2.11.3", "description": "MOST Web Framework Codename ZeroGravity - Query Module", "main": "dist/index.cjs.js", "module": "dist/index.esm.js", diff --git a/src/formatter.d.ts b/src/formatter.d.ts index 2e8c349..ea1bb81 100644 --- a/src/formatter.d.ts +++ b/src/formatter.d.ts @@ -1,4 +1,5 @@ // MOST Web Framework Codename Zero Gravity Copyright (c) 2017-2022, THEMOST LP All rights reserved +import { ObjectNameValidator } from './object-name.validator'; import {QueryExpression, QueryField, QueryValueRef} from "./query"; export declare interface FormatterSettings { @@ -10,6 +11,7 @@ export declare interface FormatterSettings { export declare class SqlFormatter { provider: any; settings: FormatterSettings; + get validator(): ObjectNameValidator; escape(value: any,unquoted?: boolean): string | any; escapeConstant(value: any,unquoted?: boolean): string | any; diff --git a/src/formatter.js b/src/formatter.js index ca70d29..5560816 100644 --- a/src/formatter.js +++ b/src/formatter.js @@ -986,8 +986,16 @@ class SqlFormatter { if (isNameReference(str)) { str = trimNameReference(name); } - return ObjectNameValidator.validator.escape(str, this.settings.nameFormat); + return this.validator.escape(str, this.settings.nameFormat); } + + /** + * @returns {ObjectNameValidator} + */ + get validator() { + return ObjectNameValidator.validator; + } + /** * @param obj {QueryField} * @param format {string} diff --git a/src/index.d.ts b/src/index.d.ts index 4882b6a..adb4f93 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -10,6 +10,7 @@ export * from './closures/PrototypeMethodParser'; export * from './closures/MathMethodParser'; export * from './closures/DateMethodParser'; export * from './closures/StringMethodParser'; +export * from './object-name.validator'; export * from './open-data-query.expression'; export * from './open-data-query.formatter';