-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Description
Issue description
Crash when using Repository.save with a column of type 'time', array: true when switching from null to a value, in PostgreSQL
Expected Behavior
Update should occur without error (this was fine in 0.3.23).
Actual Behavior
When using Repository.save on an entity with a column of type time, nullable: true, array: true in PostgreSQL, with the following scenario:
- Entity is fetched using query builder
entity.columnWithTypeTimevalue was previouslynullentity.columnWithTypeTime = ['12:00']repository.save(entity)<- this crashes
Note that crash does not happen when this column is not updated, so I suppose this relates to the "diff" process during .save to determine which columns should figure in the UPDATE request.
TypeError: Cannot read properties of null (reading 'map')
at /app/src/persistence/SubjectChangedColumnsComputer.ts:110:49
at Array.forEach (<anonymous>)
at SubjectChangedColumnsComputer.computeDiffColumns (/app/src/persistence/SubjectChangedColumnsComputer.ts:37:34)
at /app/src/persistence/SubjectChangedColumnsComputer.ts:21:18
at Array.forEach (<anonymous>)
at SubjectChangedColumnsComputer.compute (/app/src/persistence/SubjectChangedColumnsComputer.ts:20:18)
at SubjectExecutor.recompute (/app/src/persistence/SubjectExecutor.ts:209:45)
at new SubjectExecutor (/app/src/persistence/SubjectExecutor.ts:91:14)
at /app/src/persistence/EntityPersistExecutor.ts:146:28
at processTicksAndRejections (node:internal/process/task_queues:105:5)
at async Promise.all (index 0)
at EntityPersistExecutor.execute (/app/src/persistence/EntityPersistExecutor.ts:72:31)
Steps to reproduce
Create an entity with a time array column (this might happen with other array types, but I haven't tested yet).
@Entity('schools', { schema: 'public' })
export class School {
@PrimaryGeneratedColumn({ type: 'integer', name: 'id' })
id: number;
@Column('time without time zone', { nullable: true, name: 'opening_monday', array: true })
opening_monday: [string, string] | null;
}Then write the following scenario:
- Entity is fetched using query builder
const school = await connection.getRepository(School).findOne({});entity.columnWithTypeTimevalue was previouslynull
require('assert').deepEqual(school.opening_monday, null);- Write a value
school.opening_monday = ['12:00', '14:00'];- Save
await connection.getRepository(School).save(school);My Environment
TypeORM version 0.3.24
Node.js 22.16
TypeScript 5.7.2
Alpine Linux 3.21
PostgreSQL 16
Additional Context
No response
Relevant Database Driver(s)
- aurora-mysql
- aurora-postgres
- better-sqlite3
- cockroachdb
- cordova
- expo
- mongodb
- mysql
- nativescript
- oracle
- postgres
- react-native
- sap
- spanner
- sqlite
- sqlite-abstract
- sqljs
- sqlserver
Are you willing to resolve this issue by submitting a Pull Request?
Yes, I have the time, but I don't know how to start. I would need guidance.