@warlock.js/cascade 5.15.0 → 5.17.0
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/CHANGELOG.md +261 -254
- package/cjs/index.cjs +131 -30
- package/cjs/index.cjs.map +1 -1
- package/esm/drivers/mongodb/mongodb-query-builder.d.mts.map +1 -1
- package/esm/drivers/mongodb/mongodb-query-builder.mjs +12 -6
- package/esm/drivers/mongodb/mongodb-query-builder.mjs.map +1 -1
- package/esm/drivers/postgres/postgres-driver.d.mts.map +1 -1
- package/esm/drivers/postgres/postgres-driver.mjs +36 -10
- package/esm/drivers/postgres/postgres-driver.mjs.map +1 -1
- package/esm/drivers/postgres/types.d.mts +12 -2
- package/esm/drivers/postgres/types.d.mts.map +1 -1
- package/esm/errors/undefined-where-value.error.d.mts +32 -0
- package/esm/errors/undefined-where-value.error.d.mts.map +1 -0
- package/esm/errors/undefined-where-value.error.mjs +38 -0
- package/esm/errors/undefined-where-value.error.mjs.map +1 -0
- package/esm/index.d.mts +3 -2
- package/esm/index.mjs +3 -2
- package/esm/query-builder/query-builder.d.mts.map +1 -1
- package/esm/query-builder/query-builder.mjs +23 -11
- package/esm/query-builder/query-builder.mjs.map +1 -1
- package/esm/utils/sanitize-filter.d.mts +21 -6
- package/esm/utils/sanitize-filter.d.mts.map +1 -1
- package/esm/utils/sanitize-filter.mjs +26 -6
- package/esm/utils/sanitize-filter.mjs.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
//#region ../cascade/src/errors/undefined-where-value.error.ts
|
|
2
|
+
/**
|
|
3
|
+
* Error thrown when a `where()`-family call is given `undefined` as the
|
|
4
|
+
* bound value.
|
|
5
|
+
*
|
|
6
|
+
* A bound `undefined` reaches SQL drivers as `= NULL`, which never matches
|
|
7
|
+
* any row (SQL's three-valued logic — `NULL = NULL` is `NULL`, not `true`) —
|
|
8
|
+
* and reaches the MongoDB driver as a filter that matches every document
|
|
9
|
+
* missing the field. Either way the query silently returns the wrong rows
|
|
10
|
+
* instead of failing loudly, which usually means the caller forgot to guard
|
|
11
|
+
* an id/value that turned out to be missing (e.g. `User.find(post.authorId)`
|
|
12
|
+
* when `authorId` came back `undefined`).
|
|
13
|
+
*
|
|
14
|
+
* To match `NULL` explicitly, pass `null` — `where("deletedAt", null)` is a
|
|
15
|
+
* valid, intentional query. To skip the query entirely when there's no
|
|
16
|
+
* value, guard the call site instead of calling `where()`.
|
|
17
|
+
*/
|
|
18
|
+
var UndefinedWhereValueError = class UndefinedWhereValueError extends Error {
|
|
19
|
+
/**
|
|
20
|
+
* The field whose value was `undefined`.
|
|
21
|
+
*/
|
|
22
|
+
field;
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new UndefinedWhereValueError.
|
|
25
|
+
*
|
|
26
|
+
* @param field - The field name whose value was rejected
|
|
27
|
+
*/
|
|
28
|
+
constructor(field) {
|
|
29
|
+
super(`where("${field}", undefined) — a bound "undefined" value silently becomes a NULL comparison that never matches, hiding the real bug. Pass null to match NULL explicitly, or skip the query when there's no value for "${field}".`);
|
|
30
|
+
this.name = "UndefinedWhereValueError";
|
|
31
|
+
this.field = field;
|
|
32
|
+
if (Error.captureStackTrace) Error.captureStackTrace(this, UndefinedWhereValueError);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { UndefinedWhereValueError };
|
|
38
|
+
//# sourceMappingURL=undefined-where-value.error.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"undefined-where-value.error.mjs","names":[],"sources":["../../../../../../../cascade/src/errors/undefined-where-value.error.ts"],"sourcesContent":["/**\n * Error thrown when a `where()`-family call is given `undefined` as the\n * bound value.\n *\n * A bound `undefined` reaches SQL drivers as `= NULL`, which never matches\n * any row (SQL's three-valued logic — `NULL = NULL` is `NULL`, not `true`) —\n * and reaches the MongoDB driver as a filter that matches every document\n * missing the field. Either way the query silently returns the wrong rows\n * instead of failing loudly, which usually means the caller forgot to guard\n * an id/value that turned out to be missing (e.g. `User.find(post.authorId)`\n * when `authorId` came back `undefined`).\n *\n * To match `NULL` explicitly, pass `null` — `where(\"deletedAt\", null)` is a\n * valid, intentional query. To skip the query entirely when there's no\n * value, guard the call site instead of calling `where()`.\n */\nexport class UndefinedWhereValueError extends Error {\n /**\n * The field whose value was `undefined`.\n */\n public readonly field: string;\n\n /**\n * Creates a new UndefinedWhereValueError.\n *\n * @param field - The field name whose value was rejected\n */\n public constructor(field: string) {\n super(\n `where(\"${field}\", undefined) — a bound \"undefined\" value silently becomes a NULL ` +\n `comparison that never matches, hiding the real bug. Pass null to match NULL ` +\n `explicitly, or skip the query when there's no value for \"${field}\".`,\n );\n this.name = \"UndefinedWhereValueError\";\n this.field = field;\n\n // Maintains proper stack trace for where error was thrown (V8 only)\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, UndefinedWhereValueError);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgBA,IAAa,2BAAb,MAAa,iCAAiC,MAAM;;;;CAIlD,AAAgB;;;;;;CAOhB,AAAO,YAAY,OAAe;EAChC,MACE,UAAU,MAAM,yMAE8C,MAAM,GACtE;EACA,KAAK,OAAO;EACZ,KAAK,QAAQ;EAGb,IAAI,MAAM,mBACR,MAAM,kBAAkB,MAAM,wBAAwB;CAE1D;AACF"}
|
package/esm/index.d.mts
CHANGED
|
@@ -27,6 +27,7 @@ import { databaseTransactionContext } from "./context/database-transaction-conte
|
|
|
27
27
|
import { DataSourceRegistryEvent, DataSourceRegistryListener, dataSourceRegistry } from "./data-source/data-source-registry.mjs";
|
|
28
28
|
import { MissingDataSourceError } from "./errors/missing-data-source.error.mjs";
|
|
29
29
|
import { TransactionRollbackError } from "./errors/transaction-rollback.error.mjs";
|
|
30
|
+
import { UndefinedWhereValueError } from "./errors/undefined-where-value.error.mjs";
|
|
30
31
|
import { UnsafeFilterError } from "./errors/unsafe-filter.error.mjs";
|
|
31
32
|
import { UnsafeRawExpressionError } from "./errors/unsafe-raw-expression.error.mjs";
|
|
32
33
|
import { UnsupportedLeanOperationError } from "./errors/unsupported-lean-operation.error.mjs";
|
|
@@ -52,7 +53,7 @@ import { ModelSyncOperation } from "./sync/model-sync-operation.mjs";
|
|
|
52
53
|
import { DEFAULT_MAX_SYNC_DEPTH, SyncContextManager } from "./sync/sync-context.mjs";
|
|
53
54
|
import { SyncManager } from "./sync/sync-manager.mjs";
|
|
54
55
|
import { escapeRegex, likePatternToRegexSource, resolveLikePattern } from "./utils/escape-regex.mjs";
|
|
55
|
-
import { sanitizeFilter, sanitizeFilterValue } from "./utils/sanitize-filter.mjs";
|
|
56
|
+
import { assertDefined, sanitizeFilter, sanitizeFilterValue } from "./utils/sanitize-filter.mjs";
|
|
56
57
|
import { ModelTransformCallback, useModelTransformer } from "./utils/database-writer.utils.mjs";
|
|
57
58
|
import { DefineModelOptions, ModelType, defineModel } from "./utils/define-model.mjs";
|
|
58
59
|
import { onceConnected, onceDisconnected } from "./utils/once-connected.mjs";
|
|
@@ -72,6 +73,6 @@ import { PostgresQueryBuilder } from "./drivers/postgres/postgres-query-builder.
|
|
|
72
73
|
import { PostgresOperationType, PostgresParserOperation, PostgresParserOptions, PostgresQueryParser } from "./drivers/postgres/postgres-query-parser.mjs";
|
|
73
74
|
import { PostgresSyncAdapter } from "./drivers/postgres/postgres-sync-adapter.mjs";
|
|
74
75
|
import { MongoClientOptions, TransactionOptions } from "mongodb";
|
|
75
|
-
export { $agg, $expr, AggregateExpression, AggregateFunction, AlterSchema, ArithmeticExpression, AtomicUpdate, AtomicUpdateOptions, type BaseQueryRuleOptions, type BaseUniqueRuleOptions, BelongsTo, BelongsToMany, type BelongsToManyOptions, type BelongsToOptions, BuildUpdateOperationsResult, type ChildModel, ChunkCallback, ColumnBuilder, ColumnDefinition, ColumnExpression, ColumnExpressionInput, ColumnExpressionType, ColumnMap, ColumnRefExpression, ColumnType, ConnectionOptions, CreateDatabaseOptions, CreateDatabaseResult, CursorPaginationOptions, CursorPaginationResult, DEFAULT_MAX_SYNC_DEPTH, DataSource, DataSourceOptions, DataSourceRegistryEvent, DataSourceRegistryListener, DatabaseDirtyTracker, DatabaseDriver, DatabaseRemover, DatabaseRestorer, DatabaseWriter, DatabaseWriterValidationError, DefineModelOptions, DeleteStrategy, DetachedColumnBuilder, DriverAtomicUpdateOptions, DriverContract, DriverEvent, DriverEventListener, DriverQuery, DriverTransactionContract, DropAllTablesResult, DropDatabaseOptions, type EmbedKey, type ExistsRuleOptions, ExportMigrationsSQLOptions, FindOneAndUpdateOptions, ForeignKeyBuilder, ForeignKeyDefinition, FullTextIndexOptions, GenerateIdOptions, GeoIndexOptions, type GlobalScopeDefinition, type GlobalScopeOptions, GroupByInput, HasMany, type HasManyOptions, HasOne, type HasOneOptions, HavingInput, IdGeneratorContract, IndexDefinition, IndexEntry, InsertResult, JoinOptions, LeanDocument, LiteralExpression, type LoadedRelationResult, type LoadedRelationsMap, type LocalScopeCallback, LockForUpdateOptions, Migration, MigrationAlterOptions, MigrationConstructor, MigrationContract, MigrationCreateOptions, MigrationDefaults, MigrationDriverContract, MigrationDriverFactory, type MigrationRecord, type MigrationResult, MigrationRunner, type MigrationRunnerOptions, type MigrationStatus, MissingDataSourceError, Model, ModelDefaultConfig, ModelDefaults, ModelEventListener, ModelEventName, ModelEvents, ModelRef, type ModelSchema, type ModelSnapshot, type ModelSyncConfig, type ModelSyncContract, ModelSyncOperation, type ModelSyncOperationContract, ModelTransformCallback, ModelType, type MongoClientOptions, MongoDbDriver, MongoDriverOptions, MongoIdGenerator, MongoMigrationDriver, MongoQueryBuilder, MongoSyncAdapter, NamingConvention, OnDeletedEventContext, Operation, OperationType, OrderDirection, PaginationOptions, PaginationResult, PendingMigration, PendingOperation, PipelineStage, type PivotData, type PivotIds, PivotOperations, PostgresBlueprint, PostgresConnectionConfig, PostgresCopyOptions, PostgresDialect, PostgresDriver, PostgresIsolationLevel, PostgresMigrationDriver, PostgresNotification, PostgresOperation, PostgresOperationType, PostgresParserOperation, PostgresParserOptions, PostgresPoolConfig, PostgresQueryBuilder, PostgresQueryParser, PostgresQueryResult, PostgresSyncAdapter, PostgresTransactionOptions, PostgresWhereClause, QueryBuilderContract, RELATION_METADATA_KEY, RawColumnExpression, RawExpression, RawQueryResult, RegisterModel, RegisterModelOptions, type RelationConstraintCallback, type RelationConstraints, RelationDefaults, type RelationDefinition, type RelationDefinitions, RelationHydrator, RelationLoader, type RelationType, RemoverContract, RemoverOptions, RemoverResult, RestorerContract, RestorerOptions, RestorerResult, RollbackMigrationsOptions, type RollbackOptions, type RunMigrationsOptions, type ScopeTiming, type SerializedRelation, SqlAggregateFunction, SqlDeleteOperation, SqlDialectContract, SqlGroupClause, SqlHavingClause, SqlInsertOperation, SqlJoinClause, SqlJoinType, SqlOrderClause, SqlQueryConfig, SqlQueryResult, SqlSelectClause, SqlUpdateOperation, SqlWhereOperation, SqlWhereType, StrictMode, SyncAdapterContract, type SyncConfig, type SyncContext, SyncContextManager, type SyncEventPayload, SyncInstruction, type SyncInstructionOptions, SyncManager, type SyncResult, type TableIndexInformation, TransactionContext, type TransactionOptions, TransactionRollbackError, UniqueEntry, type UniqueRuleOptions, UnsafeFilterError, UnsafeRawExpressionError, UnsupportedLeanOperationError, UnsupportedQueryOperationError, UnsupportedUpdateOperationError, UnwindOptions, UpdateOperations, UpdatePipeline, UpdateResult, UuidStrategy, VectorIndexOptions, WhereCallback, WhereObject, WhereOperator, WriterContract, WriterOptions, WriterResult, arrayBigInt, arrayBoolean, arrayDate, arrayDecimal, arrayFloat, arrayInt, arrayJson, arrayText, arrayTimestamp, arrayUuid, bigInt, bigInteger, binary, blobCol, boolCol as bool, boolCol, buildPostgresPoolConfig, char, cleanupModelsRegistery, connectToDatabase, createDatabase, createPivotOperations, dataSourceRegistry, databaseDataSourceContext, databaseTransactionContext, date, dateTime, decimal, defineModel, double, dropAllTables, enumCol, escapeRegex, exportMigrationsSQL, float, freshMigrate, geometry, getAllModelsFromRegistry, getDatabaseDriver, getModelFromRegistry, globalModelEvents, int, integer, ipAddress, isAggregateExpression, isColumnExpression, isMongoDBDriverLoaded, json, likePatternToRegexSource, lineString, listExecutedMigrations, listPendingMigrations, longText, macAddress, mediumText, migrate, migrationRunner, modelSync, objectCol, onceConnected, onceDisconnected, point, polygon, registerModelInRegistry, removeModelFromRegistery, resolveLikePattern, resolveModelClass, resolveModelName, rollbackMigrations, runMigrations, sanitizeFilter, sanitizeFilterValue, setCol, smallInt, smallInteger, string, text, time, timestamp, tinyInt, tinyInteger, toColumnExpression, transaction, tryResolveModelClass, ulid, useModelTransformer, uuid, vector, verifyRegisteredRelations, year };
|
|
76
|
+
export { $agg, $expr, AggregateExpression, AggregateFunction, AlterSchema, ArithmeticExpression, AtomicUpdate, AtomicUpdateOptions, type BaseQueryRuleOptions, type BaseUniqueRuleOptions, BelongsTo, BelongsToMany, type BelongsToManyOptions, type BelongsToOptions, BuildUpdateOperationsResult, type ChildModel, ChunkCallback, ColumnBuilder, ColumnDefinition, ColumnExpression, ColumnExpressionInput, ColumnExpressionType, ColumnMap, ColumnRefExpression, ColumnType, ConnectionOptions, CreateDatabaseOptions, CreateDatabaseResult, CursorPaginationOptions, CursorPaginationResult, DEFAULT_MAX_SYNC_DEPTH, DataSource, DataSourceOptions, DataSourceRegistryEvent, DataSourceRegistryListener, DatabaseDirtyTracker, DatabaseDriver, DatabaseRemover, DatabaseRestorer, DatabaseWriter, DatabaseWriterValidationError, DefineModelOptions, DeleteStrategy, DetachedColumnBuilder, DriverAtomicUpdateOptions, DriverContract, DriverEvent, DriverEventListener, DriverQuery, DriverTransactionContract, DropAllTablesResult, DropDatabaseOptions, type EmbedKey, type ExistsRuleOptions, ExportMigrationsSQLOptions, FindOneAndUpdateOptions, ForeignKeyBuilder, ForeignKeyDefinition, FullTextIndexOptions, GenerateIdOptions, GeoIndexOptions, type GlobalScopeDefinition, type GlobalScopeOptions, GroupByInput, HasMany, type HasManyOptions, HasOne, type HasOneOptions, HavingInput, IdGeneratorContract, IndexDefinition, IndexEntry, InsertResult, JoinOptions, LeanDocument, LiteralExpression, type LoadedRelationResult, type LoadedRelationsMap, type LocalScopeCallback, LockForUpdateOptions, Migration, MigrationAlterOptions, MigrationConstructor, MigrationContract, MigrationCreateOptions, MigrationDefaults, MigrationDriverContract, MigrationDriverFactory, type MigrationRecord, type MigrationResult, MigrationRunner, type MigrationRunnerOptions, type MigrationStatus, MissingDataSourceError, Model, ModelDefaultConfig, ModelDefaults, ModelEventListener, ModelEventName, ModelEvents, ModelRef, type ModelSchema, type ModelSnapshot, type ModelSyncConfig, type ModelSyncContract, ModelSyncOperation, type ModelSyncOperationContract, ModelTransformCallback, ModelType, type MongoClientOptions, MongoDbDriver, MongoDriverOptions, MongoIdGenerator, MongoMigrationDriver, MongoQueryBuilder, MongoSyncAdapter, NamingConvention, OnDeletedEventContext, Operation, OperationType, OrderDirection, PaginationOptions, PaginationResult, PendingMigration, PendingOperation, PipelineStage, type PivotData, type PivotIds, PivotOperations, PostgresBlueprint, PostgresConnectionConfig, PostgresCopyOptions, PostgresDialect, PostgresDriver, PostgresIsolationLevel, PostgresMigrationDriver, PostgresNotification, PostgresOperation, PostgresOperationType, PostgresParserOperation, PostgresParserOptions, PostgresPoolConfig, PostgresQueryBuilder, PostgresQueryParser, PostgresQueryResult, PostgresSyncAdapter, PostgresTransactionOptions, PostgresWhereClause, QueryBuilderContract, RELATION_METADATA_KEY, RawColumnExpression, RawExpression, RawQueryResult, RegisterModel, RegisterModelOptions, type RelationConstraintCallback, type RelationConstraints, RelationDefaults, type RelationDefinition, type RelationDefinitions, RelationHydrator, RelationLoader, type RelationType, RemoverContract, RemoverOptions, RemoverResult, RestorerContract, RestorerOptions, RestorerResult, RollbackMigrationsOptions, type RollbackOptions, type RunMigrationsOptions, type ScopeTiming, type SerializedRelation, SqlAggregateFunction, SqlDeleteOperation, SqlDialectContract, SqlGroupClause, SqlHavingClause, SqlInsertOperation, SqlJoinClause, SqlJoinType, SqlOrderClause, SqlQueryConfig, SqlQueryResult, SqlSelectClause, SqlUpdateOperation, SqlWhereOperation, SqlWhereType, StrictMode, SyncAdapterContract, type SyncConfig, type SyncContext, SyncContextManager, type SyncEventPayload, SyncInstruction, type SyncInstructionOptions, SyncManager, type SyncResult, type TableIndexInformation, TransactionContext, type TransactionOptions, TransactionRollbackError, UndefinedWhereValueError, UniqueEntry, type UniqueRuleOptions, UnsafeFilterError, UnsafeRawExpressionError, UnsupportedLeanOperationError, UnsupportedQueryOperationError, UnsupportedUpdateOperationError, UnwindOptions, UpdateOperations, UpdatePipeline, UpdateResult, UuidStrategy, VectorIndexOptions, WhereCallback, WhereObject, WhereOperator, WriterContract, WriterOptions, WriterResult, arrayBigInt, arrayBoolean, arrayDate, arrayDecimal, arrayFloat, arrayInt, arrayJson, arrayText, arrayTimestamp, arrayUuid, assertDefined, bigInt, bigInteger, binary, blobCol, boolCol as bool, boolCol, buildPostgresPoolConfig, char, cleanupModelsRegistery, connectToDatabase, createDatabase, createPivotOperations, dataSourceRegistry, databaseDataSourceContext, databaseTransactionContext, date, dateTime, decimal, defineModel, double, dropAllTables, enumCol, escapeRegex, exportMigrationsSQL, float, freshMigrate, geometry, getAllModelsFromRegistry, getDatabaseDriver, getModelFromRegistry, globalModelEvents, int, integer, ipAddress, isAggregateExpression, isColumnExpression, isMongoDBDriverLoaded, json, likePatternToRegexSource, lineString, listExecutedMigrations, listPendingMigrations, longText, macAddress, mediumText, migrate, migrationRunner, modelSync, objectCol, onceConnected, onceDisconnected, point, polygon, registerModelInRegistry, removeModelFromRegistery, resolveLikePattern, resolveModelClass, resolveModelName, rollbackMigrations, runMigrations, sanitizeFilter, sanitizeFilterValue, setCol, smallInt, smallInteger, string, text, time, timestamp, tinyInt, tinyInteger, toColumnExpression, transaction, tryResolveModelClass, ulid, useModelTransformer, uuid, vector, verifyRegisteredRelations, year };
|
|
76
77
|
import "./validation/plugins/database-rules-plugin.mjs";
|
|
77
78
|
import "./validation/plugins/embed-validator-plugin.mjs";
|
package/esm/index.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import { DataSource } from "./data-source/data-source.mjs";
|
|
|
4
4
|
import { MissingDataSourceError } from "./errors/missing-data-source.error.mjs";
|
|
5
5
|
import { dataSourceRegistry } from "./data-source/data-source-registry.mjs";
|
|
6
6
|
import { TransactionRollbackError } from "./errors/transaction-rollback.error.mjs";
|
|
7
|
+
import { UndefinedWhereValueError } from "./errors/undefined-where-value.error.mjs";
|
|
7
8
|
import { UnsafeFilterError } from "./errors/unsafe-filter.error.mjs";
|
|
8
9
|
import { UnsafeRawExpressionError } from "./errors/unsafe-raw-expression.error.mjs";
|
|
9
10
|
import { UnsupportedLeanOperationError } from "./errors/unsupported-lean-operation.error.mjs";
|
|
@@ -19,7 +20,7 @@ import { SyncManager } from "./sync/sync-manager.mjs";
|
|
|
19
20
|
import { ModelSyncOperation } from "./sync/model-sync-operation.mjs";
|
|
20
21
|
import { modelSync } from "./sync/model-sync.mjs";
|
|
21
22
|
import { DatabaseRemover } from "./remover/database-remover.mjs";
|
|
22
|
-
import { sanitizeFilter, sanitizeFilterValue } from "./utils/sanitize-filter.mjs";
|
|
23
|
+
import { assertDefined, sanitizeFilter, sanitizeFilterValue } from "./utils/sanitize-filter.mjs";
|
|
23
24
|
import { RelationHydrator } from "./relations/relation-hydrator.mjs";
|
|
24
25
|
import { DatabaseWriterValidationError } from "./validation/database-writer-validation-error.mjs";
|
|
25
26
|
import "./validation/index.mjs";
|
|
@@ -58,4 +59,4 @@ import { createDatabase, dropAllTables } from "./operations/database.mjs";
|
|
|
58
59
|
import { exportMigrationsSQL, freshMigrate, listExecutedMigrations, listPendingMigrations, rollbackMigrations, runMigrations } from "./operations/migrations.mjs";
|
|
59
60
|
import "./operations/index.mjs";
|
|
60
61
|
|
|
61
|
-
export { $agg, $expr, BelongsTo, BelongsToMany, ColumnBuilder, DEFAULT_MAX_SYNC_DEPTH, DataSource, DatabaseDirtyTracker, DatabaseRemover, DatabaseRestorer, DatabaseWriter, DatabaseWriterValidationError, DetachedColumnBuilder, ForeignKeyBuilder, HasMany, HasOne, Migration, MigrationRunner, MissingDataSourceError, Model, ModelEvents, ModelSyncOperation, MongoDbDriver, MongoIdGenerator, MongoMigrationDriver, MongoQueryBuilder, MongoSyncAdapter, PivotOperations, PostgresBlueprint, PostgresDialect, PostgresDriver, PostgresMigrationDriver, PostgresQueryBuilder, PostgresQueryParser, PostgresSyncAdapter, RELATION_METADATA_KEY, RegisterModel, RelationHydrator, RelationLoader, SyncContextManager, SyncManager, TransactionRollbackError, UnsafeFilterError, UnsafeRawExpressionError, UnsupportedLeanOperationError, UnsupportedQueryOperationError, UnsupportedUpdateOperationError, arrayBigInt, arrayBoolean, arrayDate, arrayDecimal, arrayFloat, arrayInt, arrayJson, arrayText, arrayTimestamp, arrayUuid, bigInt, bigInteger, binary, blobCol, boolCol as bool, boolCol, buildPostgresPoolConfig, char, cleanupModelsRegistery, connectToDatabase, createDatabase, createPivotOperations, dataSourceRegistry, databaseDataSourceContext, databaseTransactionContext, date, dateTime, decimal, defineModel, double, dropAllTables, enumCol, escapeRegex, exportMigrationsSQL, float, freshMigrate, geometry, getAllModelsFromRegistry, getDatabaseDriver, getModelFromRegistry, globalModelEvents, int, integer, ipAddress, isAggregateExpression, isColumnExpression, isMongoDBDriverLoaded, json, likePatternToRegexSource, lineString, listExecutedMigrations, listPendingMigrations, longText, macAddress, mediumText, migrate, migrationRunner, modelSync, objectCol, onceConnected, onceDisconnected, point, polygon, registerModelInRegistry, removeModelFromRegistery, resolveLikePattern, resolveModelClass, resolveModelName, rollbackMigrations, runMigrations, sanitizeFilter, sanitizeFilterValue, setCol, smallInt, smallInteger, string, text, time, timestamp, tinyInt, tinyInteger, toColumnExpression, transaction, tryResolveModelClass, ulid, useModelTransformer, uuid, vector, verifyRegisteredRelations, year };
|
|
62
|
+
export { $agg, $expr, BelongsTo, BelongsToMany, ColumnBuilder, DEFAULT_MAX_SYNC_DEPTH, DataSource, DatabaseDirtyTracker, DatabaseRemover, DatabaseRestorer, DatabaseWriter, DatabaseWriterValidationError, DetachedColumnBuilder, ForeignKeyBuilder, HasMany, HasOne, Migration, MigrationRunner, MissingDataSourceError, Model, ModelEvents, ModelSyncOperation, MongoDbDriver, MongoIdGenerator, MongoMigrationDriver, MongoQueryBuilder, MongoSyncAdapter, PivotOperations, PostgresBlueprint, PostgresDialect, PostgresDriver, PostgresMigrationDriver, PostgresQueryBuilder, PostgresQueryParser, PostgresSyncAdapter, RELATION_METADATA_KEY, RegisterModel, RelationHydrator, RelationLoader, SyncContextManager, SyncManager, TransactionRollbackError, UndefinedWhereValueError, UnsafeFilterError, UnsafeRawExpressionError, UnsupportedLeanOperationError, UnsupportedQueryOperationError, UnsupportedUpdateOperationError, arrayBigInt, arrayBoolean, arrayDate, arrayDecimal, arrayFloat, arrayInt, arrayJson, arrayText, arrayTimestamp, arrayUuid, assertDefined, bigInt, bigInteger, binary, blobCol, boolCol as bool, boolCol, buildPostgresPoolConfig, char, cleanupModelsRegistery, connectToDatabase, createDatabase, createPivotOperations, dataSourceRegistry, databaseDataSourceContext, databaseTransactionContext, date, dateTime, decimal, defineModel, double, dropAllTables, enumCol, escapeRegex, exportMigrationsSQL, float, freshMigrate, geometry, getAllModelsFromRegistry, getDatabaseDriver, getModelFromRegistry, globalModelEvents, int, integer, ipAddress, isAggregateExpression, isColumnExpression, isMongoDBDriverLoaded, json, likePatternToRegexSource, lineString, listExecutedMigrations, listPendingMigrations, longText, macAddress, mediumText, migrate, migrationRunner, modelSync, objectCol, onceConnected, onceDisconnected, point, polygon, registerModelInRegistry, removeModelFromRegistery, resolveLikePattern, resolveModelClass, resolveModelName, rollbackMigrations, runMigrations, sanitizeFilter, sanitizeFilterValue, setCol, smallInt, smallInteger, string, text, time, timestamp, tinyInt, tinyInteger, toColumnExpression, transaction, tryResolveModelClass, ulid, useModelTransformer, uuid, vector, verifyRegisteredRelations, year };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-builder.d.mts","names":[],"sources":["../../../../../../../cascade/src/query-builder/query-builder.ts"],"mappings":";;;;;;;KAmDY,EAAA;EAAA,SACD,IAAA;EAAA,SACA,IAAA,EAAM,MAAM;AAAA;;;;;;;;;;;;;;;;;;;;;;;;cA0CV,YAAA;
|
|
1
|
+
{"version":3,"file":"query-builder.d.mts","names":[],"sources":["../../../../../../../cascade/src/query-builder/query-builder.ts"],"mappings":";;;;;;;KAmDY,EAAA;EAAA,SACD,IAAA;EAAA,SACA,IAAA,EAAM,MAAM;AAAA;;;;;;;;;;;;;;;;;;;;;;;;cA0CV,YAAA;EA8zBgB;EAxzBpB,UAAA,EAAY,EAAA;EAqgCqB;;;;;;;;;EAAA,UA1/B9B,OAAA,EAAS,GAAA;EAynCV;EAlnCF,mBAAA,GAAsB,GAAA;EA4nChB;EA1nCN,oBAAA,GAAuB,GAAA,aAAgB,IAAA;EA4nCjC;EA1nCN,oBAAA,EAAsB,GAAA;EAopCmB;EAlpCzC,aAAA;EA4pCqB;EArpCrB,kBAAA,EAAoB,GAAA,qBAAwB,KAAA;EA0pCrB;EAxpCvB,cAAA,EAAgB,GAAA;IAAc,QAAA;IAAkB,aAAA,GAAgB,EAAA;EAAA;EAmvCzC;EAjvCvB,mBAAA,GAAsB,MAAA;EAm0CP;EAj0Cf,UAAA;EAs1CgC;EA/0ChC,MAAA;EAw2CsB;;;;EAAA,UA91CnB,YAAA,CAAa,IAAA,UAAc,IAAA,EAAM,MAAA;EA5DnB;;;;;;;EA8EjB,MAAA,IAAU,KAAA,aAAkB,EAAA;EApDL;;;;;;EAkFvB,YAAA;EAvE4C;;;;;;;;;;;;;EAAA,UAsGzC,QAAA,IAAY,YAAA;EA7Df;;;;;;EAuEA,KAAA;EAyBA;;;;;;;;;EAAA,IAAA,IAAQ,YAAA,CAAa,YAAA,CAAa,CAAA;EAgDlC;EAtCA,kBAAA,IAAsB,UAAA;EAsCD;EAhCrB,mBAAA;EAiCM;;;;EAxBN,KA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Q,KAAA,EAAO,YAAA;;EAOf,UAAA,CAAW,UAAA,EAAY,aAAA,EAAe,QAAA;;;;;;;;;EAatC,MAAA,CAAO,KAAA,UAAe,KAAA;EACtB,MAAA,CAAO,KAAA,UAAe,QAAA,EAAU,aAAA,EAAe,KAAA;EAC/C,MAAA,CAAO,SAAA,EAAW,WAAA;;EAwBlB,SAAA,CAAU,UAAA,EAAY,aAAA,EAAe,QAAA;;;;;EAarC,GAAA,CAAI,QAAA,GAAW,OAAA;;;;;;;;EAYf,IAAA,IACL,SAAA,EAAW,CAAA,YACX,QAAA,GAAW,OAAA,QAAe,KAAA,EAAO,CAAA,WACjC,SAAA,IAAa,OAAA;AAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sanitizeFilter, sanitizeFilterValue } from "../utils/sanitize-filter.mjs";
|
|
1
|
+
import { assertDefined, sanitizeFilter, sanitizeFilterValue } from "../utils/sanitize-filter.mjs";
|
|
2
2
|
|
|
3
3
|
//#region ../cascade/src/query-builder/query-builder.ts
|
|
4
4
|
/**
|
|
@@ -198,11 +198,17 @@ var QueryBuilder = class QueryBuilder {
|
|
|
198
198
|
operator: "=",
|
|
199
199
|
value: sanitizeFilterValue(args[1], String(args[0]))
|
|
200
200
|
});
|
|
201
|
-
else
|
|
202
|
-
field
|
|
203
|
-
operator
|
|
204
|
-
value
|
|
205
|
-
|
|
201
|
+
else {
|
|
202
|
+
const field = String(args[0]);
|
|
203
|
+
const operator = args[1];
|
|
204
|
+
const value = operator === "=" ? sanitizeFilterValue(args[2], field) : args[2];
|
|
205
|
+
if (operator !== "=") assertDefined(value, field);
|
|
206
|
+
this.addOperation("where", {
|
|
207
|
+
field: args[0],
|
|
208
|
+
operator,
|
|
209
|
+
value
|
|
210
|
+
});
|
|
211
|
+
}
|
|
206
212
|
return this;
|
|
207
213
|
}
|
|
208
214
|
orWhere(...args) {
|
|
@@ -220,11 +226,17 @@ var QueryBuilder = class QueryBuilder {
|
|
|
220
226
|
operator: "=",
|
|
221
227
|
value: sanitizeFilterValue(args[1], String(args[0]))
|
|
222
228
|
});
|
|
223
|
-
else
|
|
224
|
-
field
|
|
225
|
-
operator
|
|
226
|
-
value
|
|
227
|
-
|
|
229
|
+
else {
|
|
230
|
+
const field = String(args[0]);
|
|
231
|
+
const operator = args[1];
|
|
232
|
+
const value = operator === "=" ? sanitizeFilterValue(args[2], field) : args[2];
|
|
233
|
+
if (operator !== "=") assertDefined(value, field);
|
|
234
|
+
this.addOperation("orWhere", {
|
|
235
|
+
field: args[0],
|
|
236
|
+
operator,
|
|
237
|
+
value
|
|
238
|
+
});
|
|
239
|
+
}
|
|
228
240
|
return this;
|
|
229
241
|
}
|
|
230
242
|
/**
|