@relq/orm 0.1.3 → 0.1.4
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/LICENSE +1 -1
- package/README.md +33 -224
- package/dist/cjs/addon/cursor.cjs +4 -3
- package/dist/cjs/addon/mysql2.cjs +21144 -0
- package/dist/cjs/addon/pg.cjs +4 -3
- package/dist/cjs/cache/query-cache.cjs +1 -4
- package/dist/cjs/core/cte/cte-accessor.cjs +80 -0
- package/dist/cjs/core/cte/cte-types.cjs +24 -0
- package/dist/cjs/core/cte/native-cte-builder.cjs +254 -0
- package/dist/cjs/core/helpers/index.cjs +14 -14
- package/dist/cjs/core/relq-base.cjs +4 -88
- package/dist/cjs/core/relq-client.cjs +52 -25
- package/dist/cjs/core/shared/column-mapping.cjs +1 -1
- package/dist/cjs/core/shared/table-accessor.cjs +1 -1
- package/dist/cjs/core/shared/where.cjs +15 -0
- package/dist/cjs/index.cjs +40 -5
- package/dist/cjs/mysql/clients/index.cjs +17 -0
- package/dist/cjs/mysql/clients/mariadb-client/capabilities.cjs +31 -0
- package/dist/cjs/mysql/clients/mariadb-client/index.cjs +7 -0
- package/dist/cjs/mysql/clients/mariadb-client/relq-mariadb.cjs +14 -0
- package/dist/cjs/mysql/clients/mysql-client/capabilities.cjs +31 -0
- package/dist/cjs/mysql/clients/mysql-client/index.cjs +7 -0
- package/dist/cjs/mysql/clients/mysql-client/relq-mysql.cjs +14 -0
- package/dist/cjs/mysql/clients/planetscale-client/capabilities.cjs +31 -0
- package/dist/cjs/mysql/clients/planetscale-client/index.cjs +7 -0
- package/dist/cjs/mysql/clients/planetscale-client/relq-planetscale.cjs +32 -0
- package/dist/cjs/mysql/clients/shared/index.cjs +32 -0
- package/dist/cjs/mysql/clients/shared/mysql-base.cjs +362 -0
- package/dist/cjs/mysql/clients/shared/mysql-dialect.cjs +141 -0
- package/dist/cjs/mysql/clients/shared/mysql-error-parser.cjs +195 -0
- package/dist/cjs/mysql/clients/shared/mysql-format.cjs +95 -0
- package/dist/cjs/mysql/clients/shared/mysql-type-coercion.cjs +14 -0
- package/dist/cjs/mysql/condition/condition-collector.cjs +377 -0
- package/dist/cjs/mysql/condition/fulltext-condition-builder.cjs +63 -0
- package/dist/cjs/mysql/condition/index.cjs +16 -0
- package/dist/cjs/mysql/condition/json-condition-builder.cjs +144 -0
- package/dist/cjs/mysql/condition/json-path-proxy.cjs +520 -0
- package/dist/cjs/mysql/count/count-builder.cjs +109 -0
- package/dist/cjs/mysql/count/index.cjs +5 -0
- package/dist/cjs/mysql/delete/delete-builder.cjs +105 -0
- package/dist/cjs/mysql/delete/index.cjs +5 -0
- package/dist/cjs/mysql/explain/explain-builder.cjs +43 -0
- package/dist/cjs/mysql/explain/index.cjs +5 -0
- package/dist/cjs/mysql/helpers/MysqlConnectedAggregateBuilder.cjs +132 -0
- package/dist/cjs/mysql/helpers/MysqlConnectedCountBuilder.cjs +83 -0
- package/dist/cjs/mysql/helpers/MysqlConnectedDeleteBuilder.cjs +91 -0
- package/dist/cjs/mysql/helpers/MysqlConnectedInsertBuilder.cjs +75 -0
- package/dist/cjs/mysql/helpers/MysqlConnectedInsertFromSelectBuilder.cjs +57 -0
- package/dist/cjs/mysql/helpers/MysqlConnectedQueryBuilder.cjs +141 -0
- package/dist/cjs/mysql/helpers/MysqlConnectedRawQueryBuilder.cjs +60 -0
- package/dist/cjs/mysql/helpers/MysqlConnectedSelectBuilder.cjs +398 -0
- package/dist/cjs/mysql/helpers/MysqlConnectedTransactionBuilder.cjs +128 -0
- package/dist/cjs/mysql/helpers/MysqlConnectedUpdateBuilder.cjs +92 -0
- package/dist/cjs/mysql/helpers/MysqlPaginateBuilder.cjs +186 -0
- package/dist/cjs/mysql/helpers/MysqlReturningExecutor.cjs +69 -0
- package/dist/cjs/mysql/helpers/index.cjs +45 -0
- package/dist/cjs/mysql/helpers/query-convenience.cjs +210 -0
- package/dist/cjs/mysql/helpers/select-joins.cjs +465 -0
- package/dist/cjs/mysql/helpers/select-pagination.cjs +190 -0
- package/dist/cjs/mysql/index.cjs +154 -0
- package/dist/cjs/mysql/insert/duplicate-key-builder.cjs +185 -0
- package/dist/cjs/mysql/insert/index.cjs +13 -0
- package/dist/cjs/mysql/insert/insert-builder.cjs +169 -0
- package/dist/cjs/mysql/insert/insert-from-select-builder.cjs +74 -0
- package/dist/cjs/mysql/raw/index.cjs +8 -0
- package/dist/cjs/mysql/raw/raw-query-builder.cjs +27 -0
- package/dist/cjs/mysql/raw/sql-template.cjs +65 -0
- package/dist/cjs/mysql/select/aggregate-builder.cjs +211 -0
- package/dist/cjs/mysql/select/index.cjs +32 -0
- package/dist/cjs/mysql/select/join-builder.cjs +206 -0
- package/dist/cjs/mysql/select/join-condition-builder.cjs +205 -0
- package/dist/cjs/mysql/select/join-internals.cjs +5 -0
- package/dist/cjs/mysql/select/scalar-query-builder.cjs +164 -0
- package/dist/cjs/mysql/select/scalar-select-builder.cjs +78 -0
- package/dist/cjs/mysql/select/select-builder.cjs +414 -0
- package/dist/cjs/mysql/select/sql-expression.cjs +56 -0
- package/dist/cjs/mysql/select/table-proxy.cjs +99 -0
- package/dist/cjs/mysql/shared/mysql-table-accessor.cjs +22 -0
- package/dist/cjs/mysql/transaction/index.cjs +6 -0
- package/dist/cjs/mysql/transaction/transaction-builder.cjs +64 -0
- package/dist/cjs/mysql/update/column-expression-builder.cjs +49 -0
- package/dist/cjs/mysql/update/index.cjs +7 -0
- package/dist/cjs/mysql/update/mysql-json-update-builder.cjs +200 -0
- package/dist/cjs/mysql/update/update-builder.cjs +167 -0
- package/dist/cjs/mysql/utils/addon/mysql/mysql2.cjs +23 -0
- package/dist/cjs/mysql/utils/fk-resolver.cjs +187 -0
- package/dist/cjs/mysql/utils/index.cjs +16 -0
- package/dist/cjs/mysql/utils/type-coercion.cjs +158 -0
- package/dist/cjs/mysql/window/index.cjs +5 -0
- package/dist/cjs/mysql/window/window-builder.cjs +80 -0
- package/dist/cjs/pg/clients/alloydb-client/capabilities.cjs +31 -0
- package/dist/cjs/pg/clients/alloydb-client/index.cjs +7 -0
- package/dist/cjs/pg/clients/alloydb-client/relq-alloydb.cjs +43 -0
- package/dist/cjs/pg/clients/aurora-client/capabilities.cjs +31 -0
- package/dist/cjs/pg/clients/aurora-client/index.cjs +7 -0
- package/dist/cjs/pg/clients/aurora-client/relq-aurora.cjs +43 -0
- package/dist/cjs/pg/clients/citus-client/capabilities.cjs +31 -0
- package/dist/cjs/pg/clients/citus-client/index.cjs +7 -0
- package/dist/cjs/pg/clients/citus-client/relq-citus.cjs +43 -0
- package/dist/cjs/pg/clients/neon-client/capabilities.cjs +31 -0
- package/dist/cjs/pg/clients/neon-client/index.cjs +7 -0
- package/dist/cjs/pg/clients/neon-client/relq-neon.cjs +43 -0
- package/dist/cjs/pg/clients/pg-client/relq-postgres.cjs +56 -0
- package/dist/cjs/{core/pg-family → pg/clients}/shared/pg-base.cjs +64 -7
- package/dist/cjs/{core/pg-family → pg/clients}/shared/pg-type-coercion.cjs +1 -1
- package/dist/cjs/pg/clients/supabase-client/capabilities.cjs +31 -0
- package/dist/cjs/pg/clients/supabase-client/index.cjs +7 -0
- package/dist/cjs/{core/pg-family/pg-client/relq-postgres.cjs → pg/clients/supabase-client/relq-supabase.cjs} +9 -9
- package/dist/cjs/pg/clients/timescale-client/capabilities.cjs +31 -0
- package/dist/cjs/pg/clients/timescale-client/index.cjs +7 -0
- package/dist/cjs/pg/clients/timescale-client/relq-timescale.cjs +43 -0
- package/dist/cjs/pg/clients/yugabytedb-client/capabilities.cjs +31 -0
- package/dist/cjs/pg/clients/yugabytedb-client/index.cjs +7 -0
- package/dist/cjs/pg/clients/yugabytedb-client/relq-yugabytedb.cjs +16 -0
- package/dist/cjs/{condition → pg/condition}/array-condition-builder.cjs +1 -1
- package/dist/cjs/pg/condition/array-path-proxy.cjs +379 -0
- package/dist/cjs/{condition → pg/condition}/condition-collector.cjs +18 -9
- package/dist/cjs/{condition → pg/condition}/fulltext-condition-builder.cjs +1 -1
- package/dist/cjs/{condition → pg/condition}/geometric-condition-builder.cjs +1 -1
- package/dist/cjs/pg/condition/json-path-proxy.cjs +480 -0
- package/dist/cjs/{condition → pg/condition}/jsonb-condition-builder.cjs +1 -1
- package/dist/cjs/{condition → pg/condition}/network-condition-builder.cjs +1 -1
- package/dist/cjs/{condition → pg/condition}/postgis-condition-builder.cjs +1 -1
- package/dist/cjs/{condition → pg/condition}/range-condition-builder.cjs +1 -1
- package/dist/cjs/{count → pg/count}/count-builder.cjs +10 -5
- package/dist/cjs/{delete → pg/delete}/delete-builder.cjs +10 -5
- package/dist/cjs/{core → pg}/helpers/ConnectedAggregateBuilder.cjs +16 -3
- package/dist/cjs/{core → pg}/helpers/ConnectedCountBuilder.cjs +16 -3
- package/dist/cjs/{core → pg}/helpers/ConnectedDeleteBuilder.cjs +27 -7
- package/dist/cjs/{core → pg}/helpers/ConnectedInsertBuilder.cjs +16 -8
- package/dist/cjs/{core → pg}/helpers/ConnectedInsertFromSelectBuilder.cjs +9 -5
- package/dist/cjs/{core → pg}/helpers/ConnectedQueryBuilder.cjs +14 -19
- package/dist/cjs/pg/helpers/ConnectedRawQueryBuilder.cjs +67 -0
- package/dist/cjs/{core → pg}/helpers/ConnectedSelectBuilder.cjs +121 -25
- package/dist/cjs/{core → pg}/helpers/ConnectedTransactionBuilder.cjs +34 -4
- package/dist/cjs/{core → pg}/helpers/ConnectedUpdateBuilder.cjs +27 -7
- package/dist/cjs/{core → pg}/helpers/PaginateBuilder.cjs +3 -3
- package/dist/cjs/{core → pg}/helpers/ReturningExecutor.cjs +3 -3
- package/dist/cjs/{core → pg}/helpers/query-convenience.cjs +11 -12
- package/dist/cjs/{core → pg}/helpers/select-joins.cjs +17 -14
- package/dist/cjs/{core → pg}/helpers/select-pagination.cjs +1 -1
- package/dist/cjs/{insert → pg/insert}/conflict-builder.cjs +2 -2
- package/dist/cjs/{insert → pg/insert}/insert-builder.cjs +8 -5
- package/dist/cjs/{insert → pg/insert}/insert-from-select-builder.cjs +1 -1
- package/dist/cjs/{pubsub → pg/pubsub}/listen-notify-builder.cjs +1 -1
- package/dist/cjs/{pubsub → pg/pubsub}/listener-connection.cjs +2 -2
- package/dist/cjs/{raw → pg/raw}/raw-query-builder.cjs +2 -2
- package/dist/cjs/{raw → pg/raw}/sql-template.cjs +1 -6
- package/dist/cjs/{select → pg/select}/aggregate-builder.cjs +10 -5
- package/dist/cjs/{select → pg/select}/join-builder.cjs +2 -2
- package/dist/cjs/{select → pg/select}/join-condition-builder.cjs +11 -1
- package/dist/cjs/{select → pg/select}/join-many-condition-builder.cjs +3 -4
- package/dist/cjs/{select → pg/select}/scalar-query-builder.cjs +31 -1
- package/dist/cjs/{select → pg/select}/scalar-select-builder.cjs +1 -1
- package/dist/cjs/{select → pg/select}/select-builder.cjs +40 -7
- package/dist/cjs/pg/select/sql-expression.cjs +56 -0
- package/dist/cjs/{transaction → pg/transaction}/transaction-builder.cjs +1 -1
- package/dist/cjs/{update → pg/update}/array-update-builder.cjs +2 -5
- package/dist/cjs/pg/update/column-expression-builder.cjs +49 -0
- package/dist/cjs/{update → pg/update}/jsonb-update-builder.cjs +1 -1
- package/dist/cjs/{update → pg/update}/update-builder.cjs +14 -7
- package/dist/cjs/{utils → pg/utils}/addon/pg/cursor.cjs +1 -1
- package/dist/cjs/{utils → pg/utils}/addon/pg/pg.cjs +2 -2
- package/dist/cjs/{utils → pg/utils}/fk-resolver.cjs +47 -30
- package/dist/cjs/{window → pg/window}/window-builder.cjs +1 -1
- package/dist/cjs/shared/errors/relq-errors.cjs +496 -35
- package/dist/cjs/shared/types/config-types.cjs +2 -2
- package/dist/cjs/utils/env-resolver.cjs +76 -13
- package/dist/cjs/utils/index.cjs +1 -1
- package/dist/esm/addon/cursor.js +4 -3
- package/dist/esm/addon/mysql2.js +21132 -0
- package/dist/esm/addon/pg.js +4 -3
- package/dist/esm/cache/query-cache.js +1 -4
- package/dist/esm/core/cte/cte-accessor.js +75 -0
- package/dist/esm/core/cte/cte-types.js +20 -0
- package/dist/esm/core/cte/native-cte-builder.js +250 -0
- package/dist/esm/core/helpers/index.js +12 -12
- package/dist/esm/core/relq-base.js +5 -56
- package/dist/esm/core/relq-client.js +44 -24
- package/dist/esm/core/shared/column-mapping.js +1 -1
- package/dist/esm/core/shared/table-accessor.js +1 -1
- package/dist/esm/core/shared/where.js +12 -0
- package/dist/esm/index.js +17 -5
- package/dist/esm/mysql/clients/index.js +5 -0
- package/dist/esm/mysql/clients/mariadb-client/capabilities.js +28 -0
- package/dist/esm/mysql/clients/mariadb-client/index.js +2 -0
- package/dist/esm/mysql/clients/mariadb-client/relq-mariadb.js +10 -0
- package/dist/esm/mysql/clients/mysql-client/capabilities.js +28 -0
- package/dist/esm/mysql/clients/mysql-client/index.js +2 -0
- package/dist/esm/mysql/clients/mysql-client/relq-mysql.js +10 -0
- package/dist/esm/mysql/clients/planetscale-client/capabilities.js +28 -0
- package/dist/esm/mysql/clients/planetscale-client/index.js +2 -0
- package/dist/esm/mysql/clients/planetscale-client/relq-planetscale.js +28 -0
- package/dist/esm/mysql/clients/shared/index.js +7 -0
- package/dist/esm/mysql/clients/shared/mysql-base.js +321 -0
- package/dist/esm/mysql/clients/shared/mysql-dialect.js +136 -0
- package/dist/esm/mysql/clients/shared/mysql-error-parser.js +188 -0
- package/dist/esm/mysql/clients/shared/mysql-format.js +92 -0
- package/dist/esm/mysql/clients/shared/mysql-type-coercion.js +6 -0
- package/dist/esm/mysql/condition/condition-collector.js +368 -0
- package/dist/esm/mysql/condition/fulltext-condition-builder.js +55 -0
- package/dist/esm/mysql/condition/index.js +4 -0
- package/dist/esm/mysql/condition/json-condition-builder.js +136 -0
- package/dist/esm/mysql/condition/json-path-proxy.js +513 -0
- package/dist/esm/mysql/count/count-builder.js +102 -0
- package/dist/esm/mysql/count/index.js +1 -0
- package/dist/esm/mysql/delete/delete-builder.js +98 -0
- package/dist/esm/mysql/delete/index.js +1 -0
- package/dist/esm/mysql/explain/explain-builder.js +39 -0
- package/dist/esm/mysql/explain/index.js +1 -0
- package/dist/esm/mysql/helpers/MysqlConnectedAggregateBuilder.js +128 -0
- package/dist/esm/{core/helpers/ConnectedCountBuilder.js → mysql/helpers/MysqlConnectedCountBuilder.js} +15 -5
- package/dist/esm/mysql/helpers/MysqlConnectedDeleteBuilder.js +87 -0
- package/dist/esm/mysql/helpers/MysqlConnectedInsertBuilder.js +71 -0
- package/dist/esm/mysql/helpers/MysqlConnectedInsertFromSelectBuilder.js +53 -0
- package/dist/esm/mysql/helpers/MysqlConnectedQueryBuilder.js +137 -0
- package/dist/esm/mysql/helpers/MysqlConnectedRawQueryBuilder.js +56 -0
- package/dist/esm/mysql/helpers/MysqlConnectedSelectBuilder.js +391 -0
- package/dist/esm/mysql/helpers/MysqlConnectedTransactionBuilder.js +123 -0
- package/dist/esm/mysql/helpers/MysqlConnectedUpdateBuilder.js +88 -0
- package/dist/esm/mysql/helpers/MysqlPaginateBuilder.js +182 -0
- package/dist/esm/mysql/helpers/MysqlReturningExecutor.js +65 -0
- package/dist/esm/mysql/helpers/index.js +15 -0
- package/dist/esm/mysql/helpers/query-convenience.js +199 -0
- package/dist/esm/mysql/helpers/select-joins.js +455 -0
- package/dist/esm/mysql/helpers/select-pagination.js +186 -0
- package/dist/esm/mysql/index.js +47 -0
- package/dist/esm/mysql/insert/duplicate-key-builder.js +174 -0
- package/dist/esm/mysql/insert/index.js +3 -0
- package/dist/esm/mysql/insert/insert-builder.js +162 -0
- package/dist/esm/mysql/insert/insert-from-select-builder.js +67 -0
- package/dist/esm/mysql/raw/index.js +2 -0
- package/dist/esm/mysql/raw/raw-query-builder.js +20 -0
- package/dist/esm/mysql/raw/sql-template.js +58 -0
- package/dist/esm/mysql/select/aggregate-builder.js +204 -0
- package/dist/esm/mysql/select/index.js +9 -0
- package/dist/esm/mysql/select/join-builder.js +198 -0
- package/dist/esm/mysql/select/join-condition-builder.js +197 -0
- package/dist/esm/mysql/select/join-internals.js +2 -0
- package/dist/esm/mysql/select/scalar-query-builder.js +156 -0
- package/dist/esm/mysql/select/scalar-select-builder.js +70 -0
- package/dist/esm/mysql/select/select-builder.js +407 -0
- package/dist/esm/mysql/select/sql-expression.js +51 -0
- package/dist/esm/mysql/select/table-proxy.js +91 -0
- package/dist/esm/mysql/shared/mysql-table-accessor.js +19 -0
- package/dist/esm/mysql/transaction/index.js +1 -0
- package/dist/esm/mysql/transaction/transaction-builder.js +56 -0
- package/dist/esm/mysql/update/column-expression-builder.js +42 -0
- package/dist/esm/mysql/update/index.js +2 -0
- package/dist/esm/mysql/update/mysql-json-update-builder.js +193 -0
- package/dist/esm/mysql/update/update-builder.js +160 -0
- package/dist/esm/mysql/utils/addon/mysql/mysql2.js +2 -0
- package/dist/esm/mysql/utils/fk-resolver.js +179 -0
- package/dist/esm/mysql/utils/index.js +2 -0
- package/dist/esm/mysql/utils/type-coercion.js +150 -0
- package/dist/esm/mysql/window/index.js +1 -0
- package/dist/esm/mysql/window/window-builder.js +73 -0
- package/dist/esm/pg/clients/alloydb-client/capabilities.js +28 -0
- package/dist/esm/pg/clients/alloydb-client/index.js +2 -0
- package/dist/esm/{core/pg-family/pg-client/relq-postgres.js → pg/clients/alloydb-client/relq-alloydb.js} +8 -8
- package/dist/esm/pg/clients/aurora-client/capabilities.js +28 -0
- package/dist/esm/pg/clients/aurora-client/index.js +2 -0
- package/dist/esm/pg/clients/aurora-client/relq-aurora.js +39 -0
- package/dist/esm/pg/clients/citus-client/capabilities.js +28 -0
- package/dist/esm/pg/clients/citus-client/index.js +2 -0
- package/dist/esm/pg/clients/citus-client/relq-citus.js +39 -0
- package/dist/esm/pg/clients/neon-client/capabilities.js +28 -0
- package/dist/esm/pg/clients/neon-client/index.js +2 -0
- package/dist/esm/pg/clients/neon-client/relq-neon.js +39 -0
- package/dist/esm/pg/clients/pg-client/relq-postgres.js +52 -0
- package/dist/esm/{core/pg-family → pg/clients}/shared/pg-base.js +64 -7
- package/dist/esm/{core/pg-family → pg/clients}/shared/pg-type-coercion.js +1 -1
- package/dist/esm/pg/clients/supabase-client/capabilities.js +28 -0
- package/dist/esm/pg/clients/supabase-client/index.js +2 -0
- package/dist/esm/pg/clients/supabase-client/relq-supabase.js +39 -0
- package/dist/esm/pg/clients/timescale-client/capabilities.js +28 -0
- package/dist/esm/pg/clients/timescale-client/index.js +2 -0
- package/dist/esm/pg/clients/timescale-client/relq-timescale.js +39 -0
- package/dist/esm/pg/clients/yugabytedb-client/capabilities.js +28 -0
- package/dist/esm/pg/clients/yugabytedb-client/index.js +2 -0
- package/dist/esm/pg/clients/yugabytedb-client/relq-yugabytedb.js +12 -0
- package/dist/esm/{condition → pg/condition}/array-condition-builder.js +1 -1
- package/dist/esm/pg/condition/array-path-proxy.js +372 -0
- package/dist/esm/{condition → pg/condition}/condition-collector.js +20 -11
- package/dist/esm/{condition → pg/condition}/fulltext-condition-builder.js +1 -1
- package/dist/esm/{condition → pg/condition}/geometric-condition-builder.js +1 -1
- package/dist/esm/pg/condition/json-path-proxy.js +473 -0
- package/dist/esm/{condition → pg/condition}/jsonb-condition-builder.js +1 -1
- package/dist/esm/{condition → pg/condition}/network-condition-builder.js +1 -1
- package/dist/esm/{condition → pg/condition}/postgis-condition-builder.js +1 -1
- package/dist/esm/{condition → pg/condition}/range-condition-builder.js +1 -1
- package/dist/esm/{count → pg/count}/count-builder.js +10 -5
- package/dist/esm/{delete → pg/delete}/delete-builder.js +10 -5
- package/dist/esm/{core → pg}/helpers/ConnectedAggregateBuilder.js +16 -3
- package/dist/esm/pg/helpers/ConnectedCountBuilder.js +82 -0
- package/dist/esm/{core → pg}/helpers/ConnectedDeleteBuilder.js +27 -7
- package/dist/esm/{core → pg}/helpers/ConnectedInsertBuilder.js +16 -8
- package/dist/esm/{core → pg}/helpers/ConnectedInsertFromSelectBuilder.js +9 -5
- package/dist/esm/{core → pg}/helpers/ConnectedQueryBuilder.js +15 -20
- package/dist/esm/pg/helpers/ConnectedRawQueryBuilder.js +63 -0
- package/dist/esm/{core → pg}/helpers/ConnectedSelectBuilder.js +118 -25
- package/dist/esm/{core → pg}/helpers/ConnectedTransactionBuilder.js +34 -4
- package/dist/esm/{core → pg}/helpers/ConnectedUpdateBuilder.js +27 -7
- package/dist/esm/{core → pg}/helpers/PaginateBuilder.js +3 -3
- package/dist/esm/{core → pg}/helpers/ReturningExecutor.js +3 -3
- package/dist/esm/{core → pg}/helpers/query-convenience.js +11 -12
- package/dist/esm/{core → pg}/helpers/select-joins.js +18 -15
- package/dist/esm/{core → pg}/helpers/select-pagination.js +1 -1
- package/dist/esm/{insert → pg/insert}/conflict-builder.js +2 -2
- package/dist/esm/{insert → pg/insert}/insert-builder.js +8 -5
- package/dist/esm/{insert → pg/insert}/insert-from-select-builder.js +1 -1
- package/dist/esm/{pubsub → pg/pubsub}/listen-notify-builder.js +1 -1
- package/dist/esm/{pubsub → pg/pubsub}/listener-connection.js +2 -2
- package/dist/esm/{raw → pg/raw}/raw-query-builder.js +2 -2
- package/dist/esm/{raw → pg/raw}/sql-template.js +1 -6
- package/dist/esm/{select → pg/select}/aggregate-builder.js +10 -5
- package/dist/esm/{select → pg/select}/join-builder.js +2 -2
- package/dist/esm/{select → pg/select}/join-condition-builder.js +11 -1
- package/dist/esm/{select → pg/select}/join-many-condition-builder.js +3 -4
- package/dist/esm/{select → pg/select}/scalar-query-builder.js +31 -1
- package/dist/esm/{select → pg/select}/scalar-select-builder.js +1 -1
- package/dist/esm/{select → pg/select}/select-builder.js +40 -7
- package/dist/esm/pg/select/sql-expression.js +51 -0
- package/dist/esm/{transaction → pg/transaction}/transaction-builder.js +1 -1
- package/dist/esm/{update → pg/update}/array-update-builder.js +2 -5
- package/dist/esm/pg/update/column-expression-builder.js +42 -0
- package/dist/esm/{update → pg/update}/jsonb-update-builder.js +1 -1
- package/dist/esm/{update → pg/update}/update-builder.js +14 -7
- package/dist/esm/pg/utils/addon/pg/cursor.js +1 -0
- package/dist/esm/pg/utils/addon/pg/pg.js +2 -0
- package/dist/esm/{utils → pg/utils}/fk-resolver.js +47 -30
- package/dist/esm/{window → pg/window}/window-builder.js +1 -1
- package/dist/esm/shared/errors/relq-errors.js +486 -34
- package/dist/esm/shared/types/config-types.js +2 -2
- package/dist/esm/utils/env-resolver.js +74 -13
- package/dist/esm/utils/index.js +1 -1
- package/dist/index.d.ts +9629 -3974
- package/package.json +5 -3
- package/dist/cjs/core/helpers/ConnectedCTEBuilder.cjs +0 -53
- package/dist/cjs/core/helpers/ConnectedRawQueryBuilder.cjs +0 -46
- package/dist/cjs/select/sql-expression.cjs +0 -38
- package/dist/esm/core/helpers/ConnectedCTEBuilder.js +0 -49
- package/dist/esm/core/helpers/ConnectedRawQueryBuilder.js +0 -42
- package/dist/esm/select/sql-expression.js +0 -33
- package/dist/esm/utils/addon/pg/cursor.js +0 -1
- package/dist/esm/utils/addon/pg/pg.js +0 -2
- /package/dist/cjs/{core/pg-family → pg/clients}/cockroachdb-client/capabilities.cjs +0 -0
- /package/dist/cjs/{core/pg-family → pg/clients}/cockroachdb-client/index.cjs +0 -0
- /package/dist/cjs/{core/pg-family → pg/clients}/cockroachdb-client/relq-cockroach.cjs +0 -0
- /package/dist/cjs/{core/pg-family → pg/clients}/dsql-client/capabilities.cjs +0 -0
- /package/dist/cjs/{core/pg-family → pg/clients}/dsql-client/index.cjs +0 -0
- /package/dist/cjs/{core/pg-family → pg/clients}/dsql-client/relq-dsql.cjs +0 -0
- /package/dist/cjs/{core/pg-family → pg/clients}/index.cjs +0 -0
- /package/dist/cjs/{core/pg-family → pg/clients}/nile-client/capabilities.cjs +0 -0
- /package/dist/cjs/{core/pg-family → pg/clients}/nile-client/index.cjs +0 -0
- /package/dist/cjs/{core/pg-family → pg/clients}/nile-client/relq-nile.cjs +0 -0
- /package/dist/cjs/{core/pg-family → pg/clients}/nile-client/tenant-context.cjs +0 -0
- /package/dist/cjs/{core/pg-family → pg/clients}/pg-client/capabilities.cjs +0 -0
- /package/dist/cjs/{core/pg-family → pg/clients}/pg-client/index.cjs +0 -0
- /package/dist/cjs/{core/pg-family → pg/clients}/shared/pg-dialect.cjs +0 -0
- /package/dist/cjs/{core/pg-family → pg/clients}/shared/pg-error-parser.cjs +0 -0
- /package/dist/cjs/{condition → pg/condition}/array-numeric-condition-builder.cjs +0 -0
- /package/dist/cjs/{condition → pg/condition}/array-specialized-condition-builder.cjs +0 -0
- /package/dist/cjs/{condition → pg/condition}/array-string-condition-builder.cjs +0 -0
- /package/dist/cjs/{condition → pg/condition}/index.cjs +0 -0
- /package/dist/cjs/{count → pg/count}/index.cjs +0 -0
- /package/dist/cjs/{delete → pg/delete}/index.cjs +0 -0
- /package/dist/cjs/{explain → pg/explain}/explain-builder.cjs +0 -0
- /package/dist/cjs/{explain → pg/explain}/index.cjs +0 -0
- /package/dist/cjs/{insert → pg/insert}/index.cjs +0 -0
- /package/dist/cjs/{pubsub → pg/pubsub}/index.cjs +0 -0
- /package/dist/cjs/{raw → pg/raw}/index.cjs +0 -0
- /package/dist/cjs/{select → pg/select}/index.cjs +0 -0
- /package/dist/cjs/{select → pg/select}/join-internals.cjs +0 -0
- /package/dist/cjs/{select → pg/select}/table-proxy.cjs +0 -0
- /package/dist/cjs/{transaction → pg/transaction}/index.cjs +0 -0
- /package/dist/cjs/{update → pg/update}/index.cjs +0 -0
- /package/dist/cjs/{utils → pg/utils}/type-coercion.cjs +0 -0
- /package/dist/cjs/{window → pg/window}/index.cjs +0 -0
- /package/dist/esm/{core/pg-family → pg/clients}/cockroachdb-client/capabilities.js +0 -0
- /package/dist/esm/{core/pg-family → pg/clients}/cockroachdb-client/index.js +0 -0
- /package/dist/esm/{core/pg-family → pg/clients}/cockroachdb-client/relq-cockroach.js +0 -0
- /package/dist/esm/{core/pg-family → pg/clients}/dsql-client/capabilities.js +0 -0
- /package/dist/esm/{core/pg-family → pg/clients}/dsql-client/index.js +0 -0
- /package/dist/esm/{core/pg-family → pg/clients}/dsql-client/relq-dsql.js +0 -0
- /package/dist/esm/{core/pg-family → pg/clients}/index.js +0 -0
- /package/dist/esm/{core/pg-family → pg/clients}/nile-client/capabilities.js +0 -0
- /package/dist/esm/{core/pg-family → pg/clients}/nile-client/index.js +0 -0
- /package/dist/esm/{core/pg-family → pg/clients}/nile-client/relq-nile.js +0 -0
- /package/dist/esm/{core/pg-family → pg/clients}/nile-client/tenant-context.js +0 -0
- /package/dist/esm/{core/pg-family → pg/clients}/pg-client/capabilities.js +0 -0
- /package/dist/esm/{core/pg-family → pg/clients}/pg-client/index.js +0 -0
- /package/dist/esm/{core/pg-family → pg/clients}/shared/pg-dialect.js +0 -0
- /package/dist/esm/{core/pg-family → pg/clients}/shared/pg-error-parser.js +0 -0
- /package/dist/esm/{condition → pg/condition}/array-numeric-condition-builder.js +0 -0
- /package/dist/esm/{condition → pg/condition}/array-specialized-condition-builder.js +0 -0
- /package/dist/esm/{condition → pg/condition}/array-string-condition-builder.js +0 -0
- /package/dist/esm/{condition → pg/condition}/index.js +0 -0
- /package/dist/esm/{count → pg/count}/index.js +0 -0
- /package/dist/esm/{delete → pg/delete}/index.js +0 -0
- /package/dist/esm/{explain → pg/explain}/explain-builder.js +0 -0
- /package/dist/esm/{explain → pg/explain}/index.js +0 -0
- /package/dist/esm/{insert → pg/insert}/index.js +0 -0
- /package/dist/esm/{pubsub → pg/pubsub}/index.js +0 -0
- /package/dist/esm/{raw → pg/raw}/index.js +0 -0
- /package/dist/esm/{select → pg/select}/index.js +0 -0
- /package/dist/esm/{select → pg/select}/join-internals.js +0 -0
- /package/dist/esm/{select → pg/select}/table-proxy.js +0 -0
- /package/dist/esm/{transaction → pg/transaction}/index.js +0 -0
- /package/dist/esm/{update → pg/update}/index.js +0 -0
- /package/dist/esm/{utils → pg/utils}/type-coercion.js +0 -0
- /package/dist/esm/{window → pg/window}/index.js +0 -0
|
@@ -44,34 +44,93 @@ export function setupErrorHandler() {
|
|
|
44
44
|
process.exit();
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
+
const ORIGINAL_ERROR = Symbol('relq-original-error');
|
|
48
|
+
let _errorHandlerInstalled = false;
|
|
49
|
+
function _autoInstallErrorHandler() {
|
|
50
|
+
if (_errorHandlerInstalled)
|
|
51
|
+
return;
|
|
52
|
+
_errorHandlerInstalled = true;
|
|
53
|
+
if (typeof process === 'undefined' || !process.on)
|
|
54
|
+
return;
|
|
55
|
+
const formatRelqError = (error) => {
|
|
56
|
+
const lines = [
|
|
57
|
+
'',
|
|
58
|
+
` \x1b[1m\x1b[31m${error.name}\x1b[0m: ${error.message}`,
|
|
59
|
+
];
|
|
60
|
+
const props = error._getInspectProps?.() || {};
|
|
61
|
+
for (const [key, value] of Object.entries(props)) {
|
|
62
|
+
if (value === undefined)
|
|
63
|
+
continue;
|
|
64
|
+
const strVal = typeof value === 'string' ? value : JSON.stringify(value);
|
|
65
|
+
lines.push(` \x1b[2m${key.padStart(16)}:\x1b[0m ${strVal}`);
|
|
66
|
+
}
|
|
67
|
+
lines.push(` \x1b[2m timestamp:\x1b[0m ${error.timestamp.toISOString()}`);
|
|
68
|
+
lines.push('');
|
|
69
|
+
return lines.join('\n');
|
|
70
|
+
};
|
|
71
|
+
process.on('uncaughtException', (error) => {
|
|
72
|
+
if (error instanceof RelqError) {
|
|
73
|
+
console.error(formatRelqError(error));
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
console.error(`${error.name || 'Error'}: ${error.message}`);
|
|
77
|
+
if (error.stack) {
|
|
78
|
+
const stackLines = error.stack.split('\n').filter((line) => line.trim().startsWith('at '));
|
|
79
|
+
console.error(stackLines.slice(0, 5).join('\n'));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
process.exit(1);
|
|
83
|
+
});
|
|
84
|
+
process.on('unhandledRejection', (reason) => {
|
|
85
|
+
if (reason instanceof RelqError) {
|
|
86
|
+
console.error(formatRelqError(reason));
|
|
87
|
+
}
|
|
88
|
+
else if (reason instanceof Error) {
|
|
89
|
+
console.error(`${reason.name || 'Error'}: ${reason.message}`);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
console.error('Unhandled rejection:', reason);
|
|
93
|
+
}
|
|
94
|
+
process.exit(1);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
47
97
|
export class RelqError extends Error {
|
|
48
98
|
name;
|
|
49
|
-
cause;
|
|
50
99
|
timestamp;
|
|
51
100
|
constructor(message, cause) {
|
|
52
101
|
super(message);
|
|
53
102
|
this.name = 'RelqError';
|
|
54
|
-
this
|
|
103
|
+
Object.defineProperty(this, ORIGINAL_ERROR, {
|
|
104
|
+
value: cause,
|
|
105
|
+
enumerable: false,
|
|
106
|
+
writable: false,
|
|
107
|
+
});
|
|
55
108
|
this.timestamp = new Date();
|
|
109
|
+
_autoInstallErrorHandler();
|
|
56
110
|
if (Error.captureStackTrace) {
|
|
57
111
|
Error.captureStackTrace(this, this.constructor);
|
|
58
112
|
}
|
|
113
|
+
if (this.stack) {
|
|
114
|
+
const lines = this.stack.split('\n');
|
|
115
|
+
this.stack = lines.filter(line => line.includes(this.name) ||
|
|
116
|
+
line.trim().startsWith('at ') ||
|
|
117
|
+
line.trim() === '').slice(0, 8).join('\n');
|
|
118
|
+
}
|
|
59
119
|
}
|
|
60
120
|
[Symbol.for('nodejs.util.inspect.custom')](_depth, _options) {
|
|
61
121
|
const lines = [
|
|
62
|
-
|
|
63
|
-
`
|
|
122
|
+
'',
|
|
123
|
+
` \x1b[1m\x1b[31m${this.name}\x1b[0m: ${this.message}`,
|
|
64
124
|
];
|
|
65
125
|
const props = this._getInspectProps();
|
|
66
126
|
for (const [key, value] of Object.entries(props)) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const stackLines = this.stack.split('\n').filter(line => line.trim().startsWith('at ') || line.includes(this.name));
|
|
72
|
-
lines.push('');
|
|
73
|
-
lines.push(...stackLines.slice(1, 6));
|
|
127
|
+
if (value === undefined)
|
|
128
|
+
continue;
|
|
129
|
+
const strVal = typeof value === 'string' ? value : JSON.stringify(value);
|
|
130
|
+
lines.push(` \x1b[2m${key.padStart(16)}:\x1b[0m ${strVal}`);
|
|
74
131
|
}
|
|
132
|
+
lines.push(` \x1b[2m timestamp:\x1b[0m ${this.timestamp.toISOString()}`);
|
|
133
|
+
lines.push('');
|
|
75
134
|
return lines.join('\n');
|
|
76
135
|
}
|
|
77
136
|
_getInspectProps() {
|
|
@@ -81,12 +140,14 @@ export class RelqError extends Error {
|
|
|
81
140
|
return {
|
|
82
141
|
name: this.name,
|
|
83
142
|
message: this.message,
|
|
84
|
-
cause: this.cause?.message,
|
|
85
143
|
timestamp: this.timestamp.toISOString(),
|
|
86
|
-
|
|
144
|
+
...this._getInspectProps(),
|
|
87
145
|
};
|
|
88
146
|
}
|
|
89
147
|
}
|
|
148
|
+
export function getOriginalError(error) {
|
|
149
|
+
return error[ORIGINAL_ERROR];
|
|
150
|
+
}
|
|
90
151
|
export class RelqConnectionError extends RelqError {
|
|
91
152
|
name = 'RelqConnectionError';
|
|
92
153
|
code;
|
|
@@ -262,9 +323,139 @@ export class RelqBuilderError extends RelqError {
|
|
|
262
323
|
};
|
|
263
324
|
}
|
|
264
325
|
}
|
|
326
|
+
export class RelqConstraintError extends RelqError {
|
|
327
|
+
name = 'RelqConstraintError';
|
|
328
|
+
constraintType;
|
|
329
|
+
table;
|
|
330
|
+
column;
|
|
331
|
+
constraint;
|
|
332
|
+
value;
|
|
333
|
+
sql;
|
|
334
|
+
code;
|
|
335
|
+
detail;
|
|
336
|
+
retryable = false;
|
|
337
|
+
constructor(message, constraintType, options) {
|
|
338
|
+
super(message, options?.cause);
|
|
339
|
+
this.constraintType = constraintType;
|
|
340
|
+
this.table = options?.table;
|
|
341
|
+
this.column = options?.column;
|
|
342
|
+
this.constraint = options?.constraint;
|
|
343
|
+
this.value = options?.value;
|
|
344
|
+
this.sql = options?.sql;
|
|
345
|
+
this.code = options?.code;
|
|
346
|
+
this.detail = options?.detail;
|
|
347
|
+
}
|
|
348
|
+
_getInspectProps() {
|
|
349
|
+
return {
|
|
350
|
+
constraintType: this.constraintType,
|
|
351
|
+
table: this.table,
|
|
352
|
+
column: this.column,
|
|
353
|
+
constraint: this.constraint,
|
|
354
|
+
value: this.value,
|
|
355
|
+
code: this.code,
|
|
356
|
+
detail: this.detail,
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
toJSON() {
|
|
360
|
+
return {
|
|
361
|
+
...super.toJSON(),
|
|
362
|
+
constraintType: this.constraintType,
|
|
363
|
+
table: this.table,
|
|
364
|
+
column: this.column,
|
|
365
|
+
constraint: this.constraint,
|
|
366
|
+
value: this.value,
|
|
367
|
+
sql: this.sql,
|
|
368
|
+
code: this.code,
|
|
369
|
+
detail: this.detail,
|
|
370
|
+
retryable: this.retryable,
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
export class RelqSchemaError extends RelqError {
|
|
375
|
+
name = 'RelqSchemaError';
|
|
376
|
+
schemaObject;
|
|
377
|
+
objectName;
|
|
378
|
+
table;
|
|
379
|
+
sql;
|
|
380
|
+
code;
|
|
381
|
+
hint;
|
|
382
|
+
constructor(message, schemaObject, options) {
|
|
383
|
+
super(message, options?.cause);
|
|
384
|
+
this.schemaObject = schemaObject;
|
|
385
|
+
this.objectName = options?.objectName;
|
|
386
|
+
this.table = options?.table;
|
|
387
|
+
this.sql = options?.sql;
|
|
388
|
+
this.code = options?.code;
|
|
389
|
+
this.hint = options?.hint;
|
|
390
|
+
}
|
|
391
|
+
_getInspectProps() {
|
|
392
|
+
return { schemaObject: this.schemaObject, objectName: this.objectName, table: this.table, code: this.code, hint: this.hint };
|
|
393
|
+
}
|
|
394
|
+
toJSON() {
|
|
395
|
+
return { ...super.toJSON(), schemaObject: this.schemaObject, objectName: this.objectName, table: this.table, sql: this.sql, code: this.code, hint: this.hint };
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
export class RelqDataError extends RelqError {
|
|
399
|
+
name = 'RelqDataError';
|
|
400
|
+
dataIssue;
|
|
401
|
+
column;
|
|
402
|
+
table;
|
|
403
|
+
value;
|
|
404
|
+
dataType;
|
|
405
|
+
sql;
|
|
406
|
+
code;
|
|
407
|
+
constructor(message, dataIssue, options) {
|
|
408
|
+
super(message, options?.cause);
|
|
409
|
+
this.dataIssue = dataIssue;
|
|
410
|
+
this.column = options?.column;
|
|
411
|
+
this.table = options?.table;
|
|
412
|
+
this.value = options?.value;
|
|
413
|
+
this.dataType = options?.dataType;
|
|
414
|
+
this.sql = options?.sql;
|
|
415
|
+
this.code = options?.code;
|
|
416
|
+
}
|
|
417
|
+
_getInspectProps() {
|
|
418
|
+
return { dataIssue: this.dataIssue, column: this.column, table: this.table, dataType: this.dataType, code: this.code };
|
|
419
|
+
}
|
|
420
|
+
toJSON() {
|
|
421
|
+
return { ...super.toJSON(), dataIssue: this.dataIssue, column: this.column, table: this.table, value: this.value, dataType: this.dataType, sql: this.sql, code: this.code };
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
export class RelqLockError extends RelqError {
|
|
425
|
+
name = 'RelqLockError';
|
|
426
|
+
lockIssue;
|
|
427
|
+
sql;
|
|
428
|
+
code;
|
|
429
|
+
retryable;
|
|
430
|
+
constructor(message, lockIssue, options) {
|
|
431
|
+
super(message, options?.cause);
|
|
432
|
+
this.lockIssue = lockIssue;
|
|
433
|
+
this.sql = options?.sql;
|
|
434
|
+
this.code = options?.code;
|
|
435
|
+
this.retryable = lockIssue === 'deadlock' || lockIssue === 'serialization_failure';
|
|
436
|
+
}
|
|
437
|
+
_getInspectProps() {
|
|
438
|
+
return { lockIssue: this.lockIssue, retryable: this.retryable, code: this.code };
|
|
439
|
+
}
|
|
440
|
+
toJSON() {
|
|
441
|
+
return { ...super.toJSON(), lockIssue: this.lockIssue, sql: this.sql, code: this.code, retryable: this.retryable };
|
|
442
|
+
}
|
|
443
|
+
}
|
|
265
444
|
export function isRelqError(error) {
|
|
266
445
|
return error instanceof RelqError;
|
|
267
446
|
}
|
|
447
|
+
export function isRelqConstraintError(error) {
|
|
448
|
+
return error instanceof RelqConstraintError;
|
|
449
|
+
}
|
|
450
|
+
export function isRelqSchemaError(error) {
|
|
451
|
+
return error instanceof RelqSchemaError;
|
|
452
|
+
}
|
|
453
|
+
export function isRelqDataError(error) {
|
|
454
|
+
return error instanceof RelqDataError;
|
|
455
|
+
}
|
|
456
|
+
export function isRelqLockError(error) {
|
|
457
|
+
return error instanceof RelqLockError;
|
|
458
|
+
}
|
|
268
459
|
export function isRelqConnectionError(error) {
|
|
269
460
|
return error instanceof RelqConnectionError;
|
|
270
461
|
}
|
|
@@ -287,48 +478,309 @@ export function wrapError(error, context) {
|
|
|
287
478
|
: String(error);
|
|
288
479
|
return new RelqError(message);
|
|
289
480
|
}
|
|
290
|
-
export function parsePostgresError(error, sql) {
|
|
481
|
+
export function parsePostgresError(error, sql, isBuilder = true) {
|
|
291
482
|
const message = error.message || 'Database error';
|
|
292
483
|
const code = error.code;
|
|
293
484
|
if (isNetworkErrorCode(code)) {
|
|
294
485
|
return new RelqConnectionError(message, {
|
|
295
|
-
cause: error,
|
|
296
|
-
code,
|
|
297
|
-
host: error.hostname || error.address,
|
|
298
|
-
port: error.port
|
|
486
|
+
cause: error, code, host: error.hostname || error.address, port: error.port
|
|
299
487
|
});
|
|
300
488
|
}
|
|
301
|
-
if (code === '57P01' || code === '57P03' || code === '08006' || code === '08001' || code === '08004') {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
489
|
+
if (code === '57P01' || code === '57P03' || code === '08006' || code === '08001' || code === '08004' || code === '08000' || code === '08003') {
|
|
490
|
+
const friendlyMessages = {
|
|
491
|
+
'57P01': 'Database server is shutting down.',
|
|
492
|
+
'57P03': 'Database server is starting up — try again in a moment.',
|
|
493
|
+
'08006': 'Connection to database was lost during the query.',
|
|
494
|
+
'08001': 'Cannot connect to database server. Check your host, port, and credentials.',
|
|
495
|
+
'08004': 'Database server rejected the connection. You may have reached the connection limit.',
|
|
496
|
+
'08000': 'Database connection failed.',
|
|
497
|
+
'08003': 'Database connection does not exist. The connection may have been dropped.',
|
|
498
|
+
};
|
|
499
|
+
return new RelqConnectionError(friendlyMessages[code] || message, {
|
|
500
|
+
cause: error, code, host: error.hostname, port: error.port
|
|
307
501
|
});
|
|
308
502
|
}
|
|
503
|
+
if (code === '53300') {
|
|
504
|
+
return new RelqConnectionError('Too many database connections. The server has reached its connection limit. Try again later or increase max_connections.', { cause: error, code });
|
|
505
|
+
}
|
|
309
506
|
if (code === '57014') {
|
|
310
|
-
return new RelqTimeoutError('Query execution timed out', error.timeout || 0, 'query', error);
|
|
507
|
+
return new RelqTimeoutError('Query execution timed out.', error.timeout || 0, 'query', error);
|
|
311
508
|
}
|
|
312
509
|
if (message.includes('timeout exceeded when trying to connect')) {
|
|
313
|
-
return new RelqTimeoutError('Connection timed out', error.timeout || 0, 'connection', error);
|
|
510
|
+
return new RelqTimeoutError('Connection timed out.', error.timeout || 0, 'connection', error);
|
|
314
511
|
}
|
|
315
512
|
if (!code && (message.includes('Connection terminated') ||
|
|
316
513
|
message.includes('connection is closed') ||
|
|
317
514
|
message.includes('Client has encountered a connection error'))) {
|
|
318
515
|
return new RelqConnectionError(message, {
|
|
319
|
-
cause: error,
|
|
320
|
-
|
|
321
|
-
|
|
516
|
+
cause: error, host: error.hostname || error.address, port: error.port
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
if (!isBuilder) {
|
|
520
|
+
return new RelqQueryError(message, { cause: error, sql, code, detail: error.detail, hint: error.hint });
|
|
521
|
+
}
|
|
522
|
+
if (code === '23505') {
|
|
523
|
+
const valueMatch = error.detail?.match(/Key \((.+?)\)=\((.+?)\) already exists/);
|
|
524
|
+
const col = valueMatch?.[1] || error.column;
|
|
525
|
+
const val = valueMatch?.[2];
|
|
526
|
+
return new RelqConstraintError(`Duplicate value: A record with this ${col || 'value'} already exists.${val ? ` Value: "${val}".` : ''}${error.constraint ? ` Constraint: "${error.constraint}".` : ''}`, 'unique', { cause: error, table: error.table, column: col, constraint: error.constraint, value: val, sql, code, detail: error.detail });
|
|
527
|
+
}
|
|
528
|
+
if (code === '23503') {
|
|
529
|
+
const isDelete = error.detail?.includes('is still referenced from table');
|
|
530
|
+
const refMatch = error.detail?.match(/(?:table|from table) "(\w+)"/);
|
|
531
|
+
const refTable = refMatch?.[1];
|
|
532
|
+
const msg = isDelete
|
|
533
|
+
? `Cannot delete: This record is still referenced by "${refTable || 'another table'}".${error.constraint ? ` Constraint: "${error.constraint}".` : ''}`
|
|
534
|
+
: `Referenced record not found: The value you're inserting references a record in "${refTable || 'another table'}" that doesn't exist.${error.constraint ? ` Constraint: "${error.constraint}".` : ''}`;
|
|
535
|
+
return new RelqConstraintError(msg, 'foreign_key', {
|
|
536
|
+
cause: error, table: error.table, constraint: error.constraint, sql, code, detail: error.detail
|
|
322
537
|
});
|
|
323
538
|
}
|
|
539
|
+
if (code === '23502') {
|
|
540
|
+
return new RelqConstraintError(`Required field missing: Column "${error.column || 'unknown'}" on table "${error.table || 'unknown'}" cannot be NULL. Provide a value or set a default in your schema.`, 'not_null', { cause: error, table: error.table, column: error.column, sql, code, detail: error.detail });
|
|
541
|
+
}
|
|
542
|
+
if (code === '23514') {
|
|
543
|
+
return new RelqConstraintError(`Check constraint failed: "${error.constraint || 'unknown'}" on table "${error.table || 'unknown'}". The value doesn't satisfy the validation rule.`, 'check', { cause: error, table: error.table, constraint: error.constraint, sql, code, detail: error.detail });
|
|
544
|
+
}
|
|
545
|
+
if (code === '23P01') {
|
|
546
|
+
return new RelqConstraintError(`Exclusion constraint failed: "${error.constraint || 'unknown'}" on table "${error.table || 'unknown'}". A conflicting record exists.`, 'exclusion', { cause: error, table: error.table, constraint: error.constraint, sql, code, detail: error.detail });
|
|
547
|
+
}
|
|
548
|
+
if (code === '23001') {
|
|
549
|
+
return new RelqConstraintError(`Restrict violation: Cannot delete or update — a RESTRICT constraint prevents this operation.`, 'restrict', { cause: error, table: error.table, constraint: error.constraint, sql, code, detail: error.detail });
|
|
550
|
+
}
|
|
551
|
+
if (code === '23000') {
|
|
552
|
+
return new RelqConstraintError(`Integrity constraint violation: ${error.detail || message}.${error.constraint ? ` Constraint: "${error.constraint}".` : ''}`, 'unique', { cause: error, table: error.table, constraint: error.constraint, sql, code, detail: error.detail });
|
|
553
|
+
}
|
|
554
|
+
if (code === '40003') {
|
|
555
|
+
return new RelqLockError('Ambiguous result: The transaction outcome is unknown (network issue during COMMIT). Check if the transaction was applied and retry if needed.', 'serialization_failure', { cause: error, sql, code });
|
|
556
|
+
}
|
|
557
|
+
if (code === '40P01') {
|
|
558
|
+
return new RelqLockError('Deadlock detected: Two transactions are waiting for each other. Retry the transaction.', 'deadlock', { cause: error, sql, code });
|
|
559
|
+
}
|
|
560
|
+
if (code === '40001') {
|
|
561
|
+
return new RelqLockError('Serialization conflict: Another transaction modified the same data. Retry the transaction.', 'serialization_failure', { cause: error, sql, code });
|
|
562
|
+
}
|
|
563
|
+
if (code === '55P03') {
|
|
564
|
+
return new RelqLockError('Lock not available: Another transaction holds the lock and NOWAIT was specified. Retry or remove NOWAIT.', 'lock_not_available', { cause: error, sql, code });
|
|
565
|
+
}
|
|
566
|
+
if (code === '42P01') {
|
|
567
|
+
return new RelqSchemaError(`Table "${error.table || extractFromMessage(message, /relation "(.+?)"/)}" does not exist. Check your schema definition or run migrations.`, 'table', { cause: error, objectName: error.table, sql, code });
|
|
568
|
+
}
|
|
569
|
+
if (code === '42703') {
|
|
570
|
+
const col = error.column || extractFromMessage(message, /column "(.+?)"/);
|
|
571
|
+
return new RelqSchemaError(`Column "${col}" does not exist. Check column name spelling in your schema and query.`, 'column', { cause: error, objectName: col, table: error.table, sql, code });
|
|
572
|
+
}
|
|
573
|
+
if (code === '42803') {
|
|
574
|
+
const col = extractFromMessage(message, /column "(.+?)"/);
|
|
575
|
+
return new RelqSchemaError(`Grouping error: Column "${col || 'unknown'}" must be in GROUP BY or used in an aggregate function. Add it to .groupBy() or wrap it in .include() with an aggregate.`, 'column', { cause: error, objectName: col, sql, code, hint: 'Add the column to .groupBy() or use it inside .include() with a.count(), a.sum(), etc.' });
|
|
576
|
+
}
|
|
577
|
+
if (code === '42883') {
|
|
578
|
+
const fnMatch = message.match(/function (\w+)\((\w+)\)/);
|
|
579
|
+
const fnName = fnMatch?.[1];
|
|
580
|
+
const argType = fnMatch?.[2];
|
|
581
|
+
if (fnName === 'bool_and' || fnName === 'bool_or') {
|
|
582
|
+
const relqMethod = fnName === 'bool_and' ? 'boolAnd' : 'boolOr';
|
|
583
|
+
return new RelqSchemaError(`${relqMethod}() only accepts boolean columns, but received a ${argType || 'non-boolean'} column. Pass a boolean column like t.table.isActive or t.table.delivered.`, 'function', { cause: error, sql, code, hint: `Change a.${relqMethod}(t.table.numericColumn) to a.${relqMethod}(t.table.booleanColumn)` });
|
|
584
|
+
}
|
|
585
|
+
if (fnName === 'string_agg') {
|
|
586
|
+
return new RelqSchemaError(`stringAgg() received an incompatible column type (${argType || 'unknown'}). The column should be a text/string type.`, 'function', { cause: error, sql, code, hint: 'stringAgg auto-casts to text — if you see this error, the column type may not support text conversion.' });
|
|
587
|
+
}
|
|
588
|
+
return new RelqSchemaError(`Function not found: ${message}. Check function name and argument types.`, 'function', { cause: error, sql, code });
|
|
589
|
+
}
|
|
590
|
+
if (code === '42804' || code === '42846') {
|
|
591
|
+
return new RelqSchemaError(`Type mismatch: ${message}. Check that the value type matches the column type.`, 'type', { cause: error, sql, code });
|
|
592
|
+
}
|
|
593
|
+
if (code === '42601') {
|
|
594
|
+
return new RelqSchemaError(`SQL syntax error: ${message}. This may indicate a bug in the query builder — please report it.`, 'column', { cause: error, sql, code, hint: 'If you are using db.raw(), check your SQL syntax.' });
|
|
595
|
+
}
|
|
596
|
+
if (code === '428C9') {
|
|
597
|
+
return new RelqSchemaError(`Cannot write to generated column. Remove it from your insert or update data — generated columns are computed by the database.`, 'column', { cause: error, objectName: error.column, table: error.table, sql, code });
|
|
598
|
+
}
|
|
599
|
+
if (code === '42P07') {
|
|
600
|
+
return new RelqSchemaError(`Table "${error.table || extractFromMessage(message, /relation "(.+?)"/)}" already exists.`, 'table', { cause: error, objectName: error.table, sql, code });
|
|
601
|
+
}
|
|
602
|
+
if (code === '42501') {
|
|
603
|
+
return new RelqSchemaError(`Permission denied: ${message}. Check that your database user has the required privileges.`, 'table', { cause: error, table: error.table, sql, code });
|
|
604
|
+
}
|
|
605
|
+
if (code === '42702') {
|
|
606
|
+
const col = extractFromMessage(message, /column "(.+?)"/);
|
|
607
|
+
return new RelqSchemaError(`Ambiguous column "${col || 'unknown'}": The column exists in multiple tables. Qualify it with a table name or alias.`, 'column', { cause: error, objectName: col, sql, code, hint: 'When joining tables, use the table alias to qualify ambiguous columns.' });
|
|
608
|
+
}
|
|
609
|
+
if (code === '42830') {
|
|
610
|
+
return new RelqSchemaError(`Invalid foreign key definition: ${message}.`, 'constraint', { cause: error, sql, code });
|
|
611
|
+
}
|
|
612
|
+
if (code === '42701') {
|
|
613
|
+
const col = extractFromMessage(message, /column "(.+?)"/);
|
|
614
|
+
return new RelqSchemaError(`Duplicate column "${col || 'unknown'}": A column with this name already exists.`, 'column', { cause: error, objectName: col, table: error.table, sql, code });
|
|
615
|
+
}
|
|
616
|
+
if (code === '42P02') {
|
|
617
|
+
return new RelqSchemaError(`Undefined parameter: ${message}. Check that the number of parameters matches the placeholders in your query.`, 'column', { cause: error, sql, code });
|
|
618
|
+
}
|
|
619
|
+
if (code === '42704') {
|
|
620
|
+
const obj = extractFromMessage(message, /type "(.+?)"/) || extractFromMessage(message, /"(.+?)"/);
|
|
621
|
+
return new RelqSchemaError(`Object "${obj || 'unknown'}" does not exist: ${message}`, 'type', { cause: error, objectName: obj, sql, code });
|
|
622
|
+
}
|
|
623
|
+
if (code === '42P04') {
|
|
624
|
+
const db = extractFromMessage(message, /database "(.+?)"/);
|
|
625
|
+
return new RelqSchemaError(`Database "${db || 'unknown'}" already exists.`, 'schema', { cause: error, objectName: db, sql, code });
|
|
626
|
+
}
|
|
627
|
+
if (code === '42P06') {
|
|
628
|
+
const schema = extractFromMessage(message, /schema "(.+?)"/);
|
|
629
|
+
return new RelqSchemaError(`Schema "${schema || 'unknown'}" already exists.`, 'schema', { cause: error, objectName: schema, sql, code });
|
|
630
|
+
}
|
|
631
|
+
if (code === '42710') {
|
|
632
|
+
const obj = extractFromMessage(message, /"(.+?)"/);
|
|
633
|
+
return new RelqSchemaError(`Object "${obj || 'unknown'}" already exists: ${message}`, 'type', { cause: error, objectName: obj, sql, code });
|
|
634
|
+
}
|
|
635
|
+
if (code === '42809') {
|
|
636
|
+
return new RelqSchemaError(`Wrong object type: ${message}. The object exists but is not the expected type (e.g., using a view as a table).`, 'type', { cause: error, sql, code });
|
|
637
|
+
}
|
|
638
|
+
if (code === '42P18') {
|
|
639
|
+
return new RelqSchemaError(`Cannot determine data type: ${message}. Add an explicit type cast.`, 'type', { cause: error, sql, code, hint: 'TypeScript types are correct but the database needs a type hint. This usually happens with NULL or ambiguous literals.' });
|
|
640
|
+
}
|
|
641
|
+
if (code === '42P20') {
|
|
642
|
+
return new RelqSchemaError(`Window function error: ${message}.`, 'function', { cause: error, sql, code });
|
|
643
|
+
}
|
|
644
|
+
if (code === '42P19') {
|
|
645
|
+
return new RelqSchemaError(`Invalid recursion: ${message}. Check your CTE recursive query.`, 'function', { cause: error, sql, code });
|
|
646
|
+
}
|
|
647
|
+
if (code === '42622') {
|
|
648
|
+
return new RelqSchemaError(`Name too long: ${message}. PostgreSQL identifiers are limited to 63 characters.`, 'column', { cause: error, sql, code });
|
|
649
|
+
}
|
|
650
|
+
if (code === '42939') {
|
|
651
|
+
return new RelqSchemaError(`Reserved name: ${message}. The name conflicts with a PostgreSQL reserved word.`, 'column', { cause: error, sql, code, hint: 'Rename the column/table or quote the identifier.' });
|
|
652
|
+
}
|
|
653
|
+
if (code === '42602') {
|
|
654
|
+
return new RelqSchemaError(`Invalid name: ${message}. The identifier contains invalid characters.`, 'column', { cause: error, sql, code });
|
|
655
|
+
}
|
|
656
|
+
if (code === '42P10') {
|
|
657
|
+
return new RelqSchemaError(`Invalid column reference: ${message}. The column cannot be used in this context.`, 'column', { cause: error, sql, code });
|
|
658
|
+
}
|
|
659
|
+
if (code === '42611') {
|
|
660
|
+
return new RelqSchemaError(`Invalid column definition: ${message}.`, 'column', { cause: error, sql, code });
|
|
661
|
+
}
|
|
662
|
+
if (code === '42P16') {
|
|
663
|
+
return new RelqSchemaError(`Invalid table definition: ${message}.`, 'table', { cause: error, sql, code });
|
|
664
|
+
}
|
|
665
|
+
if (code === '42P17') {
|
|
666
|
+
return new RelqSchemaError(`Invalid object definition: ${message}.`, 'type', { cause: error, sql, code });
|
|
667
|
+
}
|
|
668
|
+
if (code === '42725') {
|
|
669
|
+
return new RelqSchemaError(`Ambiguous function: ${message}. Multiple functions match the given name and argument types.`, 'function', { cause: error, sql, code, hint: 'Add explicit type casts to the arguments to resolve ambiguity.' });
|
|
670
|
+
}
|
|
671
|
+
if (code === '42P21' || code === '42P22') {
|
|
672
|
+
return new RelqSchemaError(`Collation mismatch: ${message}. The columns use different collations.`, 'column', { cause: error, sql, code });
|
|
673
|
+
}
|
|
674
|
+
if (code?.startsWith('42')) {
|
|
675
|
+
return new RelqSchemaError(`Schema/syntax error: ${message}`, 'type', { cause: error, sql, code });
|
|
676
|
+
}
|
|
677
|
+
if (code === '28000' || code === '28P01') {
|
|
678
|
+
return new RelqConnectionError(`Authentication failed: ${code === '28P01' ? 'Invalid password.' : 'Invalid authorization.'} Check your database credentials.`, { cause: error, code });
|
|
679
|
+
}
|
|
680
|
+
if (code === '3D000') {
|
|
681
|
+
const db = extractFromMessage(message, /database "(.+?)"/);
|
|
682
|
+
return new RelqSchemaError(`Database "${db || 'unknown'}" does not exist. Check your database name in the connection config.`, 'schema', { cause: error, objectName: db, sql, code });
|
|
683
|
+
}
|
|
684
|
+
if (code === '3F000') {
|
|
685
|
+
const schema = extractFromMessage(message, /schema "(.+?)"/);
|
|
686
|
+
return new RelqSchemaError(`Schema "${schema || 'unknown'}" does not exist. Check the schema name in your config.`, 'schema', { cause: error, objectName: schema, sql, code });
|
|
687
|
+
}
|
|
688
|
+
if (code === '25001') {
|
|
689
|
+
return new RelqTransactionError('A transaction is already active. Nested transactions are not supported — use savepoints instead.', 'BEGIN', { cause: error, transactionState: 'active' });
|
|
690
|
+
}
|
|
691
|
+
if (code === '25P01') {
|
|
692
|
+
return new RelqTransactionError('No active transaction. You tried to COMMIT or ROLLBACK but there is no transaction in progress.', 'COMMIT', { cause: error, transactionState: 'none' });
|
|
693
|
+
}
|
|
694
|
+
if (code === '25P03') {
|
|
695
|
+
return new RelqTimeoutError('Idle transaction timeout: The transaction was idle for too long and was terminated by the server.', 0, 'query', error);
|
|
696
|
+
}
|
|
697
|
+
if (code === 'OC000') {
|
|
698
|
+
return new RelqLockError('Transaction conflict (DSQL): Another transaction modified the same data. Retry the transaction.', 'serialization_failure', { cause: error, sql, code });
|
|
699
|
+
}
|
|
700
|
+
if (code === 'OC001') {
|
|
701
|
+
return new RelqSchemaError('Schema conflict (DSQL): The schema was updated by another transaction. Retry the operation.', 'schema', { cause: error, sql, code });
|
|
702
|
+
}
|
|
703
|
+
if (code === '53100') {
|
|
704
|
+
return new RelqQueryError('Disk full: The server has run out of disk space.', { cause: error, sql, code });
|
|
705
|
+
}
|
|
706
|
+
if (code === '54001') {
|
|
707
|
+
return new RelqQueryError('Statement too complex: Simplify the query or break it into smaller parts.', { cause: error, sql, code });
|
|
708
|
+
}
|
|
709
|
+
if (code === '0A000') {
|
|
710
|
+
return new RelqSchemaError(`Feature not supported: ${message}. This feature may not be available on your database dialect.`, 'type', { cause: error, sql, code, hint: 'Check your dialect\'s supported features.' });
|
|
711
|
+
}
|
|
712
|
+
if (code === '22001') {
|
|
713
|
+
return new RelqDataError(`Value too long for column "${error.column || 'unknown'}". Shorten the value or increase the column length in your schema.`, 'too_long', { cause: error, column: error.column, table: error.table, sql, code });
|
|
714
|
+
}
|
|
715
|
+
if (code === '22003') {
|
|
716
|
+
return new RelqDataError(`Numeric value out of range for column "${error.column || 'unknown'}". The number is too large or too small for the column type.`, 'out_of_range', { cause: error, column: error.column, table: error.table, sql, code });
|
|
717
|
+
}
|
|
718
|
+
if (code === '22P02') {
|
|
719
|
+
return new RelqDataError(`Invalid value: Cannot convert the given value to the expected type. ${error.detail || message}`, 'invalid_type', { cause: error, dataType: error.dataType, sql, code });
|
|
720
|
+
}
|
|
721
|
+
if (code === '22007' || code === '22008') {
|
|
722
|
+
return new RelqDataError(`Invalid date/time value: ${error.detail || message}. Check date format and range.`, 'invalid_format', { cause: error, sql, code });
|
|
723
|
+
}
|
|
724
|
+
if (code === '22012') {
|
|
725
|
+
return new RelqDataError('Division by zero in query.', 'division_by_zero', { cause: error, sql, code });
|
|
726
|
+
}
|
|
727
|
+
if (code === '22004') {
|
|
728
|
+
return new RelqDataError(`Null value not allowed in this context. ${error.detail || message}`, 'null_not_allowed', { cause: error, column: error.column, table: error.table, sql, code });
|
|
729
|
+
}
|
|
730
|
+
if (code === '22023') {
|
|
731
|
+
return new RelqDataError(`Invalid parameter value: ${error.detail || message}`, 'invalid_type', { cause: error, sql, code });
|
|
732
|
+
}
|
|
733
|
+
if (code === '22018') {
|
|
734
|
+
return new RelqDataError(`Invalid value for type cast: ${error.detail || message}. Cannot convert the value to the target type.`, 'invalid_type', { cause: error, dataType: error.dataType, sql, code });
|
|
735
|
+
}
|
|
736
|
+
if (code === '2200H') {
|
|
737
|
+
return new RelqDataError(`Sequence limit exceeded. The sequence has reached its maximum value.`, 'out_of_range', { cause: error, sql, code });
|
|
738
|
+
}
|
|
739
|
+
if (code === '25P02') {
|
|
740
|
+
return new RelqTransactionError('Transaction is in a failed state. A previous error in this transaction makes it unusable. The transaction will be rolled back.', 'ROLLBACK', { cause: error, transactionState: 'failed' });
|
|
741
|
+
}
|
|
742
|
+
if (code === '25006') {
|
|
743
|
+
return new RelqTransactionError('Cannot write data in a read-only transaction. Remove the readOnly option or use a separate transaction for writes.', 'COMMIT', { cause: error, transactionState: 'read_only' });
|
|
744
|
+
}
|
|
745
|
+
if (code === '53200') {
|
|
746
|
+
return new RelqQueryError('Out of memory: The query requires too much memory. Try reducing result size with LIMIT or simplifying the query.', {
|
|
747
|
+
cause: error, sql, code
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
if (code?.startsWith('22')) {
|
|
751
|
+
return new RelqDataError(`Data error: ${message}`, 'invalid_type', { cause: error, sql, code });
|
|
752
|
+
}
|
|
753
|
+
if (code?.startsWith('23')) {
|
|
754
|
+
return new RelqConstraintError(`Constraint violation: ${message}`, 'unique', { cause: error, table: error.table, constraint: error.constraint, sql, code, detail: error.detail });
|
|
755
|
+
}
|
|
756
|
+
if (code?.startsWith('25')) {
|
|
757
|
+
return new RelqTransactionError(`Transaction error: ${message}`, 'ROLLBACK', { cause: error });
|
|
758
|
+
}
|
|
759
|
+
if (code?.startsWith('40')) {
|
|
760
|
+
return new RelqLockError(`Transaction rollback: ${message}. Retry the transaction.`, 'serialization_failure', { cause: error, sql, code });
|
|
761
|
+
}
|
|
762
|
+
if (code?.startsWith('53')) {
|
|
763
|
+
return new RelqQueryError(`Resource limit: ${message}`, { cause: error, sql, code });
|
|
764
|
+
}
|
|
765
|
+
if (code?.startsWith('54')) {
|
|
766
|
+
return new RelqQueryError(`Limit exceeded: ${message}`, { cause: error, sql, code });
|
|
767
|
+
}
|
|
768
|
+
if (code?.startsWith('55')) {
|
|
769
|
+
return new RelqQueryError(`Object state error: ${message}`, { cause: error, sql, code });
|
|
770
|
+
}
|
|
771
|
+
if (code?.startsWith('57')) {
|
|
772
|
+
return new RelqConnectionError(`Server intervention: ${message}`, { cause: error, code });
|
|
773
|
+
}
|
|
774
|
+
if (code?.startsWith('08')) {
|
|
775
|
+
return new RelqConnectionError(`Connection error: ${message}`, { cause: error, code });
|
|
776
|
+
}
|
|
324
777
|
return new RelqQueryError(message, {
|
|
325
|
-
cause: error,
|
|
326
|
-
sql,
|
|
327
|
-
code,
|
|
328
|
-
detail: error.detail,
|
|
329
|
-
hint: error.hint
|
|
778
|
+
cause: error, sql, code, detail: error.detail, hint: error.hint
|
|
330
779
|
});
|
|
331
780
|
}
|
|
781
|
+
function extractFromMessage(message, pattern) {
|
|
782
|
+
return message.match(pattern)?.[1];
|
|
783
|
+
}
|
|
332
784
|
const NETWORK_ERROR_CODES = new Set([
|
|
333
785
|
'ECONNREFUSED', 'ECONNRESET', 'ENOTFOUND', 'ESERVFAIL',
|
|
334
786
|
'ETIMEDOUT', 'EPIPE', 'EAI_AGAIN', 'EHOSTUNREACH',
|
|
@@ -34,9 +34,9 @@ export function toPoolConfig(config) {
|
|
|
34
34
|
ssl: config.pool?.ssl ?? ssl,
|
|
35
35
|
allowExitOnIdle
|
|
36
36
|
};
|
|
37
|
-
if (config.
|
|
37
|
+
if (config.url) {
|
|
38
38
|
return {
|
|
39
|
-
connectionString: config.
|
|
39
|
+
connectionString: config.url,
|
|
40
40
|
min: poolConfig.min,
|
|
41
41
|
max: poolConfig.max,
|
|
42
42
|
idleTimeoutMillis: poolConfig.idleTimeoutMillis,
|