Repository navigation
Conversation
Excel cells arrive as JSON numbers, but Lesson.teacherId only had @IsDigitsOnly (a string validator), so every row of the lessons bulk-upload failed validation with 'teacherId must contain digits only'. Add @StringType (Type(() => String)) like Student.tz, so class-transformer coerces the number to a digits string before both the CREATE-group ValidationPipe and the entity save. Covered by a new Lesson.entity.spec.ts that validates a row exactly as the client parses it from the lessons_kodesh Excel (numeric teacherId/klasses, date strings, empty year) and asserts the @StringType transform, CREATE-group validation, and fillFields reference resolution.
There was a problem hiding this comment.
🟢 Approval recommended
The fix and regression coverage address the import validation failure with no unresolved blocking issues.
Pull request overview
Fixes lesson bulk Excel imports by converting numeric teacherId values to strings before validation.
Changes:
- Adds
@StringTypetoLesson.teacherId. - Adds regression coverage for validation and reference resolution.
File summaries
| File | Summary |
|---|---|
server/src/db/entities/Lesson.entity.ts |
Coerces numeric teacher IDs to strings. |
server/src/db/entities/__tests__/Lesson.entity.spec.ts |
Covers Excel-style lesson import behavior. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Owner
Author
|
Superseded by nra-server #58: IsDigitsOnly now coerces numeric values to strings centrally, making the per-field @StringType here redundant. The Lesson.entity.spec.ts test case is valuable — merged its intent into #58's coverage. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Lesson.teacherIdhas@IsDigitsOnly(10)(string-only validator) and was missing the@StringTypetransform. Added@StringType(Type(() => String)) — same pattern asStudent.tz— so class-transformer coerces the number to a digits string during both the CREATE-group ValidationPipe andprepareEntityBeforeSave.server/src/db/entities/__tests__/Lesson.entity.spec.ts: validates a row exactly as the client parses it from the lessons Excel (numeric teacherId/klasses, 'YYYY-MM-DD' dates, empty year) — asserts the transform, CREATE-group validation, andfillFields(klass/teacher reference resolution + Hebrew-year default). Verified it fails without the fix.Verified end-to-end (lessons_kodesh.xlsx, 65 rows, school year 5787 / 2026-27)
client/src/entities/lesson.jsximporter →ResourceImportButton→readAsExcel+ date fix → preview → per-rowcreate; no client changes needed.yeardefaults to current Hebrew year (5787) viafillDefaultYearValue; unique (userId, key, year) enforced byIsUniqueCombination.@BeforeInsert fillFields(tz/key+year lookups).Data prerequisites (not code)
Klasses (71100…72300) and teacher tzs must already exist for year 5787 in the target environment, or those rows save without the reference.
Tests
server: new spec + lesson.config.spec pass. Pre-existing failures unchanged (yemot e2e/scenario suites, year.util.behavior, attendance-cleanup-sweep, yemot-handler — date/env-dependent, fail identically with the change stashed).client: no client code changed; client suite untouched.