mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-15 20:17:22 +00:00
fix: recursive with omitted join clauses
This commit is contained in:
@@ -4,6 +4,7 @@ import type { KyselyJsonFrom } from "data/relations/EntityRelation";
|
|||||||
import type { RepoQuery } from "data/server/query";
|
import type { RepoQuery } from "data/server/query";
|
||||||
import { InvalidSearchParamsException } from "data/errors";
|
import { InvalidSearchParamsException } from "data/errors";
|
||||||
import type { Entity, EntityManager, RepositoryQB } from "data/entities";
|
import type { Entity, EntityManager, RepositoryQB } from "data/entities";
|
||||||
|
import { $console } from "bknd/utils";
|
||||||
|
|
||||||
export class WithBuilder {
|
export class WithBuilder {
|
||||||
static addClause(
|
static addClause(
|
||||||
@@ -13,7 +14,7 @@ export class WithBuilder {
|
|||||||
withs: RepoQuery["with"],
|
withs: RepoQuery["with"],
|
||||||
) {
|
) {
|
||||||
if (!withs || !isObject(withs)) {
|
if (!withs || !isObject(withs)) {
|
||||||
console.warn(`'withs' undefined or invalid, given: ${JSON.stringify(withs)}`);
|
$console.warn(`'withs' undefined or invalid, given: ${JSON.stringify(withs)}`);
|
||||||
return qb;
|
return qb;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,9 +38,7 @@ export class WithBuilder {
|
|||||||
let subQuery = relation.buildWith(entity, ref)(eb);
|
let subQuery = relation.buildWith(entity, ref)(eb);
|
||||||
if (query) {
|
if (query) {
|
||||||
subQuery = em.repo(other.entity).addOptionsToQueryBuilder(subQuery, query as any, {
|
subQuery = em.repo(other.entity).addOptionsToQueryBuilder(subQuery, query as any, {
|
||||||
ignore: ["with", "join", cardinality === 1 ? "limit" : undefined].filter(
|
ignore: ["with", cardinality === 1 ? "limit" : undefined].filter(Boolean) as any,
|
||||||
Boolean,
|
|
||||||
) as any,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,7 +56,7 @@ export class WithBuilder {
|
|||||||
static validateWiths(em: EntityManager<any>, entity: string, withs: RepoQuery["with"]) {
|
static validateWiths(em: EntityManager<any>, entity: string, withs: RepoQuery["with"]) {
|
||||||
let depth = 0;
|
let depth = 0;
|
||||||
if (!withs || !isObject(withs)) {
|
if (!withs || !isObject(withs)) {
|
||||||
withs && console.warn(`'withs' invalid, given: ${JSON.stringify(withs)}`);
|
withs && $console.warn(`'withs' invalid, given: ${JSON.stringify(withs)}`);
|
||||||
return depth;
|
return depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -105,7 +105,10 @@ export class AppServer extends Module<AppServerConfig> {
|
|||||||
|
|
||||||
if (err instanceof Error) {
|
if (err instanceof Error) {
|
||||||
if (isDebug()) {
|
if (isDebug()) {
|
||||||
return c.json({ error: err.message, stack: err.stack }, 500);
|
return c.json(
|
||||||
|
{ error: err.message, stack: err.stack?.split("\n").map((line) => line.trim()) },
|
||||||
|
500,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,8 +70,9 @@ switch (dbType) {
|
|||||||
if (example) {
|
if (example) {
|
||||||
const name = slugify(example);
|
const name = slugify(example);
|
||||||
configPath = `.configs/${slugify(example)}.wrangler.json`;
|
configPath = `.configs/${slugify(example)}.wrangler.json`;
|
||||||
const exists = await readFile(configPath, "utf-8");
|
try {
|
||||||
if (!exists) {
|
await readFile(configPath, "utf-8");
|
||||||
|
} catch (_e) {
|
||||||
wranglerConfig.name = name;
|
wranglerConfig.name = name;
|
||||||
wranglerConfig.d1_databases[0]!.database_name = name;
|
wranglerConfig.d1_databases[0]!.database_name = name;
|
||||||
wranglerConfig.d1_databases[0]!.database_id = crypto.randomUUID();
|
wranglerConfig.d1_databases[0]!.database_id = crypto.randomUUID();
|
||||||
|
|||||||
Reference in New Issue
Block a user