- Solutions are always more difficult than difficulties, so finding problems is more difficult than solving them.
- The origin of the event is that when debugging a model event, a string was casually inserted into the database
ID, not standard
uuid。 Then I found that I can’t find the current model event
- Of course, we can’t always encounter problems, or we may encounter problems because of our own mistakes. We can go there at this timeLaravelofQuestion bankSee what problems you can solve
- First eliminate the errors in your own code, and then debug step by step
- Printed the return variable and found
- Further inspection shows that this integer size is very familiar. I think it should be an integer type size overflow. Then I looked at the source code
- Basically, it is determined that the integer number overflows. Here, it is simply forced conversion according to the variable type, because
PHPIs a weakly typed language, so when the long character is a numeric string, it will lead to incorrect results.
- But I have set the primary key type to string in the model, which should not be the result I want.
- Then I put a question to the frameissues
LaravelMembers of the organizationtillkrussTell me I can submit one
- Then take action immediately. To be honest, it is very simple to solve this problem, because you only need to obtain the primary key type and then perform strong conversion
- I submitted the code immediately and was rejected. It turned out that I forgot to write the test code
- I checked the test code of other databases, found one that is more in line with me, and wrote a database test. Submit. Successfully merged.
- The specific modified code can be viewed here5.7 Improve the return value of the caseKey method
- First submission for large projectsPR, I really feel that I can’t be so casual.
- When writing code, please clearly explain the reason for this code. You will find a lot of comments in the framework
- Don’t forget to write test files
- When you submitPRPlease describe in detail what changes you have made and what new functions have been added.
- Express your ideas freely. There are many people in the community who will help you
Welcome to laravel learning exchange group, group number: 584453488