Error: Index contains column that is missing in the entity - @Index isn't using column name from @Column
See original GitHub issueWith an entity like this:
@Entity()
@Index(["country","iso3","region","name","rei_name"], { unique: true })
export class BurdenRegion implements Region {
@PrimaryColumn()
@Column({ length: 56 })
country?: string;
@PrimaryColumn()
@Column({ length: 6})
iso3?: string;
@PrimaryColumn()
@Column({ length: 12})
region?: string;
@PrimaryColumn()
@Column({ length: 56})
name?: string;
@PrimaryColumn()
@Column({name:"rei_name",length: 5})
reiName?: string;
}
I get the following error:
Index contains column that is missing in the entity: rei_name
I want rei_name to be called reiName in the entity, so I added the column name property
@Column({name:"rei_name",length: 5})
But it’s not being used. If I change the @Index to use the entity name like this:
@Index(["country","iso3","region","name","reiName"], { unique: true })
I get another error:
error: column BurdenRegion.reiName does not exist
So I’m not sure how to configure this properly?
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
How to create a unique index containing multiple fields where ...
When i generate this entity and create the sql table (without the index) i see player_id as one of the columns. But it...
Read more >Tune nonclustered indexes with missing index suggestions
Returns detailed information about a missing index; for example, it returns the name and identifier of the table where the index is missing,...
Read more >Indexing and selecting data - Pandas
If a column is not contained in the DataFrame, an exception will be raised. ... pandas will raise a KeyError if indexing with...
Read more >Secondary indexes | Cloud Spanner
The query processor retrieves these columns by joining the index and the base table. To avoid this extra join, use a STORING clause...
Read more >13.1.20 CREATE TABLE Statement - MySQL :: Developer Zone
If you use quoted identifiers, quote the database and table names ... In other cases, you must declare indexed columns as NOT NULL...
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
Actually
BurdenRegion.reiNameis correct one since Index decorator expects property names, not database column names. Adding indices expert - mr. @iz-iznogoodHi all
this is the proper declaration, it works like a charm