Skip to content
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

Unable to set first order id on nop 4.3 with MySQL db #4866

Closed
jonquickqsense opened this issue Jun 19, 2020 · 2 comments
Closed

Unable to set first order id on nop 4.3 with MySQL db #4866

jonquickqsense opened this issue Jun 19, 2020 · 2 comments
Assignees
Labels
Milestone

Comments

@jonquickqsense
Copy link

nopCommerce version:
4.3 MySQL
Steps to reproduce the problem:
New install. In settings > Orders > Order Id

trying to change first order id from 1 to 1001

error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''Order' AUTO_INCREMENT = 1001' at line 1

First order Id is not changed after refresh

@jonquickqsense jonquickqsense changed the title Unable to set first order id on 4.3 MySQL Unable to set first order id on nop 4.3 with MySQL db Jun 19, 2020
@AndreiMaz AndreiMaz added this to the Version 4.40 milestone Jun 22, 2020
@jonquickqsense
Copy link
Author

I did some debug/testing for this to try and fix issue for mySQL 8. It uncovered some interesting things..

Whilst SetTableIdent will set the AUTO_INCREMENT in mySQL table, the value cannot immediately be re-queried from information_schema.TABLES until a manual action to ANALYSE TABLE is carried out (in mySQL studio or a restart of mySQL). This leads to behaviour in Nop that if you set the OrderId through settings, when you reload the settings page, it re-reads the incorrect/out-of-date value from information_schema.TABLES

You cannot reliably query SELECT AUTO_INCREMENT FROM information_schema.TABLES WHERE TABLE_SCHEMA = '{databaseName}' AND TABLE_NAME = '{tableName}'") to give the last used ID. The reason is the AUTO_INCREMENT value is held in memory and not committed to the information_schema in real time. I understand information_schema is updated with the latest value on restart (by performing a MAX(id) on the Order table and writing this to information_schema.

The whole difficulty in this (supporting multiple db back-ends etc), leads me to think it should be re-architected and handled in a different way.

I can see the business case for setting the start Order Id - you may be migrating from another system and want the order id's to transfer with sequential consistency

Idea:

  1. Include as a setting on the install screen, near where you select MS SQL or MySql - set auto_increment value on table creation
  2. Also keep option in 'Settings' but, disable once orders have been processed. (which a message to say 'now you can only alter/increase this value from db admin side)

@exileDev
Copy link
Contributor

Closed #4866

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants