UNPKG

pg-mem

Version:

A memory version of postgres

66 lines 2.72 kB
import { Evaluator } from '../evaluator'; import { DataType, IValue, nil, Reg, _IType, _RelationBase, _Transaction } from '../interfaces-private'; export declare function regGen(typeId: number | null): Reg; export declare abstract class TypeBase<TRaw = any> implements _IType<TRaw>, _RelationBase { readonly reg: Reg; get type(): 'type'; /** * select a.oid, a.typname, b.typcategory from pg_catalog.pg_type a left join pg_catalog.pg_type b on b.oid = a.typelem */ constructor(typeId: number | null); private _asArray?; private _asList?; abstract primary: DataType; get name(): string; get primaryName(): string; /** Compute a custom unicty hash for a non null value */ doGetHash?(value: TRaw): string | number; /** Can be casted to */ doCanCast?(to: _IType<TRaw>): boolean | nil; /** Can be built to from (inverse of doCanCast()) */ doCanBuildFrom?(from: _IType): boolean | nil; /** * @see this.prefer() doc */ doPrefer?(type: _IType<TRaw>): _IType | null; /** * @see this.canConvertImplicit() doc */ doCanConvertImplicit?(to: _IType<TRaw>): boolean; /** Perform conversion from this type to given type */ doCast?(value: Evaluator<TRaw>, to: _IType<TRaw>): Evaluator<any> | nil; /** Perform conversion given type to this type (inverse of doCast()) */ doBuildFrom?(value: Evaluator, from: _IType): Evaluator<TRaw> | nil; doEquals(a: TRaw, b: TRaw): boolean; doGt(a: TRaw, b: TRaw): boolean; doLt(a: TRaw, b: TRaw): boolean; toString(): string; equals(a: TRaw, b: TRaw): boolean | null; gt(a: TRaw, b: TRaw): boolean | null; lt(a: TRaw, b: TRaw): boolean | null; ge(a: TRaw, b: TRaw): boolean | null; le(a: TRaw, b: TRaw): boolean | null; /** * When performing 'a+b', will be given 'b' type, * this returns the prefered resulting type, or null if they are not compatible */ prefer(to: _IType<TRaw>): _IType | nil; /** * Can constant literals be converted implicitely * (without a cast... i.e. you can use both values as different values of a case expression, for instance) **/ canConvertImplicit(to: _IType<TRaw>): boolean | nil; /** Can be explicitely casted to */ canCast(to: _IType<TRaw>): boolean | nil; /** Perform cast */ cast(_a: IValue<TRaw>, _to: _IType<any>): IValue; /** Perform implicit conversion */ convertImplicit(_a: IValue<TRaw>, _to: _IType<any>): IValue; private _convert; asArray(): _IType<TRaw[]>; asList(): _IType<TRaw[]>; hash(value: any): string | number | null; drop(t: _Transaction): void; } //# sourceMappingURL=datatype-base.d.ts.map