findOneOrFail throws when selecting a null valued column
See original GitHub issueIssue type:
[ ] question [x] bug report [ ] feature request [ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql
/ mariadb
[ ] oracle
[x] postgres
[ ] sqlite
[ ] sqljs
[ ] react-native
TypeORM version:
[ ] latest
[ ] @next
[x] 0.2.3
(or put your version here)
findOneOrFail() throws when it shoulddn’t.
Given this entity:
@Entity()
class Company {
@PrimaryGeneratedColumn()
id: number
@Column()
name: string
@Column({nullable:true})
nullName: string
}
then this snippet shows the problem:
// Given
const company = new Company()
company.name = "Company A"
await companyRepo.save(company)
// Then - This works
const c1 = await companyRepo.findOneOrFail(company.id, {select: ["name"]})
// Then - This throws "EntityNotFound: Could not find any entity of type "Company" matching: 1"
const c2 = await companyRepo.findOneOrFail(company.id, {select: ["nullName"]})
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Laravel - find by custom column or fail - Stack Overflow
So call firstOrFail before where. Model::firstOrFail()->where('something', $value).
Read more >typeorm/typeorm - Gitter
This is the errors typeorm throws from the console. query: 'ALTER TABLE "book_reading_status" ADD "readingStatus" integer NOT NULL', message: 'column ...
Read more >typeorm: CHANGELOG
stringify() to json/jsonb column types in Postgres. Instead, we delegate value directly to underlying pg driver. This is a correct way of handling...
Read more >Model Querying - Finders - Sequelize
Finder methods are the ones that generate SELECT queries. ... If the defaults do not contain values for every column, Sequelize will take ......
Read more >partitioning on a null valued column - Forums - IBM Support
Is it possible to create partitions on field that has null values ? I would like to create the partition key for a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
it’s very confusing and can easily lead to errors that can be missed before production release. if
typeorm
needid
, it should always fetch id, even if it is not asked for it.What is the reason for ~the bug to occur~ this behaviour? Is the entity id column always required, or is selecting a single nullable column parsed in a wrong way, when the value is null?