fix(kysely): edge case aliased joined table names (#7171)

Co-authored-by: Bereket Engida <Bekacru@gmail.com>
This commit is contained in:
Maxwell
2026-02-28 15:40:14 -08:00
committed by GitHub
parent a63d31eefb
commit 55100bfcb9

View File

@@ -15,6 +15,7 @@ import type {
UpdateQueryBuilder,
} from "kysely";
import { sql } from "kysely";
import { capitalizeFirstLetter } from "../..";
import type { KyselyDatabaseType } from "./types";
interface KyselyAdapterConfig {
@@ -262,7 +263,13 @@ export const kyselyAdapter = (
fieldName,
joinModelRef,
} of allSelectsStr) {
if (keyStr === `_joined_${joinModelRef}_${fieldName}`) {
if (
keyStr === `_joined_${joinModelRef}_${fieldName}` ||
// Edge case to catch capitalized results that derive from snake_case table names
// If anyone can identify the cause behind this, please note it here.
keyStr ===
`_Joined${capitalizeFirstLetter(joinModelRef)}${capitalizeFirstLetter(fieldName)}`
) {
joinedModelFields[getModelName(joinModel)]![
getFieldName({
model: joinModel,