DataTypeNotSupportedError when using "| null" type
See original GitHub issueIssue type:
[x] bug report
Database system/driver:
[x] mysql
TypeORM version:
[x] latest
Steps to reproduce or a small repository showing the problem:
When I set one of my entity fields with | null
, ex:
@Column({ name: "code", nullable: true })
public code?: string | null;
I am told
DataTypeNotSupportedError: Data type "Object" in "User.code" is not supported by "mysql" database.
at new DataTypeNotSupportedError (/project/node_modules/typeorm/error/DataTypeNotSupportedError.js:16:28)
at /project/node_modules/typeorm/metadata-builder/EntityMetadataValidator.js:73:27
at Array.forEach (<anonymous>)
at EntityMetadataValidator.validate (/project/node_modules/typeorm/metadata-builder/EntityMetadataValidator.js:70:36)
at /project/node_modules/typeorm/metadata-builder/EntityMetadataValidator.js:41:74
at Array.forEach (<anonymous>)
at EntityMetadataValidator.validateMany (/project/node_modules/typeorm/metadata-builder/EntityMetadataValidator.js:41:25)
at Connection.buildMetadatas (/project/node_modules/typeorm/connection/Connection.js:515:33)
at Connection.<anonymous> (/project/node_modules/typeorm/connection/Connection.js:162:30)
at step (/project/node_modules/typeorm/connection/Connection.js:32:23)
This is a problem for me as I use strictNullChecks
(so ?
only allows undefined) and use the difference as:
null
=== the field is nullundefined
=== i dont know the value of this field
Issue Analytics
- State:
- Created 5 years ago
- Reactions:10
- Comments:10 (3 by maintainers)
Top Results From Across the Web
TypeORM error - DataTypeNotSupportedError - Stack Overflow
Show activity on this post. This is the correct usage: @Column({ type: 'varchar', nullable: true }) username: string | undefined;.
Read more >typeorm/typeorm - Gitter
Is typeorm incompatible with transpileOnly mode for TS? I receive this: DataTypeNotSupportedError: Data type "Object" in "Study.status" is not supported by ...
Read more >DescribeParams = true raises Data type not supported error
I get "Data type is not supported". I fully understand that this works fine if I set DescribeParams to False, but in my...
Read more >Entities - typeorm - GitBook
The example below will create id with int as type which you must manually assign ... nullable: boolean - Makes column NULL or...
Read more >InfoSphere Information Server, Version 8.1 Fix Pack 1, fix list
SCD stage rejects rows with null type 2 fielDS when comparing between ... ODBC Enterprise: Data type not supported error thrown while ...
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
You need provide a data type explicitly. By default typeorm reads typeorm from type definition, e.g.
: string
, andstring
is reflected intoString
. Butstring|null
is reflected intoObject
and we cannot determine type. So, what you should do is to specify type explicitly:"text"
type worked for me