Table alias is greater than 63 bytes causes truncated identifier notice

I have a query:
const samplingRound = await db.query.samplingRound
.findFirst({
where: ops.eq(schema.samplingRound.id, samplingRoundId),
with: {
carbonEstimationArea: true,
stratumSamplingRounds: {
with: {
soilSamples: {
with: {
soilSampleAnalysis: true,
},
},
stratum: true,
},
},
},
})
const samplingRound = await db.query.samplingRound
.findFirst({
where: ops.eq(schema.samplingRound.id, samplingRoundId),
with: {
carbonEstimationArea: true,
stratumSamplingRounds: {
with: {
soilSamples: {
with: {
soilSampleAnalysis: true,
},
},
stratum: true,
},
},
},
})
which generates some SQL that alias the table name soil_sample_analysis to samplingRound_stratumSamplingRounds_soilSamples_soilSampleAnalysis which is 66 bytes:
from "soil_sample_analysis" "samplingRound_stratumSamplingRounds_soilSamples_soilSampleAnalysis"
where "samplingRound_stratumSamplingRounds_soilSamples_soilSampleAnalysis"."soil_sample_id" = "samplingRound_stratumSamplingRounds_soilSamples"."id"
from "soil_sample_analysis" "samplingRound_stratumSamplingRounds_soilSamples_soilSampleAnalysis"
where "samplingRound_stratumSamplingRounds_soilSamples_soilSampleAnalysis"."soil_sample_id" = "samplingRound_stratumSamplingRounds_soilSamples"."id"
Because 66 > 63, I get this notice:
{
severity_local: 'NOTICE',
severity: 'NOTICE',
code: '42622',
message: 'identifier "samplingRound_stratumSamplingRounds_soilSamples_soilSampleAnalysis" will be truncated to "samplingRound_stratumSamplingRounds_soilSamples_soilSampleAnaly"',
file: 'scansup.c',
line: '99',
routine: 'truncate_identifier'
}
{
severity_local: 'NOTICE',
severity: 'NOTICE',
code: '42622',
message: 'identifier "samplingRound_stratumSamplingRounds_soilSamples_soilSampleAnalysis" will be truncated to "samplingRound_stratumSamplingRounds_soilSamples_soilSampleAnaly"',
file: 'scansup.c',
line: '99',
routine: 'truncate_identifier'
}
What are my options here for preventing this? I don't want to rename the table, as the individual tables themselves are a reasonable length. I also ideally don't want to just suppress the notice using the driver. I see this as an issue with drizzle as drizzle is generating this alias. Thanks for your help!
1 Reply
Angelelz
Angelelz7mo ago
Not many options right now, other than renaming the tables
Want results from more Discord servers?
Add your server