@sqb/builder 5.0.6 → 5.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/enums.d.ts CHANGED
@@ -72,7 +72,8 @@ export declare enum OperatorType {
72
72
  isNot = "isNot",
73
73
  exists = "exists",
74
74
  notExists = "notExists",
75
- not = "not"
75
+ not = "not",
76
+ match = "match"
76
77
  }
77
78
  export declare enum DataType {
78
79
  BOOL = "BOOL",
package/enums.js CHANGED
@@ -76,6 +76,7 @@ export var OperatorType;
76
76
  OperatorType["exists"] = "exists";
77
77
  OperatorType["notExists"] = "notExists";
78
78
  OperatorType["not"] = "not";
79
+ OperatorType["match"] = "match";
79
80
  })(OperatorType || (OperatorType = {}));
80
81
  export var DataType;
81
82
  (function (DataType) {
package/op.ns.d.ts CHANGED
@@ -11,6 +11,7 @@ import { IsNot } from './sql/operators/is-not.js';
11
11
  import { Like } from './sql/operators/like.js';
12
12
  import { Lt } from './sql/operators/lt.js';
13
13
  import { Lte } from './sql/operators/lte.js';
14
+ import { Match } from './sql/operators/match.js';
14
15
  import { Ne } from './sql/operators/ne.js';
15
16
  import { Not } from './sql/operators/not.js';
16
17
  import { NotBetween } from './sql/operators/not-between.js';
@@ -59,6 +60,7 @@ export interface OperatorsMap {
59
60
  exists: typeof Exists;
60
61
  notExists: typeof NotExists;
61
62
  '!exists': typeof NotExists;
63
+ match: typeof Match;
62
64
  }
63
65
  declare const Operators: OperatorsMap;
64
66
  export { Operators };
package/op.ns.js CHANGED
@@ -12,6 +12,7 @@ import { IsNot } from './sql/operators/is-not.js';
12
12
  import { Like } from './sql/operators/like.js';
13
13
  import { Lt } from './sql/operators/lt.js';
14
14
  import { Lte } from './sql/operators/lte.js';
15
+ import { Match } from './sql/operators/match.js';
15
16
  import { Ne } from './sql/operators/ne.js';
16
17
  import { Not } from './sql/operators/not.js';
17
18
  import { NotBetween } from './sql/operators/not-between.js';
@@ -60,6 +61,7 @@ const Operators = {
60
61
  exists: Exists,
61
62
  notExists: NotExists,
62
63
  '!exists': NotExists,
64
+ match: Match,
63
65
  };
64
66
  LogicalOperator.Operators = Operators;
65
67
  export { Operators };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sqb/builder",
3
3
  "description": "Extensible multi-dialect SQL query builder written with TypeScript",
4
- "version": "5.0.6",
4
+ "version": "5.0.7",
5
5
  "author": "Panates",
6
6
  "license": "Apache-2.0",
7
7
  "dependencies": {
@@ -13,6 +13,7 @@ export * from './like.js';
13
13
  export * from './logical-operator.js';
14
14
  export * from './lt.js';
15
15
  export * from './lte.js';
16
+ export * from './match.js';
16
17
  export * from './ne.js';
17
18
  export * from './not.js';
18
19
  export * from './not-between.js';
@@ -13,6 +13,7 @@ export * from './like.js';
13
13
  export * from './logical-operator.js';
14
14
  export * from './lt.js';
15
15
  export * from './lte.js';
16
+ export * from './match.js';
16
17
  export * from './ne.js';
17
18
  export * from './not.js';
18
19
  export * from './not-between.js';
@@ -0,0 +1,16 @@
1
+ import { SqlElement } from '../../serializable.js';
2
+ import { SerializeContext } from '../../serialize-context.js';
3
+ import { CompOperator } from './comp-operator.js';
4
+ declare class MatchClass extends CompOperator {
5
+ customArgs?: any;
6
+ __serialize(ctx: SerializeContext, o: any): string;
7
+ }
8
+ interface MatchCtor {
9
+ new (left: string | SqlElement, right?: string | SqlElement, customArgs?: any): Match;
10
+ (left: string | SqlElement, right?: string | SqlElement, customArgs?: any): Match;
11
+ prototype: Match;
12
+ }
13
+ export declare const Match: MatchCtor;
14
+ export interface Match extends MatchClass {
15
+ }
16
+ export {};
@@ -0,0 +1,32 @@
1
+ import { OperatorType } from '../../enums.js';
2
+ import { SqlElement } from '../../serializable.js';
3
+ import { SerializeContext } from '../../serialize-context.js';
4
+ import { CompOperator } from './comp-operator.js';
5
+ class MatchClass extends CompOperator {
6
+ customArgs;
7
+ __serialize(ctx, o) {
8
+ if (!o.right.expression)
9
+ return '';
10
+ if (o.right && typeof o.right.expression !== 'string')
11
+ o.right.expression = String(o.right.expression);
12
+ o.customArgs = this.customArgs;
13
+ return ctx.serialize(this._type, o, (_ctx, _o) => this.__defaultSerialize(_ctx, _o));
14
+ }
15
+ }
16
+ export const Match = function (left, right, customArgs) {
17
+ if (!(this instanceof Match))
18
+ return new Match(left, right, customArgs);
19
+ CompOperator.call(this, left, right);
20
+ this._operatorType = OperatorType.match;
21
+ this._symbol = '=';
22
+ this.customArgs = customArgs;
23
+ if (typeof left === 'string') {
24
+ const m = left.match(/^([\w\\.$]+)(\[])?/);
25
+ if (!m)
26
+ throw new TypeError(`"${left}" is not a valid expression definition`);
27
+ this._left = m[1];
28
+ this._isArray = !!m[2];
29
+ }
30
+ };
31
+ Match.prototype = MatchClass.prototype;
32
+ Match.prototype.constructor = Match;