char / character in both MySQL and SQLite
See original GitHub issueIssue type:
[x] question [x] bug report [x] feature request [ ] documentation issue
Database system/driver:
[x] mysql
/ mariadb
[x] sqlite
TypeORM version:
[x] latest
[x] 0.2.6
Steps to reproduce or a small repository showing the problem:
I want to have a fixed length char in both MySQL and SQLite.
If I use type: 'character'
I get:
DataTypeNotSupportedError: Data type “character” in “Entity.column” is not supported by “mysql” database
If I use type: 'char'
I get:
Data type “char” in “Entity.column” is not supported by “sqlite” database.
I checked other issues and I found that this was addressed in issue #343 by adding a fixedLength
option, but then was removed in commit #f1c566f2efc206170533171110aed0980cd1360b, when database specific types were introduced.
Is there any way I can get around this?
If not, Wouldn’t it make sense to have a some generic types like char
that can be mapped in every database? Or re-introduce String + fixedLength
type?
Whichever option, I would be glad to contribute if someone approves.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:6
@pmoleri Ah, thanks for the clarification, I rarely use the later type, seems postgres has spoiled me:
“Different from other database systems, in PostgreSQL, there is no performance difference among three character types. In most situation, you should use text or varchar, and varchar(n) if you want PostgreSQL to check for the length limit.”
http://www.postgresqltutorial.com/postgresql-char-varchar-text/
It makes a difference to the DBMS.
varchar
128: I’m storing a variable length string up to 128 charscharacter
128: I’m always storing 128 chars.The DBMS optimizes these 2 in different ways.