Comparing version 1.8.2 to 1.8.3
{ | ||
"name": "pg-mem", | ||
"version": "1.8.2", | ||
"version": "1.8.3", | ||
"description": "A memory version of postgres", | ||
@@ -47,3 +47,3 @@ "main": "index.js", | ||
"object-hash": "^2.0.3", | ||
"pgsql-ast-parser": "^6.2.1" | ||
"pgsql-ast-parser": "^7.0.2" | ||
}, | ||
@@ -50,0 +50,0 @@ "devDependencies": { |
@@ -17,3 +17,3 @@ | ||
<p align="center"> | ||
❤ It works both in node or in browser. | ||
❤ It works both in Node or in the browser. | ||
</p> | ||
@@ -42,4 +42,4 @@ | ||
## Using NodeJS | ||
As always, it stats with an: | ||
## Using Node.js | ||
As always, it starts with an: | ||
@@ -50,3 +50,3 @@ ```bash | ||
Then, assuming you're using something like Webpack if you're targetting a browser: | ||
Then, assuming you're using something like webpack, if you're targeting a browser: | ||
@@ -81,3 +81,3 @@ ```typescript | ||
This lib is quite new, so forgive it if some obivious pg syntax is not supported ! | ||
This lib is quite new, so forgive it if some obvious pg syntax is not supported ! | ||
@@ -97,8 +97,9 @@ ... And open an issue if you feel like a feature should be implemented :) | ||
`pg-mem` uses immutable data structures ([here](https://www.npmjs.com/package/immutable) and [here](https://www.npmjs.com/package/functional-red-black-tree)), | ||
which means that you can have restore points for free ! | ||
which means that you can have restore points for free! | ||
This is super useful if you indend to use `pg-mem` to mock your database for unit tests. | ||
This is super useful if you intend to use `pg-mem` to mock your database for unit tests. | ||
You could: | ||
1) Create your schema only once (which could be an heavy operation for a single unit test) | ||
1) Create your schema only once (which could be a heavy operation for a single unit test) | ||
2) Insert test data which will be shared by all test | ||
@@ -139,3 +140,3 @@ 2) Create a restore point | ||
⚠ However, the value you return is not type checked. It MUST correspond to the datatype you provided as 'returns' (wont fail if not, but could lead to weird bugs). | ||
⚠ However, the value you return is not type checked. It MUST correspond to the datatype you provided as 'returns' (it won't fail if not, but could lead to weird bugs). | ||
@@ -155,3 +156,3 @@ | ||
name: 'macaddr', | ||
// which type is it equilalent to (will be able to cast it from it) | ||
// which type is it equivalent to (will be able to cast it from it) | ||
equivalentTo: DataType.text, | ||
@@ -190,3 +191,3 @@ isValid(val: string) { | ||
pg-mem provides handy shortcuts to create instances of popuplar libraries that will be bound to pg-mem instead of a real postgres db. | ||
pg-mem provides handy shortcuts to create instances of popular libraries that will be bound to pg-mem instead of a real postgres db. | ||
@@ -247,3 +248,3 @@ - pg-native | ||
```typescript | ||
// called when a table is iterated entierly (ex: 'select * from data where notIndex=3' triggers it) | ||
// called when a table is iterated entirely (ex: 'select * from data where notIndex=3' triggers it) | ||
db.on('seq-scan', () => {}); | ||
@@ -276,6 +277,6 @@ | ||
To start hacking this lib, you'll have to: | ||
- Use vscode | ||
- Use VS Code | ||
- Install [mocha test explorer with HMR support](https://marketplace.visualstudio.com/items?itemName=oguimbal.vscode-mocha-test-adapter) extension | ||
- `npm start` | ||
- Reload unit tests in vscode | ||
- Reload unit tests in VS Code | ||
@@ -285,4 +286,4 @@ ... once done, tests should appear. HMR is on, which means that changes in your code are instantly propagated to unit tests. | ||
To debug tests: Just hit "run" (F5, or whatever)... vscode should attach the mocha worker. Then run the test you want to debug. | ||
To debug tests: Just hit "run" (F5, or whatever)... VS Code should attach the mocha worker. Then run the test you want to debug. | ||
Alternatively, you could just run `npm run test` wihtout installing anything, but this is a bit long. | ||
Alternatively, you could just run `npm run test` without installing anything, but this is a bit long. |
import { _ISelection, IValue } from './interfaces-private'; | ||
import { nil } from './interfaces'; | ||
import { Expr } from 'pgsql-ast-parser'; | ||
import { Expr, BinaryOperator } from 'pgsql-ast-parser'; | ||
export declare function buildValue(data: _ISelection, val: Expr): IValue; | ||
export declare function uncache(data: _ISelection): void; | ||
export declare function buildBinaryValue(data: _ISelection, leftValue: IValue, op: BinaryOperator, rightValue: IValue): IValue; | ||
export declare function sqlSubstring(value: string, from?: number, len?: number | nil): string | null; | ||
//# sourceMappingURL=expression-builder.d.ts.map |
@@ -169,4 +169,4 @@ import { IMemoryDb, IMemoryTable, DataType, IType, TableEvent, GlobalEvent, ISchema, SchemaField, MemoryDbOptions, nil, Schema, ISubscription, LanguageCompiler, ArgDefDetails } from './interfaces'; | ||
_: 'limit'; | ||
take?: number; | ||
skip?: number; | ||
take?: _ExprExplanation; | ||
skip?: _ExprExplanation; | ||
on: _SelectExplanation; | ||
@@ -173,0 +173,0 @@ } | { |
import { IMigrate } from './migrate/migrate-interfaces'; | ||
import { TableConstraint, CreateColumnDef, StatementLocation, DataTypeDef, FunctionArgumentMode } from 'pgsql-ast-parser'; | ||
import { TableConstraint, CreateColumnDef, NodeLocation, DataTypeDef, FunctionArgumentMode } from 'pgsql-ast-parser'; | ||
export declare type nil = undefined | null; | ||
@@ -252,3 +252,3 @@ export declare type Schema = { | ||
/** Location of the last ";" prior to this statement */ | ||
location: StatementLocation; | ||
location: NodeLocation; | ||
} | ||
@@ -255,0 +255,0 @@ export interface FieldInfo { |
import { TransformBase } from './transform-base'; | ||
import { _ISelection, _Transaction, IValue, _IIndex, _Explainer, _SelectExplanation, Stats } from '../interfaces-private'; | ||
import { SelectedColumn, Expr, ExprRef } from 'pgsql-ast-parser'; | ||
import { SelectedColumn, Expr, ExprRef, ExprCall } from 'pgsql-ast-parser'; | ||
import { nil } from '../interfaces'; | ||
@@ -31,3 +31,3 @@ export declare const aggregationFunctions: Set<string>; | ||
getColumn(column: string | ExprRef, nullIfNotFound?: boolean): IValue | nil; | ||
getAggregation(name: string, args: Expr[]): IValue; | ||
getAggregation(name: string, call: ExprCall): IValue; | ||
private _getAggregation; | ||
@@ -34,0 +34,0 @@ hasItem(value: T, t: _Transaction): boolean; |
import { AggregationComputer, AggregationGroupComputer, IndexKey, IValue, _IIndex, _ISelection, _IType, _Transaction } from '../../interfaces-private'; | ||
import { Expr } from 'pgsql-ast-parser'; | ||
export declare function buildCount(this: void, base: _ISelection, args: Expr[]): CountStar | CountDistinct | CountExpr; | ||
import { ExprCall } from 'pgsql-ast-parser'; | ||
export declare function buildCount(this: void, base: _ISelection, call: ExprCall): CountStar | CountDistinct | CountExpr; | ||
declare class CountStar implements AggregationComputer<number> { | ||
@@ -5,0 +5,0 @@ private on; |
import { AggregationComputer, AggregationGroupComputer, IValue, _ISelection, _IType, _Transaction } from '../../interfaces-private'; | ||
import { Expr } from 'pgsql-ast-parser'; | ||
import { ExprCall } from 'pgsql-ast-parser'; | ||
declare class SumExpr implements AggregationComputer<number> { | ||
@@ -15,4 +15,4 @@ private exp; | ||
} | ||
export declare function buildSum(this: void, base: _ISelection, args: Expr[]): SumExpr | SumDistinct; | ||
export declare function buildSum(this: void, base: _ISelection, call: ExprCall): SumExpr | SumDistinct; | ||
export {}; | ||
//# sourceMappingURL=sum.d.ts.map |
import { _ISelection, IValue, _IIndex, _Transaction, _ISchema, _SelectExplanation, _Explainer, IndexExpression, IndexOp, IndexKey, _IndexExplanation, Stats, _IAlias } from '../interfaces-private'; | ||
import { nil } from '../interfaces'; | ||
import { DataSourceBase } from './transform-base'; | ||
import { Expr, ExprRef } from 'pgsql-ast-parser'; | ||
import { ExprRef, JoinClause } from 'pgsql-ast-parser'; | ||
interface JoinRaw<TLeft, TRight> { | ||
@@ -28,9 +28,13 @@ '>restrictive': TLeft; | ||
private building; | ||
private ignoreDupes?; | ||
isOriginOf(a: IValue<any>): boolean; | ||
get columns(): IValue<any>[]; | ||
entropy(t: _Transaction): number; | ||
constructor(db: _ISchema, restrictive: _ISelection<TLeft>, joined: _ISelection<TRight>, on: Expr, innerJoin: boolean); | ||
constructor(db: _ISchema, restrictive: _ISelection<TLeft>, joined: _ISelection<TRight>, on: JoinClause, innerJoin: boolean); | ||
private wrap; | ||
listSelectableIdentities(): Iterable<IValue>; | ||
private fetchStrategies; | ||
private fetchEqStrategy; | ||
private fetchOnStrategies; | ||
private fetchUsingStrategies; | ||
private fetchAndStrategies; | ||
private fetchEqStrategyOn; | ||
getColumn(column: string | ExprRef): IValue; | ||
@@ -37,0 +41,0 @@ getColumn(column: string | ExprRef, nullIfNotFound?: boolean): IValue | nil; |
@@ -1,2 +0,2 @@ | ||
import { _ISelection, _Transaction, _Explainer, _SelectExplanation, Stats } from '../interfaces-private'; | ||
import { IValue, _ISelection, _Transaction, _Explainer, _SelectExplanation, Stats, nil } from '../interfaces-private'; | ||
import { FilterBase } from './transform-base'; | ||
@@ -12,3 +12,3 @@ import { LimitStatement } from 'pgsql-ast-parser'; | ||
hasItem(raw: T, t: _Transaction): boolean; | ||
constructor(selection: _ISelection<T>, take: number, skip: number); | ||
constructor(selection: _ISelection<T>, take: IValue | nil, skip: IValue | nil); | ||
stats(t: _Transaction): Stats | null; | ||
@@ -15,0 +15,0 @@ enumerate(t: _Transaction): Iterable<T>; |
@@ -5,5 +5,10 @@ import { _ISelection, _IIndex, IValue, _IType, _Transaction, _Explainer, _SelectExplanation, IndexKey, _IndexExplanation, IndexExpression, IndexOp, Stats } from '../interfaces-private'; | ||
import { TransformBase } from './transform-base'; | ||
import { SelectedColumn, ExprRef } from 'pgsql-ast-parser'; | ||
import { SelectedColumn, Expr, ExprRef } from 'pgsql-ast-parser'; | ||
export declare function buildSelection(on: _ISelection, select: SelectedColumn[] | nil): _ISelection<any> | import("./aggregation").Aggregation<unknown> | Selection<unknown>; | ||
export declare function columnEvaluator(this: void, on: _ISelection, id: string, type: _IType): Evaluator<any>; | ||
export interface CustomAlias { | ||
val: IValue; | ||
as?: string; | ||
expr?: Expr; | ||
} | ||
export declare class Selection<T> extends TransformBase<T> implements _ISelection<T> { | ||
@@ -17,3 +22,3 @@ private columnIds; | ||
readonly columns: IValue[]; | ||
constructor(base: _ISelection<any>, _columns: SelectedColumn[]); | ||
constructor(base: _ISelection<any>, _columns: (SelectedColumn | CustomAlias)[]); | ||
private refColumn; | ||
@@ -20,0 +25,0 @@ stats(t: _Transaction): Stats | null; |
@@ -12,2 +12,3 @@ import moment from 'moment'; | ||
}; | ||
export declare type SRecord<T> = Record<string, T>; | ||
export declare function trimNullish<T>(value: T, depth?: number): T; | ||
@@ -24,3 +25,2 @@ export declare function watchUse<T>(rootValue: T): { | ||
export declare function queryJson(a: Json, b: Json): boolean; | ||
export declare function buildColumnIds(suggestedIds: string[]): string[]; | ||
export declare function buildLikeMatcher(likeCondition: string, caseSensitive?: boolean): (stringToMatch: string | number) => boolean | null; | ||
@@ -27,0 +27,0 @@ export declare function nullIsh(v: any): boolean; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
1317930
13899
279
+ Addedpgsql-ast-parser@7.2.1(transitive)
- Removedpgsql-ast-parser@6.3.2(transitive)
Updatedpgsql-ast-parser@^7.0.2