question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Specifying a columnType in Property decorator doesn't produce desired schema

See original GitHub issue

Describe the bug I’m trying to create an entity number property that maps to a Postgres numeric column with a specific precision and scale. However specifying the columnType option in the @Property() decorator doesn’t seem to result in anything but int4.

To Reproduce Steps to reproduce the behavior:

  1. Create an entity with the following property
@Property({ type: 'number', columnType: 'numeric(10, 2)', default: 0 })
	myAttribute: number = 0.00;
  1. Run schemaGenerator.createSchema() and inspect the dump

Expected behavior The resulting sql builds a statement that includes the column definition as "my_attribute" numeric(10,2) not null default 0

Actual behavior The resulting sql builds a statement that includes the column definition as "my_attribute" int4 not null default 0

Versions

Dependency Version
node 13.9.1
typescript 3.8.3
mikro-orm 3.5.1
pg 7.18.2

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

5reactions
B4nancommented, Mar 23, 2020

Will release this later today.

1reaction
B4nancommented, Mar 23, 2020

Can you try to add rename(options, 'columnType', 'columnTypes'); to EntitySchema.addProperty? Should be just about that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeORM does not create tables, columns etc - Stack Overflow
Save this question. Show activity on this post. So it seems like TypeORM doesn't generate the tables / columns.
Read more >
Entity Properties - EF Core | Microsoft Learn
How to configure and map entity properties using Entity Framework ... Included and excluded properties; Column names; Column data types ...
Read more >
Custom Types - SQLAlchemy 1.4 Documentation
The TypeDecorator allows the creation of custom types which add bind-parameter and result-processing behavior to an existing type object. It is ...
Read more >
Resolvers | NestJS - A progressive Node.js framework
Most of the definitions in a GraphQL schema are object types. ... that can exist in our data graph, but clients don't yet...
Read more >
DataAnnotations - NotMapped Attribute in EF 6 & EF Core
The NotMapped attribute can be applied to properties of an entity class for which we do not want to create corresponding columns in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found