Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions develop/dev-guide-sample-application-java-jdbc.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,17 @@
- Reduce [boilerplate code](https://en.wikipedia.org/wiki/Boilerplate_code) for managing connections and transactions.
- Manipulate data with data objects instead of a number of SQL statements.

### MySQL compatibility

In MySQL, when you insert data into a `DECIMAL` column, if the number of decimal places exceeds the column's defined scale, MySQL automatically truncates the extra digits and inserts the truncated data successfully, regardless of how many extra decimal places there are.

Check warning on line 287 in develop/dev-guide-sample-application-java-jdbc.md

View workflow job for this annotation

GitHub Actions / vale

[vale] reported by reviewdog 🐶 [PingCAP.Ambiguous] Consider using a clearer word than 'many' because it may cause confusion. Raw Output: {"message": "[PingCAP.Ambiguous] Consider using a clearer word than 'many' because it may cause confusion.", "location": {"path": "develop/dev-guide-sample-application-java-jdbc.md", "range": {"start": {"line": 287, "column": 235}}}, "severity": "INFO"}

In TiDB v8.5.3 and earlier versions:

- If the number of decimal places exceeds the defined scale but does not exceed 72, TiDB also automatically truncates the extra digits and inserts the truncated data successfully.
- However, if the number of decimal places exceeds 72, the insertion fails and returns an error.

Starting from TiDB v8.5.4, TiDB aligns its behavior with MySQL: regardless of how many extra decimal places there are, it automatically truncates the extra digits and inserts the truncated data successfully.

Check warning on line 294 in develop/dev-guide-sample-application-java-jdbc.md

View workflow job for this annotation

GitHub Actions / vale

[vale] reported by reviewdog 🐶 [PingCAP.Ambiguous] Consider using a clearer word than 'many' because it may cause confusion. Raw Output: {"message": "[PingCAP.Ambiguous] Consider using a clearer word than 'many' because it may cause confusion.", "location": {"path": "develop/dev-guide-sample-application-java-jdbc.md", "range": {"start": {"line": 294, "column": 83}}}, "severity": "INFO"}
Comment on lines +287 to +294
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low

The explanation is clear, but it's a bit repetitive. The phrase "automatically truncates the extra digits and inserts the truncated data successfully" is used multiple times. To improve readability and conciseness, I suggest rephrasing this section to be more direct and avoid repetition, in line with the style guide's principle of avoiding unnecessary words (Rule 24).

Suggested change
In MySQL, when you insert data into a `DECIMAL` column, if the number of decimal places exceeds the column's defined scale, MySQL automatically truncates the extra digits and inserts the truncated data successfully, regardless of how many extra decimal places there are.
In TiDB v8.5.3 and earlier versions:
- If the number of decimal places exceeds the defined scale but does not exceed 72, TiDB also automatically truncates the extra digits and inserts the truncated data successfully.
- However, if the number of decimal places exceeds 72, the insertion fails and returns an error.
Starting from TiDB v8.5.4, TiDB aligns its behavior with MySQL: regardless of how many extra decimal places there are, it automatically truncates the extra digits and inserts the truncated data successfully.
When you insert data into a `DECIMAL` column, if the number of decimal places exceeds the column's defined scale, MySQL automatically truncates the extra digits and inserts the data successfully, regardless of the number of extra decimal places.
TiDB's behavior in this scenario varies by version:
- In TiDB v8.5.3 and earlier versions, TiDB also truncates the data and succeeds if the number of extra decimal places does not exceed 72. If it exceeds 72, the insertion fails and returns an error.
- Starting from TiDB v8.5.4, TiDB's behavior is aligned with MySQL, always truncating the extra digits and inserting the data successfully.
References
  1. The documentation should avoid unnecessary words and repetition to be clear and concise. (link)


## Next steps

- Learn more usage of MySQL Connector/J from [the documentation of MySQL Connector/J](https://dev.mysql.com/doc/connector-j/en/).
Expand Down
Loading