-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Description
Issue type:
[ ] question
[x] bug report
[ ] feature request
[ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[x] mysql / mariadb
[ ] oracle
[ ] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[x] latest
[ ] @next
[x] 0.2.15
Steps to reproduce or a small repository showing the problem:
import {BaseEntity, Entity, PrimaryColumn, Column} from "typeorm";
enum Singleton {
EMPTY = ""
}
/**
* Global application settings.
*/
@Entity("settings")
export class Settings extends BaseEntity {
@PrimaryColumn()
readonly singleton: Singleton = Singleton.EMPTY;
@Column()
value!: string;
}I have a "settings" table in my database that holds global application settings (one setting per column). In non-TypeORM projects, I've always used an enum primary key to enforce the existence of only one row. But TypeORM is not loading anything when I run:
Settings.find();The array is empty (despite having a fully populated row in the database).
If I change the entity definition to:
import {BaseEntity, Entity, PrimaryColumn, Column} from "typeorm";
/**
* Global application settings.
*/
@Entity("settings")
export class Settings extends BaseEntity {
@PrimaryColumn()
readonly singleton: number = 0;
@Column()
value!: string;
}then it starts working (after updating the database schema).