Skip to main content

durcno@1.0.0-alpha.23

Minor Changes​

  • 212f208 - Thanks to @almahdi404 !

    feat(functions): add trunc and power mathematical functions

    Added support for PostgreSQL trunc and power mathematical functions in query builder expressions.

    trunc truncates a numeric expression to the nearest integer or optionally to a specified number of decimal places:

    import { trunc } from "durcno";

    trunc(Users.price);
    trunc(Users.price, 2);

    power returns a numeric expression raised to the power of an exponent:

    import { power } from "durcno";

    power(Users.price, 2);
  • 03680e2 - Thanks to @almahdi404 !

    perf(db): optimize prepared query execution

    Introduced execStrArgs in the query executor to directly execute raw query strings and arguments. This avoids unnecessarily instantiating Query objects, significantly improving the performance of prepared statements.

    Additionally, expanded SqlArgType to include bigint and boolean types, allowing them to be passed directly as arguments to db.raw and prepared queries.

Patch Changes​

  • 6b69489 - Thanks to @almahdi404 !

    fix(qb/type): fix type inference for scalar functions inside aggregate functions

    Fix type inference when passing scalar functions or scalar arithmetic expressions inside aggregate functions like sum(), avg(), min(), max(), and count().

    const [result] = await db.from(schema.Users).select({
    totalAbs: sum(abs(schema.Users.score)),
    avgAbs: avg(abs(schema.Users.score)),
    });
  • 23ccde2 - Thanks to @almahdi404 !

    fix(rq): support extra foreign key constraints in relation subqueries

    Update buildRelationSubquery in the relational query builder to resolve foreign key column references defined via table extra foreign key constraints (extra.foreignKeys) when inline column references (getReferencesCol) are absent.

    This resolves issues where relational queries failed to resolve relations defined through table-level foreign key definitions.

  • ac5c26e - Thanks to @almahdi404 !

    perf(qb): optimize object mapping for relation and select queries

    This optimization refines how rows returned by the database are transformed into TypeScript objects across rq.ts (RelationQuery) and select.ts (SelectQuery) to improve overall performance and reduce memory allocations.

    • Relation Queries: Now leverage SQL aliasing directly in the query (AS "colName") to retrieve rows with TypeScript keys pre-mapped, eliminating the need to iterate through objects and rewrite keys in JavaScript. It also uses traditional for loops rather than for...in to iterate array relations, optimizing array processing.
    • Select Queries: The object mapping logic now short-circuits on empty arrays. Additionally, it caches Object.keys() from the first row and re-uses it to iterate over subsequent rows instead of calling Object.entries() on every row, reducing garbage collection overhead for large result sets.
  • 47b86fa - Thanks to @almahdi404 !

    perf(qb): inline variable access during row processing

    Optimized query result mapping in rq and select query builders by removing intermediate variable declarations during row iteration. This reduces unnecessary memory allocations and improves performance when mapping database rows to TypeScript objects.