-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Synchronize issue with UUID (MySQL) #3374
Comments
please provide some reproduction |
Hi @pleerock , I wrote some steps above to reproduce the issue, did I miss something? |
Same issue |
do you have records in your database before you change it to uuid? |
No records before changing it. But once set to UUID, I then insert sample data which all works fine. Upon restarting app it tries to synchronize by dropping the column and adding it again, which fails because it's not generating a UUID at that point. |
Sounds like uuid isn't being generated |
Thanks, how to fix? |
first we need to write a test that will with this issue, then we need to find a place where its being generated and see why its not generating (if its an issue) then fix it. |
Hitting the same problem. Do you mean it is expected to drop the primary key column? What if its values are referenced and used somewhere else? |
We have a similar problem. By the way, I have a question. Bipolar said 'Upon restarting app it tries to synchronize by dropping the column and adding it again'. I saw the same log with mysql 5.7. Can anybody tell me why columns are dropped? |
@pleerock Hi! Could you tell me where do I start to fix this problem? I want to spend time to solve this issue. |
fix in #3234 caused this bug. I pushed fix and released |
The issue is closed, but ist fixed? I am experiencing the exact same issue with the |
Yep experienced the same in the postgres driver, it doesn't seem to be dropping everything in the synchronize. |
Please create a new issue with the new details if you face problems. |
Regression 0.3.16 related to #10090 |
Issue type:
[ ] question
[x] bug report
[ ] feature request
[ ] documentation issue
Database system/driver:
[ ]
cordova
[ ]
mongodb
[ ]
mssql
[x]
mysql
/mariadb
[ ]
oracle
[ ]
postgres
[ ]
sqlite
[ ]
sqljs
[ ]
react-native
[ ]
expo
TypeORM version:
[x]
latest
[ ]
@next
[ ]
0.x.x
(or put your version here)Steps to reproduce or a small repository showing the problem:
I am running into issues with synchronize setting on TypeORM with UUID PrimaryGeneratedColumns on MySQL driver. It seems each time application loads it tries to re-index, so it drops the id column and tries to add it again. Issue is that since it's UUID, for MySQL the column type is varchar(36) NOT NULL PRIMARY KEY. So we run into duplicate entry '' for key 'PRIMARY' because UUID is not set.
To recreate issue, you can do it like this:
typeorm init --name MyProject --database mysql
Edit your User.ts entity to change primary key to UUID.
Ensure synchronize is set to true in ormconfig.json. Start the app and it will insert sample User. Restart app and synchronize will run and try and drop and re-add the column and give error.
The text was updated successfully, but these errors were encountered: