pqb 0.66.0 → 0.66.1

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.
@@ -1,2 +1,3 @@
1
1
  import { Adapter, AdapterClass, AdapterConfigBase, AdapterParams, AfterCommitStandaloneHook, AfterHook, ArrayColumn, ArrayColumnValue, ArrayData, AsyncState, BaseNumberData, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BoxColumn, ByteaColumn, CidrColumn, CircleColumn, CitextColumn, Code, Codes, Column, ColumnFromDbParams, ColumnSchemaConfig, ColumnSchemaGetterColumns, ColumnSchemaGetterTableClass, ColumnToCodeCtx, ColumnTypeSchemaArg, ColumnsByType, ColumnsShape, ComputedColumnsFromOptions, ComputedOptionsConfig, ComputedOptionsFactory, CreateCtx, CreateData, CreateManyMethodsNames, CreateMethodsNames, CreateSelf, CustomTypeColumn, DateColumn, DateColumnData, DbDomainArg, DbExtension, DbOptions, DbResult, DbRlsOptions, DbSharedOptions, DbSqlMethod, DbStructureDomainsMap, DbTableOptionScopes, DbTableOptions, DecimalColumn, DecimalColumnData, DefaultColumnTypes, DefaultPrivileges, DefaultSchemaConfig, DeleteMethodsNames, DomainColumn, DoublePrecisionColumn, DriverAdapter, DynamicRawSQL, EmptyObject, EmptyTuple, EnumColumn, Expression, FromArg, FromResult, GeneratorIgnore, HookSelectValue, InetColumn, IntegerColumn, IntervalColumn, IsQuery, IsolationLevel, JSONColumn, JSONTextColumn, JoinQueryMethod, JoinedShapes, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, MapTableScopesOption, MaybeArray, MaybePromise, MergeQuery, MoneyColumn, NoPrimaryKeyOption, NonUniqDataItem, NumberColumnData, Operators, OperatorsArray, OperatorsJson, OperatorsOrdinalText, Ord, PathColumn, PickQueryInputType, PickQueryInternal, PickQueryQ, PickQueryRelations, PickQuerySelectableRelations, PickQueryShape, PointColumn, PolygonColumn, PostgisGeographyPointColumn, QueryAfterHook, QueryArraysResult, QueryBeforeActionHook, QueryBeforeHook, QueryData, QueryHasWhere, QueryHookUtils, QueryHooks, QueryInternal, QueryLogObject, QueryLogOptions, QueryLogger, QueryManyTake, QueryManyTakeOptional, QueryOrExpression, QueryResult, QueryResultRow, QueryReturnType, QuerySchema, QueryScopes, RawSql, RawSqlBase, RealColumn, RecordKeyTrue, RecordOptionalString, RecordString, RecordStringOrNumber, RecordUnknown, RelationConfigBase, RelationJoinQuery, RelationsBase, SearchWeight, SelectableFromShape, SerialColumn, SerialColumnData, ShallowSimplify, ShapeColumnPrimaryKeys, ShapeUniqueColumns, SingleSql, SingleSqlItem, SmallIntColumn, SmallSerialColumn, Sql, SqlFn, SqlSessionState, StorageOptions, StringColumn, StringData, TableData, TableDataFn, TableDataInput, TableDataItem, TableDataItemsUniqueColumnTuples, TableDataItemsUniqueColumns, TableDataItemsUniqueConstraints, TableDataMethods, TableRlsConfig, TemplateLiteralArgs, TextColumn, TimeColumn, TimestampColumn, TimestampTZColumn, Timestamps, TransactionAdapterClass, TransactionOptions, TsQueryColumn, TsVectorColumn, UUIDColumn, UniqueConstraints, UniqueTableDataItem, UnknownColumn, UpdateData, UpsertData, UpsertThis, VarCharColumn, VirtualColumn, WhereArg, XMLColumn, _appendQuery, _clone, _createDbSqlMethod, _hookSelectColumns, _initQueryBuilder, _orCreate, _prependWith, _queryCreate, _queryCreateMany, _queryCreateManyFrom, _queryDefaults, _queryDelete, _queryFindBy, _queryFindByOptional, _queryHookAfterCreate, _queryHookAfterUpdate, _queryInsert, _queryInsertMany, _queryJoinOn, _queryRows, _querySelect, _queryTake, _queryTakeOptional, _queryUpdate, _queryUpdateOrThrow, _queryUpsert, _queryWhere, _queryWhereExists, _queryWhereIn, addCode, addTopCte, addTopCteSql, applyMixins, assignDbDataToColumn, backtickQuote, cloneQueryBaseUnscoped, codeToString, colors, columnsShapeToCode, constraintInnerToCode, consumeColumnName, deepCompare, defaultSchemaConfig, emptyArray, emptyObject, escapeForMigration, escapeString, excludeInnerToCode, exhaustive, getCallerFilePath, getClonedQueryData, getColumnBaseType, getColumnTypes, getFreeAlias, getFreeSetAlias, getImportPath, getPrimaryKeys, getQueryAs, getQuerySchema, getShapeFromSelect, getSqlText, getStackTrace, getSupportedDefaultPrivileges, indexInnerToCode, isExpression, isQueryReturnsAll, isRawSQL, logColors, logParamToLogObject, makeColumnNullable, makeColumnTypes, makeColumnsByType, makeConnectRetryConfig, noop, objectHasValues, omit, parseTableData, parseTableDataInput, pathToLog, pick, pluralize, prepareSubQueryForSql, primaryKeyInnerToCode, pushQueryOnForOuter, pushQueryValueImmutable, pushTableDataCode, quoteObjectKey, quoteTableWithSchema, raw, rawSqlToCode, referencesArgsToCode, returnArg, setColumnData, setColumnEncode, setColumnParse, setColumnParseNull, setCurrentColumnName, setDataValue, setDefaultLanguage, setFreeAlias, setQueryObjectValueImmutable, singleQuote, snakeCaseKey, tableDataMethods, toArray, toCamelCase, toPascalCase, toSnakeCase, wrapAdapterFnWithConnectRetry } from "./index.d.ts";
2
- export { type Adapter, AdapterClass, type AdapterConfigBase, type AdapterParams, type AfterCommitStandaloneHook, type AfterHook, ArrayColumn, type ArrayColumnValue, type ArrayData, type AsyncState, type BaseNumberData, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BoxColumn, ByteaColumn, CidrColumn, CircleColumn, CitextColumn, type Code, type Codes, Column, type ColumnFromDbParams, type ColumnSchemaConfig, type ColumnSchemaGetterColumns, type ColumnSchemaGetterTableClass, type ColumnToCodeCtx, type ColumnTypeSchemaArg, type ColumnsByType, type ColumnsShape, type ComputedColumnsFromOptions, type ComputedOptionsConfig, type ComputedOptionsFactory, type CreateCtx, type CreateData, type CreateManyMethodsNames, type CreateMethodsNames, type CreateSelf, CustomTypeColumn, DateColumn, type DateColumnData, type DbDomainArg, type DbExtension, type DbOptions, type DbResult, type DbRlsOptions, type DbSharedOptions, type DbSqlMethod, type DbStructureDomainsMap, type DbTableOptionScopes, type DbTableOptions, DecimalColumn, type DecimalColumnData, type DefaultColumnTypes, type DefaultPrivileges, type DefaultSchemaConfig, type DeleteMethodsNames, DomainColumn, DoublePrecisionColumn, type DriverAdapter, DynamicRawSQL, type EmptyObject, type EmptyTuple, EnumColumn, Expression, type FromArg, type FromResult, type GeneratorIgnore, type HookSelectValue, InetColumn, IntegerColumn, IntervalColumn, type IsQuery, type IsolationLevel, JSONColumn, JSONTextColumn, type JoinQueryMethod, type JoinedShapes, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, type MapTableScopesOption, type MaybeArray, type MaybePromise, type MergeQuery, MoneyColumn, type NoPrimaryKeyOption, type NonUniqDataItem, type NumberColumnData, Operators, type OperatorsArray, type OperatorsJson, type OperatorsOrdinalText, type Ord, PathColumn, type PickQueryInputType, type PickQueryInternal, type PickQueryQ, type PickQueryRelations, type PickQuerySelectableRelations, type PickQueryShape, PointColumn, PolygonColumn, PostgisGeographyPointColumn, type QueryAfterHook, type QueryArraysResult, type QueryBeforeActionHook, type QueryBeforeHook, type QueryData, type QueryHasWhere, QueryHookUtils, QueryHooks, type QueryInternal, type QueryLogObject, type QueryLogOptions, type QueryLogger, type QueryManyTake, type QueryManyTakeOptional, type QueryOrExpression, type QueryResult, type QueryResultRow, type QueryReturnType, type QuerySchema, type QueryScopes, RawSql, type RawSqlBase, RealColumn, type RecordKeyTrue, type RecordOptionalString, type RecordString, type RecordStringOrNumber, type RecordUnknown, type RelationConfigBase, type RelationJoinQuery, type RelationsBase, type SearchWeight, type SelectableFromShape, SerialColumn, type SerialColumnData, type ShallowSimplify, type ShapeColumnPrimaryKeys, type ShapeUniqueColumns, type SingleSql, type SingleSqlItem, SmallIntColumn, SmallSerialColumn, type Sql, type SqlFn, type SqlSessionState, type StorageOptions, StringColumn, type StringData, type TableData, type TableDataFn, type TableDataInput, type TableDataItem, type TableDataItemsUniqueColumnTuples, type TableDataItemsUniqueColumns, type TableDataItemsUniqueConstraints, type TableDataMethods, type TableRlsConfig, type TemplateLiteralArgs, TextColumn, TimeColumn, TimestampColumn, TimestampTZColumn, type Timestamps, TransactionAdapterClass, type TransactionOptions, TsQueryColumn, TsVectorColumn, UUIDColumn, type UniqueConstraints, type UniqueTableDataItem, UnknownColumn, type UpdateData, type UpsertData, type UpsertThis, VarCharColumn, VirtualColumn, type WhereArg, XMLColumn, _appendQuery, _clone, _createDbSqlMethod, _hookSelectColumns, _initQueryBuilder, _orCreate, _prependWith, _queryCreate, _queryCreateMany, _queryCreateManyFrom, _queryDefaults, _queryDelete, _queryFindBy, _queryFindByOptional, _queryHookAfterCreate, _queryHookAfterUpdate, _queryInsert, _queryInsertMany, _queryJoinOn, _queryRows, _querySelect, _queryTake, _queryTakeOptional, _queryUpdate, _queryUpdateOrThrow, _queryUpsert, _queryWhere, _queryWhereExists, _queryWhereIn, addCode, addTopCte, addTopCteSql, applyMixins, assignDbDataToColumn, backtickQuote, cloneQueryBaseUnscoped, codeToString, colors, columnsShapeToCode, constraintInnerToCode, consumeColumnName, deepCompare, defaultSchemaConfig, emptyArray, emptyObject, escapeForMigration, escapeString, excludeInnerToCode, exhaustive, getCallerFilePath, getClonedQueryData, getColumnBaseType, getColumnTypes, getFreeAlias, getFreeSetAlias, getImportPath, getPrimaryKeys, getQueryAs, getQuerySchema, getShapeFromSelect, getSqlText, getStackTrace, getSupportedDefaultPrivileges, indexInnerToCode, isExpression, isQueryReturnsAll, isRawSQL, logColors, logParamToLogObject, makeColumnNullable, makeColumnTypes, makeColumnsByType, makeConnectRetryConfig, noop, objectHasValues, omit, parseTableData, parseTableDataInput, pathToLog, pick, pluralize, prepareSubQueryForSql, primaryKeyInnerToCode, pushQueryOnForOuter, pushQueryValueImmutable, pushTableDataCode, quoteObjectKey, quoteTableWithSchema, raw, rawSqlToCode, referencesArgsToCode, returnArg, setColumnData, setColumnEncode, setColumnParse, setColumnParseNull, setCurrentColumnName, setDataValue, setDefaultLanguage, setFreeAlias, setQueryObjectValueImmutable, singleQuote, snakeCaseKey, tableDataMethods, toArray, toCamelCase, toPascalCase, toSnakeCase, wrapAdapterFnWithConnectRetry };
2
+ declare abstract class OrchidOrmError extends Error {}
3
+ export { type Adapter, AdapterClass, type AdapterConfigBase, type AdapterParams, type AfterCommitStandaloneHook, type AfterHook, ArrayColumn, type ArrayColumnValue, type ArrayData, type AsyncState, type BaseNumberData, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BoxColumn, ByteaColumn, CidrColumn, CircleColumn, CitextColumn, type Code, type Codes, Column, type ColumnFromDbParams, type ColumnSchemaConfig, type ColumnSchemaGetterColumns, type ColumnSchemaGetterTableClass, type ColumnToCodeCtx, type ColumnTypeSchemaArg, type ColumnsByType, type ColumnsShape, type ComputedColumnsFromOptions, type ComputedOptionsConfig, type ComputedOptionsFactory, type CreateCtx, type CreateData, type CreateManyMethodsNames, type CreateMethodsNames, type CreateSelf, CustomTypeColumn, DateColumn, type DateColumnData, type DbDomainArg, type DbExtension, type DbOptions, type DbResult, type DbRlsOptions, type DbSharedOptions, type DbSqlMethod, type DbStructureDomainsMap, type DbTableOptionScopes, type DbTableOptions, DecimalColumn, type DecimalColumnData, type DefaultColumnTypes, type DefaultPrivileges, type DefaultSchemaConfig, type DeleteMethodsNames, DomainColumn, DoublePrecisionColumn, type DriverAdapter, DynamicRawSQL, type EmptyObject, type EmptyTuple, EnumColumn, Expression, type FromArg, type FromResult, type GeneratorIgnore, type HookSelectValue, InetColumn, IntegerColumn, IntervalColumn, type IsQuery, type IsolationLevel, JSONColumn, JSONTextColumn, type JoinQueryMethod, type JoinedShapes, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, type MapTableScopesOption, type MaybeArray, type MaybePromise, type MergeQuery, MoneyColumn, type NoPrimaryKeyOption, type NonUniqDataItem, type NumberColumnData, Operators, type OperatorsArray, type OperatorsJson, type OperatorsOrdinalText, OrchidOrmError, type Ord, PathColumn, type PickQueryInputType, type PickQueryInternal, type PickQueryQ, type PickQueryRelations, type PickQuerySelectableRelations, type PickQueryShape, PointColumn, PolygonColumn, PostgisGeographyPointColumn, type QueryAfterHook, type QueryArraysResult, type QueryBeforeActionHook, type QueryBeforeHook, type QueryData, type QueryHasWhere, QueryHookUtils, QueryHooks, type QueryInternal, type QueryLogObject, type QueryLogOptions, type QueryLogger, type QueryManyTake, type QueryManyTakeOptional, type QueryOrExpression, type QueryResult, type QueryResultRow, type QueryReturnType, type QuerySchema, type QueryScopes, RawSql, type RawSqlBase, RealColumn, type RecordKeyTrue, type RecordOptionalString, type RecordString, type RecordStringOrNumber, type RecordUnknown, type RelationConfigBase, type RelationJoinQuery, type RelationsBase, type SearchWeight, type SelectableFromShape, SerialColumn, type SerialColumnData, type ShallowSimplify, type ShapeColumnPrimaryKeys, type ShapeUniqueColumns, type SingleSql, type SingleSqlItem, SmallIntColumn, SmallSerialColumn, type Sql, type SqlFn, type SqlSessionState, type StorageOptions, StringColumn, type StringData, type TableData, type TableDataFn, type TableDataInput, type TableDataItem, type TableDataItemsUniqueColumnTuples, type TableDataItemsUniqueColumns, type TableDataItemsUniqueConstraints, type TableDataMethods, type TableRlsConfig, type TemplateLiteralArgs, TextColumn, TimeColumn, TimestampColumn, TimestampTZColumn, type Timestamps, TransactionAdapterClass, type TransactionOptions, TsQueryColumn, TsVectorColumn, UUIDColumn, type UniqueConstraints, type UniqueTableDataItem, UnknownColumn, type UpdateData, type UpsertData, type UpsertThis, VarCharColumn, VirtualColumn, type WhereArg, XMLColumn, _appendQuery, _clone, _createDbSqlMethod, _hookSelectColumns, _initQueryBuilder, _orCreate, _prependWith, _queryCreate, _queryCreateMany, _queryCreateManyFrom, _queryDefaults, _queryDelete, _queryFindBy, _queryFindByOptional, _queryHookAfterCreate, _queryHookAfterUpdate, _queryInsert, _queryInsertMany, _queryJoinOn, _queryRows, _querySelect, _queryTake, _queryTakeOptional, _queryUpdate, _queryUpdateOrThrow, _queryUpsert, _queryWhere, _queryWhereExists, _queryWhereIn, addCode, addTopCte, addTopCteSql, applyMixins, assignDbDataToColumn, backtickQuote, cloneQueryBaseUnscoped, codeToString, colors, columnsShapeToCode, constraintInnerToCode, consumeColumnName, deepCompare, defaultSchemaConfig, emptyArray, emptyObject, escapeForMigration, escapeString, excludeInnerToCode, exhaustive, getCallerFilePath, getClonedQueryData, getColumnBaseType, getColumnTypes, getFreeAlias, getFreeSetAlias, getImportPath, getPrimaryKeys, getQueryAs, getQuerySchema, getShapeFromSelect, getSqlText, getStackTrace, getSupportedDefaultPrivileges, indexInnerToCode, isExpression, isQueryReturnsAll, isRawSQL, logColors, logParamToLogObject, makeColumnNullable, makeColumnTypes, makeColumnsByType, makeConnectRetryConfig, noop, objectHasValues, omit, parseTableData, parseTableDataInput, pathToLog, pick, pluralize, prepareSubQueryForSql, primaryKeyInnerToCode, pushQueryOnForOuter, pushQueryValueImmutable, pushTableDataCode, quoteObjectKey, quoteTableWithSchema, raw, rawSqlToCode, referencesArgsToCode, returnArg, setColumnData, setColumnEncode, setColumnParse, setColumnParseNull, setCurrentColumnName, setDataValue, setDefaultLanguage, setFreeAlias, setQueryObjectValueImmutable, singleQuote, snakeCaseKey, tableDataMethods, toArray, toCamelCase, toPascalCase, toSnakeCase, wrapAdapterFnWithConnectRetry };
package/dist/internal.js CHANGED
@@ -1,5 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  let src_index_ts = require("./index.js");
3
+ var OrchidOrmError = class extends Error {};
3
4
  Object.defineProperty(exports, "AdapterClass", {
4
5
  enumerable: true,
5
6
  get: function() {
@@ -192,6 +193,7 @@ Object.defineProperty(exports, "Operators", {
192
193
  return src_index_ts.Operators;
193
194
  }
194
195
  });
196
+ exports.OrchidOrmError = OrchidOrmError;
195
197
  Object.defineProperty(exports, "PathColumn", {
196
198
  enumerable: true,
197
199
  get: function() {
@@ -990,3 +992,5 @@ Object.defineProperty(exports, "wrapAdapterFnWithConnectRetry", {
990
992
  return src_index_ts.wrapAdapterFnWithConnectRetry;
991
993
  }
992
994
  });
995
+
996
+ //# sourceMappingURL=internal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.js","names":[],"sources":["../src/query/errors.ts"],"sourcesContent":["import { RecordUnknown } from '../utils';\nimport { PickQueryShape } from './pick-query-types';\nimport { IsQuery, Query } from './query';\nimport { queryColumnNameToKey } from './query-columns/query-columns';\n\nexport abstract class OrchidOrmError extends Error {}\n\n/**\n * When we search for a single record, and it is not found, it can either throw an error, or return `undefined`.\n *\n * Unlike other database libraries, `Orchid ORM` decided to throw errors by default when using methods `take`, `find`, `findBy`, `get` and the record is not found.\n * It is a [good practice](https://github.com/goldbergyoni/nodebestpractices/blob/master/sections/errorhandling/centralizedhandling.md) to catch common errors in a centralized place (see [global error handling](https://orchid-orm.netlify.app/guide/error-handling.html#global-error-handling)), and this allows for a more concise code.\n *\n * If it's more suitable to get the `undefined` value instead of throwing, use `takeOptional`, `findOptional`, `findByOptional`, `getOptional` instead.\n */\nexport class NotFoundError extends OrchidOrmError {\n // `#query` is private to prevent it from serializing to not cause problems to test runner reports\n // it is exposed with `getQuery` method which prevents this problem from both Vitest and Jest.\n // Exposing it with `get query()` still leaves the issue in Vitest.\n readonly #query: Query;\n\n constructor(query: IsQuery, message = 'Record is not found') {\n super(message);\n this.#query = query as Query;\n }\n\n getQuery() {\n return this.#query;\n }\n}\n\nexport class OrchidOrmInternalError extends Error {\n // `#query` is private to prevent it from serializing to not cause problems to test runner reports\n // it is exposed with `getQuery` method which prevents this problem from both Vitest and Jest.\n // Exposing it with `get query()` still leaves the issue in Vitest.\n readonly #query: Query;\n\n constructor(\n query: IsQuery,\n message?: string,\n public data?: RecordUnknown,\n ) {\n super(message);\n this.#query = query as Query;\n }\n\n getQuery() {\n return this.#query;\n }\n}\n\nexport type QueryErrorName =\n | 'parseComplete'\n | 'bindComplete'\n | 'closeComplete'\n | 'noData'\n | 'portalSuspended'\n | 'replicationStart'\n | 'emptyQuery'\n | 'copyDone'\n | 'copyData'\n | 'rowDescription'\n | 'parameterDescription'\n | 'parameterStatus'\n | 'backendKeyData'\n | 'notification'\n | 'readyForQuery'\n | 'commandComplete'\n | 'dataRow'\n | 'copyInResponse'\n | 'copyOutResponse'\n | 'authenticationOk'\n | 'authenticationMD5Password'\n | 'authenticationCleartextPassword'\n | 'authenticationSASL'\n | 'authenticationSASLContinue'\n | 'authenticationSASLFinal'\n | 'error'\n | 'notice';\n\nexport abstract class QueryError<\n T extends PickQueryShape = PickQueryShape,\n> extends OrchidOrmInternalError {\n declare message: string;\n declare length?: number;\n declare name: QueryErrorName;\n declare stack: string | undefined;\n code: string | undefined;\n detail: string | undefined;\n severity: string | undefined;\n hint: string | undefined;\n position: string | undefined;\n internalPosition: string | undefined;\n internalQuery: string | undefined;\n where: string | undefined;\n schema: string | undefined;\n table: string | undefined;\n column: string | undefined;\n dataType: string | undefined;\n constraint: string | undefined;\n file: string | undefined;\n line: string | undefined;\n routine: string | undefined;\n\n get isUnique() {\n return this.code === '23505';\n }\n\n #columnsCache?: { [K in keyof T['shape']]?: true };\n get columns() {\n if (this.#columnsCache) return this.#columnsCache;\n\n const columns: { [K in keyof T['shape']]?: true } = {};\n\n if (this.detail) {\n const list = this.detail.match(/\\((.*)\\)=/)?.[1];\n if (list) {\n list.split(', ').forEach((item) => {\n const column = (\n item.startsWith('\"') ? item.slice(1, -1) : item\n ) as keyof T['shape'];\n\n const key =\n queryColumnNameToKey(this.getQuery(), column as string) ?? column;\n columns[key as keyof T['shape']] = true;\n });\n }\n }\n\n return (this.#columnsCache = columns);\n }\n}\n\nexport class MoreThanOneRowError extends OrchidOrmInternalError {\n constructor(query: IsQuery, message?: string) {\n super(query, message);\n }\n}\n\nexport class UnhandledTypeError extends OrchidOrmInternalError {\n constructor(query: IsQuery, value: never) {\n super(query, `Unhandled type: ${JSON.stringify(value)} received`);\n }\n}\n\n/**\n * Error thrown when attempting to nest SQL session scopes.\n * Nested withOptions/$withOptions calls that supply role or setConfig while an outer\n * scope already has SQL session state defined will throw this error.\n */\nexport class NestedSqlSessionError extends OrchidOrmInternalError {\n constructor(query: IsQuery) {\n super(\n query,\n 'Cannot nest SQL session scopes. Outer scope already has role or setConfig defined.',\n );\n }\n}\n"],"mappings":";;AAKA,IAAsB,iBAAtB,cAA6C,MAAM"}
package/dist/internal.mjs CHANGED
@@ -1,2 +1,5 @@
1
1
  import { AdapterClass, ArrayColumn, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BoxColumn, ByteaColumn, CidrColumn, CircleColumn, CitextColumn, Column, CustomTypeColumn, DateColumn, DecimalColumn, DomainColumn, DoublePrecisionColumn, DynamicRawSQL, EnumColumn, Expression, InetColumn, IntegerColumn, IntervalColumn, JSONColumn, JSONTextColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, MoneyColumn, Operators, PathColumn, PointColumn, PolygonColumn, PostgisGeographyPointColumn, QueryHookUtils, QueryHooks, RawSql, RealColumn, SerialColumn, SmallIntColumn, SmallSerialColumn, StringColumn, TextColumn, TimeColumn, TimestampColumn, TimestampTZColumn, TransactionAdapterClass, TsQueryColumn, TsVectorColumn, UUIDColumn, UnknownColumn, VarCharColumn, VirtualColumn, XMLColumn, _appendQuery, _clone, _createDbSqlMethod, _hookSelectColumns, _initQueryBuilder, _orCreate, _prependWith, _queryCreate, _queryCreateMany, _queryCreateManyFrom, _queryDefaults, _queryDelete, _queryFindBy, _queryFindByOptional, _queryHookAfterCreate, _queryHookAfterUpdate, _queryInsert, _queryInsertMany, _queryJoinOn, _queryRows, _querySelect, _queryTake, _queryTakeOptional, _queryUpdate, _queryUpdateOrThrow, _queryUpsert, _queryWhere, _queryWhereExists, _queryWhereIn, addCode, addTopCte, addTopCteSql, applyMixins, assignDbDataToColumn, backtickQuote, cloneQueryBaseUnscoped, codeToString, colors, columnsShapeToCode, constraintInnerToCode, consumeColumnName, deepCompare, defaultSchemaConfig, emptyArray, emptyObject, escapeForMigration, escapeString, excludeInnerToCode, exhaustive, getCallerFilePath, getClonedQueryData, getColumnBaseType, getColumnTypes, getFreeAlias, getFreeSetAlias, getImportPath, getPrimaryKeys, getQueryAs, getQuerySchema, getShapeFromSelect, getSqlText, getStackTrace, getSupportedDefaultPrivileges, indexInnerToCode, isExpression, isQueryReturnsAll, isRawSQL, logColors, logParamToLogObject, makeColumnNullable, makeColumnTypes, makeColumnsByType, makeConnectRetryConfig, noop, objectHasValues, omit, parseTableData, parseTableDataInput, pathToLog, pick, pluralize, prepareSubQueryForSql, primaryKeyInnerToCode, pushQueryOnForOuter, pushQueryValueImmutable, pushTableDataCode, quoteObjectKey, quoteTableWithSchema, raw, rawSqlToCode, referencesArgsToCode, returnArg, setColumnData, setColumnEncode, setColumnParse, setColumnParseNull, setCurrentColumnName, setDataValue, setDefaultLanguage, setFreeAlias, setQueryObjectValueImmutable, singleQuote, snakeCaseKey, tableDataMethods, toArray, toCamelCase, toPascalCase, toSnakeCase, wrapAdapterFnWithConnectRetry } from "./index.mjs";
2
- export { AdapterClass, ArrayColumn, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BoxColumn, ByteaColumn, CidrColumn, CircleColumn, CitextColumn, Column, CustomTypeColumn, DateColumn, DecimalColumn, DomainColumn, DoublePrecisionColumn, DynamicRawSQL, EnumColumn, Expression, InetColumn, IntegerColumn, IntervalColumn, JSONColumn, JSONTextColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, MoneyColumn, Operators, PathColumn, PointColumn, PolygonColumn, PostgisGeographyPointColumn, QueryHookUtils, QueryHooks, RawSql, RealColumn, SerialColumn, SmallIntColumn, SmallSerialColumn, StringColumn, TextColumn, TimeColumn, TimestampColumn, TimestampTZColumn, TransactionAdapterClass, TsQueryColumn, TsVectorColumn, UUIDColumn, UnknownColumn, VarCharColumn, VirtualColumn, XMLColumn, _appendQuery, _clone, _createDbSqlMethod, _hookSelectColumns, _initQueryBuilder, _orCreate, _prependWith, _queryCreate, _queryCreateMany, _queryCreateManyFrom, _queryDefaults, _queryDelete, _queryFindBy, _queryFindByOptional, _queryHookAfterCreate, _queryHookAfterUpdate, _queryInsert, _queryInsertMany, _queryJoinOn, _queryRows, _querySelect, _queryTake, _queryTakeOptional, _queryUpdate, _queryUpdateOrThrow, _queryUpsert, _queryWhere, _queryWhereExists, _queryWhereIn, addCode, addTopCte, addTopCteSql, applyMixins, assignDbDataToColumn, backtickQuote, cloneQueryBaseUnscoped, codeToString, colors, columnsShapeToCode, constraintInnerToCode, consumeColumnName, deepCompare, defaultSchemaConfig, emptyArray, emptyObject, escapeForMigration, escapeString, excludeInnerToCode, exhaustive, getCallerFilePath, getClonedQueryData, getColumnBaseType, getColumnTypes, getFreeAlias, getFreeSetAlias, getImportPath, getPrimaryKeys, getQueryAs, getQuerySchema, getShapeFromSelect, getSqlText, getStackTrace, getSupportedDefaultPrivileges, indexInnerToCode, isExpression, isQueryReturnsAll, isRawSQL, logColors, logParamToLogObject, makeColumnNullable, makeColumnTypes, makeColumnsByType, makeConnectRetryConfig, noop, objectHasValues, omit, parseTableData, parseTableDataInput, pathToLog, pick, pluralize, prepareSubQueryForSql, primaryKeyInnerToCode, pushQueryOnForOuter, pushQueryValueImmutable, pushTableDataCode, quoteObjectKey, quoteTableWithSchema, raw, rawSqlToCode, referencesArgsToCode, returnArg, setColumnData, setColumnEncode, setColumnParse, setColumnParseNull, setCurrentColumnName, setDataValue, setDefaultLanguage, setFreeAlias, setQueryObjectValueImmutable, singleQuote, snakeCaseKey, tableDataMethods, toArray, toCamelCase, toPascalCase, toSnakeCase, wrapAdapterFnWithConnectRetry };
2
+ var OrchidOrmError = class extends Error {};
3
+ export { AdapterClass, ArrayColumn, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BoxColumn, ByteaColumn, CidrColumn, CircleColumn, CitextColumn, Column, CustomTypeColumn, DateColumn, DecimalColumn, DomainColumn, DoublePrecisionColumn, DynamicRawSQL, EnumColumn, Expression, InetColumn, IntegerColumn, IntervalColumn, JSONColumn, JSONTextColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, MoneyColumn, Operators, OrchidOrmError, PathColumn, PointColumn, PolygonColumn, PostgisGeographyPointColumn, QueryHookUtils, QueryHooks, RawSql, RealColumn, SerialColumn, SmallIntColumn, SmallSerialColumn, StringColumn, TextColumn, TimeColumn, TimestampColumn, TimestampTZColumn, TransactionAdapterClass, TsQueryColumn, TsVectorColumn, UUIDColumn, UnknownColumn, VarCharColumn, VirtualColumn, XMLColumn, _appendQuery, _clone, _createDbSqlMethod, _hookSelectColumns, _initQueryBuilder, _orCreate, _prependWith, _queryCreate, _queryCreateMany, _queryCreateManyFrom, _queryDefaults, _queryDelete, _queryFindBy, _queryFindByOptional, _queryHookAfterCreate, _queryHookAfterUpdate, _queryInsert, _queryInsertMany, _queryJoinOn, _queryRows, _querySelect, _queryTake, _queryTakeOptional, _queryUpdate, _queryUpdateOrThrow, _queryUpsert, _queryWhere, _queryWhereExists, _queryWhereIn, addCode, addTopCte, addTopCteSql, applyMixins, assignDbDataToColumn, backtickQuote, cloneQueryBaseUnscoped, codeToString, colors, columnsShapeToCode, constraintInnerToCode, consumeColumnName, deepCompare, defaultSchemaConfig, emptyArray, emptyObject, escapeForMigration, escapeString, excludeInnerToCode, exhaustive, getCallerFilePath, getClonedQueryData, getColumnBaseType, getColumnTypes, getFreeAlias, getFreeSetAlias, getImportPath, getPrimaryKeys, getQueryAs, getQuerySchema, getShapeFromSelect, getSqlText, getStackTrace, getSupportedDefaultPrivileges, indexInnerToCode, isExpression, isQueryReturnsAll, isRawSQL, logColors, logParamToLogObject, makeColumnNullable, makeColumnTypes, makeColumnsByType, makeConnectRetryConfig, noop, objectHasValues, omit, parseTableData, parseTableDataInput, pathToLog, pick, pluralize, prepareSubQueryForSql, primaryKeyInnerToCode, pushQueryOnForOuter, pushQueryValueImmutable, pushTableDataCode, quoteObjectKey, quoteTableWithSchema, raw, rawSqlToCode, referencesArgsToCode, returnArg, setColumnData, setColumnEncode, setColumnParse, setColumnParseNull, setCurrentColumnName, setDataValue, setDefaultLanguage, setFreeAlias, setQueryObjectValueImmutable, singleQuote, snakeCaseKey, tableDataMethods, toArray, toCamelCase, toPascalCase, toSnakeCase, wrapAdapterFnWithConnectRetry };
4
+
5
+ //# sourceMappingURL=internal.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.mjs","names":[],"sources":["../src/query/errors.ts"],"sourcesContent":["import { RecordUnknown } from '../utils';\nimport { PickQueryShape } from './pick-query-types';\nimport { IsQuery, Query } from './query';\nimport { queryColumnNameToKey } from './query-columns/query-columns';\n\nexport abstract class OrchidOrmError extends Error {}\n\n/**\n * When we search for a single record, and it is not found, it can either throw an error, or return `undefined`.\n *\n * Unlike other database libraries, `Orchid ORM` decided to throw errors by default when using methods `take`, `find`, `findBy`, `get` and the record is not found.\n * It is a [good practice](https://github.com/goldbergyoni/nodebestpractices/blob/master/sections/errorhandling/centralizedhandling.md) to catch common errors in a centralized place (see [global error handling](https://orchid-orm.netlify.app/guide/error-handling.html#global-error-handling)), and this allows for a more concise code.\n *\n * If it's more suitable to get the `undefined` value instead of throwing, use `takeOptional`, `findOptional`, `findByOptional`, `getOptional` instead.\n */\nexport class NotFoundError extends OrchidOrmError {\n // `#query` is private to prevent it from serializing to not cause problems to test runner reports\n // it is exposed with `getQuery` method which prevents this problem from both Vitest and Jest.\n // Exposing it with `get query()` still leaves the issue in Vitest.\n readonly #query: Query;\n\n constructor(query: IsQuery, message = 'Record is not found') {\n super(message);\n this.#query = query as Query;\n }\n\n getQuery() {\n return this.#query;\n }\n}\n\nexport class OrchidOrmInternalError extends Error {\n // `#query` is private to prevent it from serializing to not cause problems to test runner reports\n // it is exposed with `getQuery` method which prevents this problem from both Vitest and Jest.\n // Exposing it with `get query()` still leaves the issue in Vitest.\n readonly #query: Query;\n\n constructor(\n query: IsQuery,\n message?: string,\n public data?: RecordUnknown,\n ) {\n super(message);\n this.#query = query as Query;\n }\n\n getQuery() {\n return this.#query;\n }\n}\n\nexport type QueryErrorName =\n | 'parseComplete'\n | 'bindComplete'\n | 'closeComplete'\n | 'noData'\n | 'portalSuspended'\n | 'replicationStart'\n | 'emptyQuery'\n | 'copyDone'\n | 'copyData'\n | 'rowDescription'\n | 'parameterDescription'\n | 'parameterStatus'\n | 'backendKeyData'\n | 'notification'\n | 'readyForQuery'\n | 'commandComplete'\n | 'dataRow'\n | 'copyInResponse'\n | 'copyOutResponse'\n | 'authenticationOk'\n | 'authenticationMD5Password'\n | 'authenticationCleartextPassword'\n | 'authenticationSASL'\n | 'authenticationSASLContinue'\n | 'authenticationSASLFinal'\n | 'error'\n | 'notice';\n\nexport abstract class QueryError<\n T extends PickQueryShape = PickQueryShape,\n> extends OrchidOrmInternalError {\n declare message: string;\n declare length?: number;\n declare name: QueryErrorName;\n declare stack: string | undefined;\n code: string | undefined;\n detail: string | undefined;\n severity: string | undefined;\n hint: string | undefined;\n position: string | undefined;\n internalPosition: string | undefined;\n internalQuery: string | undefined;\n where: string | undefined;\n schema: string | undefined;\n table: string | undefined;\n column: string | undefined;\n dataType: string | undefined;\n constraint: string | undefined;\n file: string | undefined;\n line: string | undefined;\n routine: string | undefined;\n\n get isUnique() {\n return this.code === '23505';\n }\n\n #columnsCache?: { [K in keyof T['shape']]?: true };\n get columns() {\n if (this.#columnsCache) return this.#columnsCache;\n\n const columns: { [K in keyof T['shape']]?: true } = {};\n\n if (this.detail) {\n const list = this.detail.match(/\\((.*)\\)=/)?.[1];\n if (list) {\n list.split(', ').forEach((item) => {\n const column = (\n item.startsWith('\"') ? item.slice(1, -1) : item\n ) as keyof T['shape'];\n\n const key =\n queryColumnNameToKey(this.getQuery(), column as string) ?? column;\n columns[key as keyof T['shape']] = true;\n });\n }\n }\n\n return (this.#columnsCache = columns);\n }\n}\n\nexport class MoreThanOneRowError extends OrchidOrmInternalError {\n constructor(query: IsQuery, message?: string) {\n super(query, message);\n }\n}\n\nexport class UnhandledTypeError extends OrchidOrmInternalError {\n constructor(query: IsQuery, value: never) {\n super(query, `Unhandled type: ${JSON.stringify(value)} received`);\n }\n}\n\n/**\n * Error thrown when attempting to nest SQL session scopes.\n * Nested withOptions/$withOptions calls that supply role or setConfig while an outer\n * scope already has SQL session state defined will throw this error.\n */\nexport class NestedSqlSessionError extends OrchidOrmInternalError {\n constructor(query: IsQuery) {\n super(\n query,\n 'Cannot nest SQL session scopes. Outer scope already has role or setConfig defined.',\n );\n }\n}\n"],"mappings":";AAKA,IAAsB,iBAAtB,cAA6C,MAAM"}
package/dist/public.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { Db, NotFoundError, OrchidOrmInternalError, Query, QueryError, QueryHelperResult, QuerySchema, copyTableData, createDbWithAdapter, getColumnInfo, testTransaction } from "./index.d.ts";
2
- export { Db, NotFoundError, OrchidOrmInternalError, type Query, QueryError, type QueryHelperResult, type QuerySchema, copyTableData, createDbWithAdapter, getColumnInfo, testTransaction };
1
+ import { Db, Expression, NotFoundError, OrchidOrmInternalError, Query, QueryError, QueryHelperResult, QuerySchema, copyTableData, createDbWithAdapter, getColumnInfo, isExpression, testTransaction } from "./index.d.ts";
2
+ export { Db, Expression, NotFoundError, OrchidOrmInternalError, type Query, QueryError, type QueryHelperResult, type QuerySchema, copyTableData, createDbWithAdapter, getColumnInfo, isExpression, testTransaction };
package/dist/public.js CHANGED
@@ -6,6 +6,12 @@ Object.defineProperty(exports, "Db", {
6
6
  return src_index_ts.Db;
7
7
  }
8
8
  });
9
+ Object.defineProperty(exports, "Expression", {
10
+ enumerable: true,
11
+ get: function() {
12
+ return src_index_ts.Expression;
13
+ }
14
+ });
9
15
  Object.defineProperty(exports, "NotFoundError", {
10
16
  enumerable: true,
11
17
  get: function() {
@@ -42,6 +48,12 @@ Object.defineProperty(exports, "getColumnInfo", {
42
48
  return src_index_ts.getColumnInfo;
43
49
  }
44
50
  });
51
+ Object.defineProperty(exports, "isExpression", {
52
+ enumerable: true,
53
+ get: function() {
54
+ return src_index_ts.isExpression;
55
+ }
56
+ });
45
57
  Object.defineProperty(exports, "testTransaction", {
46
58
  enumerable: true,
47
59
  get: function() {
package/dist/public.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { Db, NotFoundError, OrchidOrmInternalError, QueryError, copyTableData, createDbWithAdapter, getColumnInfo, testTransaction } from "./index.mjs";
2
- export { Db, NotFoundError, OrchidOrmInternalError, QueryError, copyTableData, createDbWithAdapter, getColumnInfo, testTransaction };
1
+ import { Db, Expression, NotFoundError, OrchidOrmInternalError, QueryError, copyTableData, createDbWithAdapter, getColumnInfo, isExpression, testTransaction } from "./index.mjs";
2
+ export { Db, Expression, NotFoundError, OrchidOrmInternalError, QueryError, copyTableData, createDbWithAdapter, getColumnInfo, isExpression, testTransaction };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pqb",
3
- "version": "0.66.0",
3
+ "version": "0.66.1",
4
4
  "description": "Postgres query builder",
5
5
  "keywords": [
6
6
  "pg",