diff --git a/api/bun.lock b/api/bun.lock index cc9e31d5..e5837399 100644 --- a/api/bun.lock +++ b/api/bun.lock @@ -17,6 +17,9 @@ }, }, }, + "patchedDependencies": { + "drizzle-orm@0.39.0": "patches/drizzle-orm@0.39.0.patch", + }, "packages": { "@drizzle-team/brocli": ["@drizzle-team/brocli@0.10.2", "", {}, "sha512-z33Il7l5dKjUgGULTqBsQBQwckHh5AbIuxhdsIxDDiZAzBOrZO6q9ogcWC65kU382AfynTfgNumVcNIjuIua6w=="], diff --git a/api/package.json b/api/package.json index 945aa120..da151870 100644 --- a/api/package.json +++ b/api/package.json @@ -21,5 +21,8 @@ "@types/pg": "^8.11.11", "bun-types": "^1.2.4" }, - "module": "src/index.js" + "module": "src/index.js", + "patchedDependencies": { + "drizzle-orm@0.39.0": "patches/drizzle-orm@0.39.0.patch" + } } diff --git a/api/patches/drizzle-orm@0.39.0.patch b/api/patches/drizzle-orm@0.39.0.patch new file mode 100644 index 00000000..236d1c90 --- /dev/null +++ b/api/patches/drizzle-orm@0.39.0.patch @@ -0,0 +1,111 @@ +diff --git a/node_modules/drizzle-orm/.bun-tag-9fae835e61d5cc75 b/.bun-tag-9fae835e61d5cc75 +new file mode 100644 +index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 +diff --git a/pg-core/query-builders/select.d.cts b/pg-core/query-builders/select.d.cts +index b968ebb3f563f37c8c36221dd17cc6f3603270ec..3fda6d0a97997f6bd07ec6a0c83397c0fdd2e97e 100644 +--- a/pg-core/query-builders/select.d.cts ++++ b/pg-core/query-builders/select.d.cts +@@ -98,7 +98,16 @@ export declare abstract class PgSelectQueryBuilderBase; ++ leftJoin: PgSelectJoinFn; ++ /** ++ * For each row of the table, include ++ * values from a matching row of the joined ++ * subquery, if there is a matching row. If not, ++ * all of the columns of the joined subquery ++ * will be set to null. The lateral keyword allows ++ * access to columns after the FROM statement. ++ */ ++ leftJoinLateral: PgSelectJoinFn; + /** + * Executes a `right join` operation by adding another table to the current query. + * +@@ -126,7 +135,7 @@ export declare abstract class PgSelectQueryBuilderBase; ++ rightJoin: PgSelectJoinFn; + /** + * Executes an `inner join` operation, creating a new table by combining rows from two tables that have matching values. + * +@@ -154,7 +163,14 @@ export declare abstract class PgSelectQueryBuilderBase; ++ innerJoin: PgSelectJoinFn; ++ /** ++ * For each row of the table, the joined subquery ++ * needs to have a matching row, or it will ++ * be excluded from results. The lateral keyword allows ++ * access to columns after the FROM statement. ++ */ ++ innerJoinLateral: PgSelectJoinFn; + /** + * Executes a `full join` operation by combining rows from two tables into a new table. + * +@@ -182,7 +198,7 @@ export declare abstract class PgSelectQueryBuilderBase; ++ fullJoin: PgSelectJoinFn; + private createSetOperator; + /** + * Adds `union` set operator to the query. +diff --git a/pg-core/query-builders/select.js b/pg-core/query-builders/select.js +index e54406fcaf68ccfdaf32c8945d4d432212c4cf3f..0441be1e483a7ec02430978b5fac5bf6d863ffc7 100644 +--- a/pg-core/query-builders/select.js ++++ b/pg-core/query-builders/select.js +@@ -98,7 +98,7 @@ class PgSelectQueryBuilderBase extends TypedQueryBuilder { + this.tableName = getTableLikeName(table); + this.joinsNotNullableMap = typeof this.tableName === "string" ? { [this.tableName]: true } : {}; + } +- createJoin(joinType) { ++ createJoin(joinType, lateral = false) { + return (table, on) => { + const baseTableName = this.tableName; + const tableName = getTableLikeName(table); +@@ -127,7 +127,7 @@ class PgSelectQueryBuilderBase extends TypedQueryBuilder { + if (!this.config.joins) { + this.config.joins = []; + } +- this.config.joins.push({ on, table, joinType, alias: tableName }); ++ this.config.joins.push({ on, table, joinType, alias: tableName, lateral }); + if (typeof tableName === "string") { + switch (joinType) { + case "left": { +@@ -185,6 +185,15 @@ class PgSelectQueryBuilderBase extends TypedQueryBuilder { + * ``` + */ + leftJoin = this.createJoin("left"); ++ /** ++ * For each row of the table, include ++ * values from a matching row of the joined ++ * subquery, if there is a matching row. If not, ++ * all of the columns of the joined subquery ++ * will be set to null. The lateral keyword allows ++ * access to columns after the FROM statement. ++ */ ++ leftJoinLateral = this.createJoin("left", true); + /** + * Executes a `right join` operation by adding another table to the current query. + * +@@ -241,6 +250,13 @@ class PgSelectQueryBuilderBase extends TypedQueryBuilder { + * ``` + */ + innerJoin = this.createJoin("inner"); ++ /** ++ * For each row of the table, the joined subquery ++ * needs to have a matching row, or it will ++ * be excluded from results. The lateral keyword allows ++ * access to columns after the FROM statement. ++ */ ++ innerJoinLateral = this.createJoin("inner", true); + /** + * Executes a `full join` operation by combining rows from two tables into a new table. + * diff --git a/api/src/controllers/entries.ts b/api/src/controllers/entries.ts index 3362a0ee..cdf4ea48 100644 --- a/api/src/controllers/entries.ts +++ b/api/src/controllers/entries.ts @@ -148,7 +148,7 @@ async function getEntries({ }) .from(entries) .innerJoin(transQ, eq(entries.pk, transQ.pk)) - .leftJoin(videosJ, sql`true`) + .leftJoinLateral(videosJ, sql`true`) .where( and( filter,