Schema generation fails silently when @PrimaryColumn is ommitted
See original GitHub issueI have the following working entity:
export class AddressDbSchema implements AddressDTO {
@PrimaryColumn()
public _id?: string;
@Column()
public address1: string;
@Column()
public address2?: string;
@Column()
public city: string;
@Column()
public state: string;
@Column()
public zip: string;
@Column()
public country: string;
}
Here’s the calling code:
export class AddressRepositoryImplDb implements AddressRepository {
private addressRepository: Repository<AddressDbSchema>;
constructor() {
this.connect().then(async connection => {
this.addressRepository = connection.getRepository(AddressDbSchema);
});
}
public async findAll(): Promise<Array<AddressDTO>> {
return await this.addressRepository.find();
}
public async create(addressDTO: AddressDTO): Promise<AddressDTO> {
return await this.addressRepository.persist(addressDTO);
}
public async update(addressDTO: AddressDTO): Promise<AddressDTO> {
return await this.addressRepository.persist(addressDTO);
}
public async find(id: string): Promise<AddressDTO> {
return await this.addressRepository.findOneById(id);
}
private connect(): Promise<Connection> {
return createConnection({
driver: {
type: 'sqlite',
storage: 'tmp/sqlitedb.db'
},
logging: {
logQueries: true,
logSchemaCreation: true
},
autoSchemaSync: true,
entities: [
AddressDbSchema
]
});
}
}
If I modify the entity to look like this, schema generation fails, but I get no error messages.
export class AddressDbSchema implements AddressDTO {
@Column()
public _id?: string;
@Column()
public address1: string;
@Column()
public address2?: string;
@Column()
public city: string;
@Column()
public state: string;
@Column()
public zip: string;
@Column()
public country: string;
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
typeorm/typeorm - Gitter
Hi! I'm having a hard time setting the current timestamp to a column on an MySQL database. My entity is the following: @Column({...
Read more >15.10 - TPT4130 Error: Schema generation failed for SELECT ...
TPT4130 Error: Schema generation failed for SELECT statement '%s' in DBS '%s': GetSelectStmtSchema status: %d.
Read more >SQL Developer Dialog Boxes and Wizards - Oracle Help Center
This dialog box is displayed when you specify an invalid file after clicking Add in the XML Schemas pane of SQL Developer preferences....
Read more >typeorm: CHANGELOG
Primary column name must match the relation name + join column name on related entity. If related entity has multiple primary keys, and...
Read more >Can a database table not have a primary key?
Actually, SQLite silently creates a primary key column for your called ... it errors out: Parse error: PRIMARY KEY missing on table t1...
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 Free
Top 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
Thanks.
I updated the connection code and I’m getting the error now.
I would request that the examples on the README include this as I basically just copied the examples and none of them include
catch
.Thank you!