Skip to content

Incrementing in a concurrent environment could generate mismatched data between model and db #52732

Discussion options

You must be logged in to vote

Elegant solution for the current situation:
macropay-solutions/laravel-crud-wizard-free@93c8e94

Update + macropay-solutions/laravel-crud-wizard-free@dc47398
inspired by #52786

@marius-mcp

Basically it will refresh only the incremented columns during the model's lifetime, only on first access (after the increment was done). Side effect will be that the issue of adding or subtracting floats or decimals with + and - will be avoided (some numbers can't be stored in binary as in 10 base, and they end up being stored like .99999999...). This is another issue of laravel/lumen increment by the way.

For testing this code can be used coupled with printing the sqls executed:

        $a = [];
        $

Replies: 5 comments 12 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
8 replies
@marius-mcp
Comment options

@Sophist-UK
Comment options

@marius-mcp
Comment options

@marius-mcp
Comment options

@Sophist-UK
Comment options

Comment options

You must be logged in to vote
2 replies
@Sophist-UK
Comment options

@marius-mcp
Comment options

Comment options

You must be logged in to vote
1 reply
@marius-mcp
Comment options

Answer selected by marius-mcp
Comment options

You must be logged in to vote
1 reply
@macropay-solutions
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants